Study/server/ai/providers/index.ts
Elijah 25bc03ea75
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 29s
Fourth revision: OpenRouter, live tool stages, Explain layout, share sections
- Interactive blocks are encouraged by default; Explain gets a reduced library
  and never writes practice questions.
- Assistant tool steps breathe while running, show live stages from generation
  and the Python check, and read in the past tense when done.
- The assistant asks before searching the web when class materials do not
  cover a question; clarifying questions list every class's exams and never
  ask about format (always NCLEX).
- Explain opens beside the question from 900px wide, moving the question left
  while open and back on the next one.
- Generate dialog drops the practice set/exam switch (presets cover it) and the
  Generate buttons lose their icon.
- Python check notes are green when every check passed, applied fixes neutral.
- Share pages group by exam, then Quizzes, Flashcards, Notes, Class Materials,
  hiding empty groups; the class page uses the same order. "Documents" is now
  "Class Materials".
- OpenRouter provider replaces the Ollama type; migration 6 turns Ollama
  connections into OpenAI-compatible ones at /v1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 21:54:39 -07:00

28 lines
1.1 KiB
TypeScript

import { AIError, type ProviderAdapter, type ProviderKind } from '../types.ts';
import { anthropicAdapter } from './anthropic.ts';
import { deepseekAdapter } from './deepseek.ts';
import { geminiAdapter } from './gemini.ts';
import { openaiAdapter } from './openai.ts';
import { openaiCompatibleAdapter } from './openaiCompatible.ts';
import { openrouterAdapter } from './openrouter.ts';
const ADAPTERS: Record<ProviderKind, ProviderAdapter> = {
openai: openaiAdapter,
anthropic: anthropicAdapter,
gemini: geminiAdapter,
deepseek: deepseekAdapter,
openrouter: openrouterAdapter,
openai_compatible: openaiCompatibleAdapter,
};
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, cachedInputPrice, cacheWriteRatio, lookupModelDefaults, priceMultiplier } from './catalog.ts';