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:
Zoe
2026-04-27 12:04:49 -05:00
parent 6ca4de4cab
commit 1d40812f2a
21 changed files with 1221 additions and 798 deletions
-25
View File
@@ -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;