// Which provider a model runs on, and the config for both (release 27). This // module reads no settings: the caller (an editor job, S6) passes everything in. import { isClaudeModel, type AnthropicConfig } from "./anthropic"; import type { OllamaConfig } from "./ollama"; export type LlmConfig = { anthropic?: AnthropicConfig; ollama?: OllamaConfig }; export type Provider = "api" | "local"; // A Claude model goes to the API; anything else is a local model on ollama. export function providerOf(model: string): Provider { return isClaudeModel(model) ? "api" : "local"; } export function anthropicConfigOf(llm: LlmConfig, model: string): AnthropicConfig { if (!llm.anthropic) throw new Error(`${model} runs on the Claude API, and no API config was given`); return llm.anthropic; } export function ollamaConfigOf(llm: LlmConfig, model: string): OllamaConfig { if (!llm.ollama?.baseUrl) throw new Error(`${model} runs on ollama, and no ollama URL was given`); return llm.ollama; }