Files
intelligence-terminal/lib/llm/litellm.mjs
MrSphay e0e408d1eb
All checks were successful
Codex Template Compliance / template-compliance (pull_request) Successful in 6s
Build / test-and-image (pull_request) Successful in 1m12s
feat: add LiteLLM provider and Code-Inc image target
2026-07-03 23:06:33 +02:00

33 lines
1.1 KiB
JavaScript

// LiteLLM proxy provider using the OpenAI-compatible chat completions API.
import { OpenAICompatibleProvider } from './openai-compatible.mjs';
export class LiteLLMProvider extends OpenAICompatibleProvider {
constructor(config = {}) {
const baseUrl = config.baseUrl?.replace(/\/+$/, '') || null;
const model = config.model || null;
super({
...config,
name: 'litellm',
baseUrl: baseUrl || 'http://localhost:4000/v1',
model: model || 'unconfigured',
requiresApiKey: true,
});
this.baseUrl = baseUrl;
this.model = model;
}
get isConfigured() {
return Boolean(this.baseUrl && this.apiKey && this.model);
}
get status() {
if (!this.baseUrl) return { state: 'misconfigured', reason: 'LLM_BASE_URL is required for LiteLLM' };
if (!this.apiKey) return { state: 'misconfigured', reason: 'LLM_API_KEY is required for LiteLLM' };
if (!this.model) return { state: 'misconfigured', reason: 'LLM_MODEL is required for LiteLLM' };
return { state: 'configured', provider: this.name, model: this.model, baseUrl: this.baseUrl };
}
}