do not reappend if ends with v1/
This commit is contained in:
parent
c1b850777d
commit
648899034f
2 changed files with 12 additions and 1 deletions
|
|
@ -143,7 +143,7 @@ export function constructLlmApi(config: LLMConfig): BaseLlmApi | undefined {
|
|||
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 && !new RegExp(/v1\/?$/).test(config.apiBase)) {
|
||||
if (config.apiBase.endsWith("/")) {
|
||||
config.apiBase += "v1/";
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -330,4 +330,15 @@ describe("Configuration", () => {
|
|||
"http://localhost:123/v1/",
|
||||
);
|
||||
});
|
||||
|
||||
it("should not reappend /v1 to apibase for ollama if it is already present", () => {
|
||||
const ollama = constructLlmApi({
|
||||
provider: "ollama",
|
||||
apiBase: "http://localhost:123/v1/",
|
||||
});
|
||||
|
||||
expect((ollama as OpenAIApi).openai.baseURL).toBe(
|
||||
"http://localhost:123/v1/",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue