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 fedb0bc5f..34e7c179f 100644 --- a/app/lib/.server/llm/api-key.ts +++ b/app/lib/.server/llm/api-key.ts @@ -30,6 +30,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 17881980d..4dc061fb7 100644 --- a/app/lib/.server/llm/model.ts +++ b/app/lib/.server/llm/model.ts @@ -47,8 +47,10 @@ export function getGroqModel(apiKey: string, model: string) { return openai(model); } -export function getOllamaModel(model: string) { - return ollama(model); +export function getOllamaModel(baseURL: string, model: string) { + let Ollama = ollama(model); + Ollama.config.baseURL = `${baseURL}/api`; + return Ollama; } export function getOpenRouterModel(apiKey: string, model: string) { @@ -77,6 +79,6 @@ export function getModel(provider: string, model: string, env: Env) { case 'OpenAILike': return getOpenAILikeModel(baseURL,apiKey, model); default: - return getOllamaModel(model); + return getOllamaModel(baseURL, model); } } diff --git a/app/utils/constants.ts b/app/utils/constants.ts index 0a806741d..71f886e98 100644 --- a/app/utils/constants.ts +++ b/app/utils/constants.ts @@ -38,7 +38,7 @@ async function getOllamaModels(): Promise { try { const base_url =import.meta.env.OLLAMA_API_BASE_URL || "http://localhost:11434"; const url = new URL(base_url).toString(); - const response = await fetch(`${url}/api/tags`); + const response = await fetch(`${url}api/tags`); const data = await response.json(); return data.models.map((model: any) => ({