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