mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-09-27 21:56:38 +08:00
Update openai.ts
This commit is contained in:
parent
49dd5d5854
commit
1c15eb7dc9
@ -86,23 +86,16 @@ export class ChatGPTApi implements LLMApi {
|
||||
|
||||
let baseUrl = "";
|
||||
|
||||
const isAzure = path.includes("deployments") || accessStore.azureUrl?.includes(".models.ai.azure.com");
|
||||
const isAzure = path.includes("deployments");
|
||||
if (isAzure && !accessStore.isValidAzure()) {
|
||||
throw Error(
|
||||
"incomplete azure config, please check it in your settings page",
|
||||
);
|
||||
}
|
||||
baseUrl = accessStore.azureUrl;
|
||||
// baseUrl = isAzure ? accessStore.azureUrl : accessStore.openaiUrl;
|
||||
|
||||
if (baseUrl.length === 0) {
|
||||
const isApp = !!getClientConfig()?.isApp;
|
||||
const isAIFoundation = accessStore.azureUrl?.includes(".models.ai.azure.com");
|
||||
if (isAIFoundation) {
|
||||
baseUrl = accessStore.azureUrl;
|
||||
} else {
|
||||
const apiPath = ApiPath.Azure;
|
||||
baseUrl = accessStore.azureUrl;
|
||||
// const apiPath = isAzure ? ApiPath.Azure : ApiPath.OpenAI;
|
||||
// baseUrl = isApp ? OPENAI_BASE_URL : apiPath;
|
||||
}
|
||||
@ -259,13 +252,6 @@ export class ChatGPTApi implements LLMApi {
|
||||
try {
|
||||
let chatPath = "";
|
||||
if (modelConfig.providerName === ServiceProvider.Azure) {
|
||||
const isAIFoundation = useAccessStore.getState().azureUrl?.includes(".models.ai.azure.com");
|
||||
const azureUrl = useAccessStore.getState().azureUrl;
|
||||
if (!azureUrl) {
|
||||
throw new Error("Azure URL is not configured");
|
||||
}
|
||||
const sanitizedAzureUrl = azureUrl.replace(/\/+$/, "");
|
||||
chatPath = cloudflareAIGatewayUrl(`${sanitizedAzureUrl}/chat/completions`);
|
||||
// find model, and get displayName as deployName
|
||||
const { models: configModels, customModels: configCustomModels } =
|
||||
useAppConfig.getState();
|
||||
@ -284,17 +270,16 @@ export class ChatGPTApi implements LLMApi {
|
||||
model.name === modelConfig.model &&
|
||||
model?.provider?.providerName === ServiceProvider.Azure,
|
||||
);
|
||||
/* chatPath = this.path(
|
||||
chatPath = this.path(
|
||||
(isDalle3 ? Azure.ImagePath : Azure.ChatPath)(
|
||||
(model?.displayName ?? model?.name) as string,
|
||||
useCustomConfig ? useAccessStore.getState().azureApiVersion : "",
|
||||
),
|
||||
);*/
|
||||
} else {
|
||||
chatPath = this.path(
|
||||
isDalle3 ? OpenaiPath.ImagePath : OpenaiPath.ChatPath,
|
||||
);
|
||||
}
|
||||
if (!modelConfig.providerName === ServiceProvider.Azure) {
|
||||
throw Error("ModelConfig is not the same as Azure);
|
||||
}
|
||||
if (shouldStream) {
|
||||
let index = -1;
|
||||
const [tools, funcs] = usePluginStore
|
||||
|
Loading…
Reference in New Issue
Block a user