This commit is contained in:
lila 2026-07-06 13:09:30 +02:00
parent cc89f0c75c
commit afd28d934e
26 changed files with 2103 additions and 427 deletions

View file

@ -0,0 +1,30 @@
import { LLM_CONFIG } from "../../config/llm.js";
import { OpenAiCompatibleAdapter } from "./openai-compatible.js";
import { GeminiAdapter } from "./gemini.js";
import type { LlmAdapter } from "./types.js";
export function createAdapter(): LlmAdapter {
switch (LLM_CONFIG.provider) {
case "local":
return new OpenAiCompatibleAdapter(LLM_CONFIG.url);
case "openrouter":
return new OpenAiCompatibleAdapter(
LLM_CONFIG.url,
process.env["OPENROUTER_API_KEY"],
LLM_CONFIG.model,
);
case "deepseek":
return new OpenAiCompatibleAdapter(
LLM_CONFIG.url,
process.env["DEEPSEEK_API_KEY"],
LLM_CONFIG.model,
);
case "gemini": {
const apiKey = process.env["GEMINI_API_KEY"];
if (!apiKey) throw new Error("GEMINI_API_KEY env var not set");
if (!LLM_CONFIG.model)
throw new Error("LLM_CONFIG.model required for gemini");
return new GeminiAdapter(apiKey, LLM_CONFIG.model);
}
}
}