mirror of
https://github.com/coleam00/bolt.new-any-llm
synced 2024-12-27 22:33:03 +00:00
updated ollama to use defined base URL for model calls
This commit is contained in:
parent
94fa108142
commit
8ce82b5a1c
2
.gitignore
vendored
2
.gitignore
vendored
@ -12,7 +12,7 @@ dist-ssr
|
||||
*.local
|
||||
|
||||
.vscode/*
|
||||
!.vscode/launch.json
|
||||
.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
|
@ -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 "";
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ async function getOllamaModels(): Promise<ModelInfo[]> {
|
||||
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) => ({
|
||||
|
Loading…
Reference in New Issue
Block a user