diff --git a/.gitignore b/.gitignore index 20f5d1506..f141cc0ef 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,7 @@ dist-ssr *.local .vscode/* -!.vscode/launch.json +.vscode/launch.json !.vscode/extensions.json .idea .DS_Store diff --git a/app/lib/.server/llm/api-key.ts b/app/lib/.server/llm/api-key.ts index a1fd3a022..e7aaf59d1 100644 --- a/app/lib/.server/llm/api-key.ts +++ b/app/lib/.server/llm/api-key.ts @@ -34,6 +34,8 @@ export function getBaseURL(cloudflareEnv: Env, provider: string) { switch (provider) { case 'OpenAILike': return env.OPENAI_LIKE_API_BASE_URL || cloudflareEnv.OPENAI_LIKE_API_BASE_URL; + case 'Ollama': + return env.OLLAMA_API_BASE_URL || cloudflareEnv.OLLAMA_API_BASE_URL; default: return ""; } diff --git a/app/lib/.server/llm/model.ts b/app/lib/.server/llm/model.ts index 9c792893a..390d57aeb 100644 --- a/app/lib/.server/llm/model.ts +++ b/app/lib/.server/llm/model.ts @@ -57,6 +57,12 @@ export function getGroqModel(apiKey: string, model: string) { return openai(model); } +export function getOllamaModel(baseURL: string, model: string) { + let Ollama = ollama(model); + Ollama.config.baseURL = `${baseURL}/api`; + return Ollama; +} + export function getDeepseekModel(apiKey: string, model: string){ const openai = createOpenAI({ baseURL: 'https://api.deepseek.com/beta', @@ -65,9 +71,6 @@ export function getDeepseekModel(apiKey: string, model: string){ return openai(model); } -export function getOllamaModel(model: string) { - return ollama(model); -} export function getOpenRouterModel(apiKey: string, model: string) { const openRouter = createOpenRouter({ @@ -99,6 +102,6 @@ export function getModel(provider: string, model: string, env: Env) { case 'Mistral': return getMistralModel(apiKey, model); default: - return getOllamaModel(model); + return getOllamaModel(baseURL, model); } }