feat(agent): add llm assistant chat with api tools (task 88)
OpenAI-compatible client with mock fallback, tool-calling loop, and /assistant UI. Tools map to /api/v1/ endpoints per ADR 0006 direct-tools decision.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
export type LlmProviderKind = "mock" | "openai";
|
||||
|
||||
export type LlmConfig = {
|
||||
provider: LlmProviderKind;
|
||||
baseUrl: string | null;
|
||||
apiKey: string | null;
|
||||
model: string;
|
||||
};
|
||||
|
||||
export function getLlmConfig(): LlmConfig {
|
||||
const providerEnv = process.env.LLM_PROVIDER?.trim().toLowerCase();
|
||||
const baseUrl = process.env.LLM_BASE_URL?.trim() || null;
|
||||
const apiKey = process.env.LLM_API_KEY?.trim() || null;
|
||||
const model = process.env.LLM_MODEL?.trim() || "llama3.2";
|
||||
|
||||
if (providerEnv === "mock") {
|
||||
return { provider: "mock", baseUrl: null, apiKey: null, model };
|
||||
}
|
||||
|
||||
if (!baseUrl) {
|
||||
return { provider: "mock", baseUrl: null, apiKey: null, model };
|
||||
}
|
||||
|
||||
return { provider: "openai", baseUrl, apiKey, model };
|
||||
}
|
||||
|
||||
export function isLlmConfigured(): boolean {
|
||||
const config = getLlmConfig();
|
||||
return config.provider === "openai" && Boolean(config.baseUrl);
|
||||
}
|
||||
Reference in New Issue
Block a user