Elffuss BraidHub

kikocis/continue public

do not reappend if ends with v1/
Changeset1509c9fc0952ffaba4ac5f31f7165be771bf400fe2354e3fc8d316de853ea8c6
Authoruinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-09-18 08:35 +05:30
Committeruinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-09-18 08:35 +05:30
Parents119be314085b

Browse the files at this changeset

2 files changed

modified packages/openai-adapters/src/index.ts +1 −1
@@ -143,7 +143,7 @@
143143 case "ollama":
144144 // for openai compaitability, we need to add /v1 to the end of the url
145145 // this is required for cli (for core, endpoints are overriden by core/llm/llms/Ollama.ts)
146- if (config.apiBase && !config.apiBase.endsWith("v1")) {
146+ if (config.apiBase && !new RegExp(/v1\/?$/).test(config.apiBase)) {
147147 if (config.apiBase.endsWith("/")) {
148148 config.apiBase += "v1/";
149149 } else {
modified packages/openai-adapters/src/test/main.test.ts +11 −0
@@ -330,4 +330,15 @@
330330 "http://localhost:123/v1/",
331331 );
332332 });
333+
334+ it("should not reappend /v1 to apibase for ollama if it is already present", () => {
335+ const ollama = constructLlmApi({
336+ provider: "ollama",
337+ apiBase: "http://localhost:123/v1/",
338+ });
339+
340+ expect((ollama as OpenAIApi).openai.baseURL).toBe(
341+ "http://localhost:123/v1/",
342+ );
343+ });
333344 });