Changesets · Branches · Tags · Compare
| Changeset | 1509c9fc0952ffaba4ac5f31f7165be771bf400fe2354e3fc8d316de853ea8c6 |
|---|---|
| Author | uinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-09-18 08:35 +05:30 |
| Committer | uinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-09-18 08:35 +05:30 |
| Parents | 119be314085b |
2 files changed
modified packages/openai-adapters/src/index.ts +1 −1
| @@ -143,7 +143,7 @@ | ||
| 143 | 143 | case "ollama": |
| 144 | 144 | // for openai compaitability, we need to add /v1 to the end of the url |
| 145 | 145 | // 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)) { | |
| 147 | 147 | if (config.apiBase.endsWith("/")) { |
| 148 | 148 | config.apiBase += "v1/"; |
| 149 | 149 | } else { |
modified packages/openai-adapters/src/test/main.test.ts +11 −0
| @@ -330,4 +330,15 @@ | ||
| 330 | 330 | "http://localhost:123/v1/", |
| 331 | 331 | ); |
| 332 | 332 | }); |
| 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 | + }); | |
| 333 | 344 | }); |