51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
import GLib from "gi://GLib";
|
|
|
|
export type Backend = "deepseek" | "ollama";
|
|
|
|
export type LLMConfig = {
|
|
backend: Backend;
|
|
baseUrl: string;
|
|
apiKey?: string;
|
|
model: string;
|
|
systemPrompt?: string;
|
|
};
|
|
|
|
/**
|
|
* Sensible defaults per backend.
|
|
*/
|
|
export const BACKEND_DEFAULTS: Record<Backend, Omit<LLMConfig, "model" | "backend">> = {
|
|
deepseek: {
|
|
baseUrl: "https://api.deepseek.com",
|
|
apiKey: GLib.getenv("DEEPSEEK_API_KEY") ?? "",
|
|
systemPrompt: "You are a helpful assistant. Provide short answers.",
|
|
},
|
|
ollama: {
|
|
baseUrl: "http://localhost:11434",
|
|
systemPrompt: "You are a helpful assistant. Provide short answers.",
|
|
},
|
|
};
|
|
|
|
/**
|
|
* Predefined models per backend.
|
|
* The first model in each list is the default for that backend.
|
|
*/
|
|
export const MODELS: Record<Backend, string[]> = {
|
|
deepseek: [
|
|
"deepseek-v4-flash",
|
|
"deepseek-v4-pro",
|
|
],
|
|
|
|
ollama: [
|
|
"granite4.1:3b",
|
|
],
|
|
};
|
|
|
|
/** Build a full LLMConfig for the given backend and optional model override. */
|
|
export function getConfig(backend: Backend, model?: string): LLMConfig {
|
|
const defaults = BACKEND_DEFAULTS[backend];
|
|
return {
|
|
backend,
|
|
...defaults,
|
|
model: model ?? MODELS[backend][0],
|
|
};
|
|
}
|