V1 remains intact on main and in history. This branch replaces it with a new application: node:sqlite storage with migrations, scrypt auth and sessions, content/SRS/attempt/stats services, document extraction and chunking, a provider-neutral AI layer (OpenAI, Anthropic, Gemini, OpenAI-compatible, Ollama), the generation pipeline and the tool-using assistant. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
26 lines
1,020 B
TypeScript
26 lines
1,020 B
TypeScript
import { AIError, type ProviderAdapter, type ProviderKind } from '../types.ts';
|
|
import { anthropicAdapter } from './anthropic.ts';
|
|
import { geminiAdapter } from './gemini.ts';
|
|
import { ollamaAdapter } from './ollama.ts';
|
|
import { openaiAdapter } from './openai.ts';
|
|
import { openaiCompatibleAdapter } from './openaiCompatible.ts';
|
|
|
|
const ADAPTERS: Record<ProviderKind, ProviderAdapter> = {
|
|
openai: openaiAdapter,
|
|
anthropic: anthropicAdapter,
|
|
gemini: geminiAdapter,
|
|
openai_compatible: openaiCompatibleAdapter,
|
|
ollama: ollamaAdapter,
|
|
};
|
|
|
|
export function getAdapter(kind: ProviderKind): ProviderAdapter {
|
|
const adapter = ADAPTERS[kind];
|
|
if (!adapter) throw new AIError('unsupported', `Unknown provider type "${kind}".`);
|
|
return adapter;
|
|
}
|
|
|
|
export function listAdapterMeta(): Array<{ kind: ProviderKind } & ProviderAdapter['meta']> {
|
|
return (Object.keys(ADAPTERS) as ProviderKind[]).map((kind) => ({ kind, ...ADAPTERS[kind].meta }));
|
|
}
|
|
|
|
export { CATALOG_UPDATED, lookupModelDefaults } from './catalog.ts';
|