21 lines
618 B
JavaScript
21 lines
618 B
JavaScript
// Ollama Provider — OpenAI-compatible Chat Completions API
|
|
|
|
import { OpenAICompatibleProvider } from './openai-compatible.mjs';
|
|
|
|
export class OllamaProvider extends OpenAICompatibleProvider {
|
|
constructor(config) {
|
|
const rawBaseUrl = config.baseUrl || 'http://localhost:11434';
|
|
const baseUrl = rawBaseUrl.replace(/\/+$/, '').endsWith('/v1')
|
|
? rawBaseUrl
|
|
: `${rawBaseUrl.replace(/\/+$/, '')}/v1`;
|
|
super({
|
|
...config,
|
|
name: 'ollama',
|
|
baseUrl,
|
|
model: config.model || 'llama3.1:8b',
|
|
requiresApiKey: false,
|
|
timeoutMs: config.timeoutMs || 120000,
|
|
});
|
|
}
|
|
}
|