fix: append /v1 to ollama in openai-adapters

This commit is contained in:
uinstinct 2025-09-17 22:08:46 +05:30
parent f8ea904f3d
commit 22784ece8d

View file

@ -141,6 +141,15 @@ export function constructLlmApi(config: LLMConfig): BaseLlmApi | undefined {
case "lmstudio":
return openAICompatible("http://localhost:1234/", config);
case "ollama":
// for openai compaitability, we need to add /v1 to the end of the url
// this is required for cli (for core, endpoints are overriden by core/llm/llms/Ollama.ts)
if (config.apiBase && !config.apiBase.endsWith("v1")) {
if (config.apiBase.endsWith("/")) {
config.apiBase += "v1/";
} else {
config.apiBase += "/v1/";
}
}
return openAICompatible("http://localhost:11434/v1/", config);
case "mock":
return new MockApi();