Skip to content

Commit

Permalink
fix: update API version query in Azure OpenAI key validation
Browse files Browse the repository at this point in the history
  • Loading branch information
liby committed Jan 11, 2024
1 parent dd123bc commit 83e8811
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ function pluginValidate(completion) {
}

const apiKey = getApiKey(apiKeys);
const apiVersionQuery = apiVersion ? `?api-version=${apiVersion}` : "?api-version=2023-03-15-preview";
const baseUrl = ensureHttpsAndNoTrailingSlash(apiUrl || "https://api.openai.com");
let apiUrlPath = baseUrl.includes("gateway.ai.cloudflare.com") ? "/models" : "/v1/models";

Expand All @@ -353,7 +352,7 @@ function pluginValidate(completion) {
});
return;
}
apiUrlPath = `/openai/deployments/${deploymentName}/chat/completions${apiVersionQuery}`;
apiUrlPath = `/openai/deployments/${deploymentName}/chat/completions?api-version=2023-05-15`;
}

const header = buildHeader(isAzureServiceProvider, apiKey);
Expand All @@ -378,7 +377,7 @@ function pluginValidate(completion) {
});
return;
}
if (resp.data.choices) {
if (resp.data.choices.length > 0) {
completion({
result: true,
})
Expand Down

0 comments on commit 83e8811

Please sign in to comment.