mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-09-27 05:36:39 +08:00
Update common.ts
This commit is contained in:
parent
762f2cba5c
commit
06472adea9
@ -3,7 +3,6 @@ import { getServerSideConfig } from "../config/server";
|
||||
import { OPENAI_BASE_URL, ServiceProvider } from "../constant";
|
||||
import { cloudflareAIGatewayUrl } from "../utils/cloudflare";
|
||||
import { getModelProvider, isModelNotavailableInServer } from "../utils/model";
|
||||
import { useChatStore } from "../store";
|
||||
|
||||
const serverConfig = getServerSideConfig();
|
||||
|
||||
@ -58,10 +57,9 @@ console.log("[Auth Value Present]", !!authValue);
|
||||
const azureApiVersion =
|
||||
req?.nextUrl?.searchParams?.get("api-version") ||
|
||||
serverConfig.azureApiVersion;
|
||||
const modelConfig = useChatStore.getState().currentSession().mask.modelConfig;
|
||||
const deepSeek = modelConfig.model.includes("deekseek");
|
||||
console.log("[Is AI deepSeek?]", deepSeek);
|
||||
if (deepSeek) {
|
||||
const isAIFoundation = baseUrl.includes(".models.ai.azure.com");
|
||||
console.log("[Is AI Foundation]", isAIFoundation);
|
||||
if (isAIFoundation) {
|
||||
path = "chat/completions";
|
||||
/* path = req.nextUrl.pathname
|
||||
.replace("/api/azure/openai/", "")
|
||||
@ -70,13 +68,15 @@ console.log("[Auth Value Present]", !!authValue);
|
||||
.slice(-2)
|
||||
.join("/");
|
||||
*/
|
||||
} else {
|
||||
baseUrl = baseUrl.split("/deployments").shift() as string;
|
||||
path = `${req.nextUrl.pathname.replaceAll(
|
||||
"/api/azure/",
|
||||
"",
|
||||
)}?api-version=${azureApiVersion}`;
|
||||
console.log("[Azure OpenAI Path]", path);
|
||||
} else {
|
||||
baseUrl = baseUrl.split("/deployments").shift() as string;
|
||||
path = `${req.nextUrl.pathname.replaceAll(
|
||||
"/api/azure/",
|
||||
"",
|
||||
)}?api-version=${azureApiVersion}`;
|
||||
console.log("[Azure OpenAI Path]", path);
|
||||
}
|
||||
|
||||
// Forward compatibility:
|
||||
// if display_name(deployment_name) not set, and '{deploy-id}' in AZURE_URL
|
||||
// then using default '{deploy-id}'
|
||||
@ -102,7 +102,6 @@ console.log("[Auth Value Present]", !!authValue);
|
||||
console.log("[Replace with DeployId", realDeployName);
|
||||
path = path.replaceAll(modelName, realDeployName);
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log("[Final Path]", path);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user