Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/llm/llms/OpenAI-compatible.vitest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ createOpenAISubclassTests(Kindo, {

createOpenAISubclassTests(Azure, {
providerName: "azure",
customEmbeddingsUrl:
"https://api.openai.com/v1/openai/deployments/text-embedding-ada-002/embeddings?api-version=2023-07-01-preview",
});

createOpenAISubclassTests(Inception, {
Expand Down
13 changes: 8 additions & 5 deletions core/llm/llms/OpenAI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -705,11 +705,14 @@ class OpenAI extends BaseLLM {
);
}

if (this.apiType === "azure") {
return new URL(
`openai/deployments/${this.deployment}/embeddings?api-version=${this.apiVersion}`,
this.apiBase,
);
if (this.apiType?.includes("azure")) {
const isAzureOpenAI =
this.apiType === "azure-openai" || this.apiType === "azure";
const path = isAzureOpenAI
? `openai/deployments/${this.deployment}/embeddings`
: "embeddings";
const version = this.apiVersion ? `?api-version=${this.apiVersion}` : "";
return new URL(`${path}${version}`, this.apiBase);
}
return new URL("embeddings", this.apiBase);
}
Expand Down
34 changes: 34 additions & 0 deletions core/llm/llms/OpenAI.vitest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,4 +424,38 @@ describe("OpenAI", () => {
},
});
});

test("_getEmbedEndpoint should construct correct Azure deployment URL", () => {
const openai = new OpenAI({
apiType: "azure-openai",
apiBase: "https://test.openai.azure.com/",
deployment: "gpt-5.4",
apiVersion: "2024-02-15-preview",
model: "gpt-5.4",
apiKey: "test-key",
});

const endpoint = (openai as any)["_getEmbedEndpoint"]();
const url = endpoint.toString();

expect(url).toContain("openai/deployments/gpt-5.4/embeddings");
expect(url).toContain("api-version=2024-02-15-preview");
});

test("_getEmbedEndpoint should not use deployment path for azure-foundry", () => {
const openai = new OpenAI({
apiType: "azure-foundry",
apiBase: "https://test.services.ai.azure.com/",
apiVersion: "2024-05-01-preview",
model: "text-embedding-ada-002",
apiKey: "test-key",
});

const endpoint = (openai as any)["_getEmbedEndpoint"]();
const url = endpoint.toString();

expect(url).not.toContain("openai/deployments");
expect(url).toContain("embeddings");
expect(url).toContain("api-version=2024-05-01-preview");
});
});
Loading