refactor: extract provider logic into modular registry
Each AI provider now has its own module implementing a ProviderModule interface with createGateway, getAuthHeaders, and fetchModels methods. This replaces the monolithic switch statements in ai-provider.ts and models.post.ts with a clean registry pattern.
This commit is contained in:
@@ -1,30 +1,5 @@
|
||||
import * as schema from '~~/drizzle/schema';
|
||||
|
||||
export const Providers = [
|
||||
'openrouter',
|
||||
'ollama',
|
||||
'vllm',
|
||||
'cerebras',
|
||||
'google',
|
||||
'longcat',
|
||||
'cohere',
|
||||
'inception',
|
||||
'mistral',
|
||||
'closedrouter',
|
||||
] as const;
|
||||
export const SupportedModalities = ['text', 'image', 'audio', 'video', 'pdf'] as const;
|
||||
|
||||
export const providerBaseUrls = {
|
||||
openrouter: 'https://openrouter.ai/api/v1',
|
||||
vllm: '',
|
||||
ollama: '',
|
||||
cerebras: 'https://api.cerebras.ai/v1',
|
||||
google: 'https://generativelanguage.googleapis.com/v1beta',
|
||||
longcat: 'https://api.longcat.chat/openai/v1',
|
||||
cohere: 'https://api.cohere.ai/v2',
|
||||
inception: 'https://api.inceptionlabs.ai/v1',
|
||||
mistral: 'https://api.mistral.ai/v1',
|
||||
closedrouter: 'https://router.queef.in/v1',
|
||||
};
|
||||
|
||||
export type Model = typeof schema.models.$inferSelect;
|
||||
|
||||
Reference in New Issue
Block a user