Update openai.ts

This commit is contained in:
Richard C Lim 2025-02-02 03:39:27 -05:00 committed by GitHub
parent 1c4970b5bc
commit 7594379e54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -87,19 +87,21 @@ export class ChatGPTApi implements LLMApi {
let baseUrl = "";
const isAzure = path.includes("deployments");
if (accessStore.useCustomConfig) {
if (isAzure && !accessStore.isValidAzure()) {
throw Error(
"incomplete azure config, please check it in your settings page",
);
}
baseUrl = isAzure ? accessStore.azureUrl : accessStore.openaiUrl;
}
if (baseUrl.length === 0) {
const isApp = !!getClientConfig()?.isApp;
const apiPath = ApiPath.Azure;
// const apiPath = isAzure ? ApiPath.Azure : ApiPath.OpenAI;
// baseUrl = isApp ? OPENAI_BASE_URL : apiPath;
const apiPath = isAzure ? ApiPath.Azure : ApiPath.OpenAI;
baseUrl = isApp ? OPENAI_BASE_URL : apiPath;
}
};
if (baseUrl.endsWith("/")) {
baseUrl = baseUrl.slice(0, baseUrl.length - 1);
@ -276,9 +278,10 @@ export class ChatGPTApi implements LLMApi {
useCustomConfig ? useAccessStore.getState().azureApiVersion : "",
),
);
}
if (!modelConfig.providerName === ServiceProvider.Azure) {
throw Error("ModelConfig is not the same as Azure);
} else {
chatPath = this.path(
isDalle3 ? OpenaiPath.ImagePath : OpenaiPath.ChatPath,
);
}
if (shouldStream) {
let index = -1;