feat: multi-provider AI support with per-provider model selection

- Add llm-factory.ts: unified LLM provider abstraction (Google/Claude/OpenAI)
- Install @langchain/anthropic and @langchain/openai packages
- resolveAiProvider picks active provider from DB settings (Claude > OpenAI > Google)
- All AI graphs (reminder, new-patient, reschedule, internal-chat) now accept provider+model params
- Add claudeAiModel, openAiModel, googleAiModel columns to ai_settings table
- New PUT /api/ai/provider-model route to save selected model per provider
- UI model dropdowns for Claude (Haiku/Sonnet/Opus), OpenAI (GPT-5.x series), Google (Gemini 2.5/3.x)
- Google AI section also gets model selector alongside existing API key field

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ff
2026-06-06 09:34:11 -04:00
co-authored by Claude Sonnet 4.6
parent d5bc96ff39
commit 4899ab8368
57 changed files with 681 additions and 138 deletions
+5 -3
View File
@@ -1,4 +1,4 @@
import { ChatGoogleGenerativeAI } from "@langchain/google-genai";
import { getLlm, type AiProvider } from "./llm-factory";
// ─── Intent types ─────────────────────────────────────────────────────────────
@@ -92,7 +92,9 @@ export async function classifyInternalChat(
message: string,
apiKey: string,
extraSystemPrompt?: string,
history: { role: "user" | "assistant"; text: string }[] = []
history: { role: "user" | "assistant"; text: string }[] = [],
provider: AiProvider = "google",
model?: string
): Promise<ChatClassification> {
const fallback: ChatClassification = {
intent: "general",
@@ -107,7 +109,7 @@ export async function classifyInternalChat(
: BASE_SYSTEM_PROMPT;
try {
const llm = new ChatGoogleGenerativeAI({ model: "gemini-flash-latest", apiKey });
const llm = getLlm(provider, apiKey, model);
// Gemini requires conversation to start with a user turn — drop any leading assistant messages
const trimmedHistory = history.slice(