fix(ollama-local): support custom host URL for remote Ollama servers (closes #578)

Add a shared resolveOllamaLocalHost() helper and wire it through the
executor, models/validate/test routes, so users can point ollama-local
at a remote Ollama instance instead of being locked to localhost:11434.

Also expose the host as an "Ollama Host URL" field in AddApiKeyModal
(empty = default localhost:11434), making the option reachable from the
dashboard without hand-editing db.json.

Co-authored-by: anuragg-saxenaa <anuragg.saxenaa@gmail.com>
Made-with: Cursor
This commit is contained in:
anuragg-saxenaa
2026-04-22 10:42:34 +07:00
committed by decolua
parent 94ab0d715d
commit 4638cf0e81
6 changed files with 77 additions and 31 deletions

View File

@@ -339,3 +339,10 @@ export const PROVIDERS = {
noAuth: true
},
};
export const OLLAMA_LOCAL_DEFAULT_HOST = "http://localhost:11434";
export function resolveOllamaLocalHost(credentials) {
const raw = credentials?.providerSpecificData?.baseUrl?.trim();
return (raw || OLLAMA_LOCAL_DEFAULT_HOST).replace(/\/$/, "");
}

View File

@@ -1,4 +1,5 @@
import { HTTP_STATUS, RETRY_CONFIG, DEFAULT_RETRY_CONFIG } from "../config/runtimeConfig.js";
import { resolveOllamaLocalHost } from "../config/providers.js";
import { proxyAwareFetch } from "../utils/proxyFetch.js";
/**
@@ -35,6 +36,9 @@ export class BaseExecutor {
const normalized = baseUrl.replace(/\/$/, "");
return `${normalized}/messages`;
}
if (this.provider === "ollama-local") {
return `${resolveOllamaLocalHost(credentials)}/api/chat`;
}
const baseUrls = this.getBaseUrls();
return baseUrls[urlIndex] || baseUrls[0] || this.config.baseUrl;
}