33 lines
1.1 KiB
JavaScript
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 };
|
|
}
|
|
}
|