mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-09-27 21:56:38 +08:00
Update common.ts
This commit is contained in:
parent
dad9c9caf6
commit
6ba449d80e
@ -3,14 +3,17 @@ import { getServerSideConfig } from "../config/server";
|
|||||||
import { OPENAI_BASE_URL, ServiceProvider } from "../constant";
|
import { OPENAI_BASE_URL, ServiceProvider } from "../constant";
|
||||||
import { cloudflareAIGatewayUrl } from "../utils/cloudflare";
|
import { cloudflareAIGatewayUrl } from "../utils/cloudflare";
|
||||||
import { getModelProvider, isModelNotavailableInServer } from "../utils/model";
|
import { getModelProvider, isModelNotavailableInServer } from "../utils/model";
|
||||||
|
import { useChatStore } from "../store";
|
||||||
|
|
||||||
const serverConfig = getServerSideConfig();
|
const serverConfig = getServerSideConfig();
|
||||||
|
|
||||||
export async function requestOpenai(req: NextRequest) {
|
export async function requestOpenai(req: NextRequest) {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
|
|
||||||
const isAzure = req.nextUrl.pathname.includes("azure/deployments") || Boolean(serverConfig.azureUrl && serverConfig.azureUrl.includes(".models.ai.azure.com"));
|
console.log("[pathname: Azure?]", req.nextUrl.pathname);
|
||||||
|
const isAzure = req.nextUrl.pathname.includes("azure/deployments");
|
||||||
|
//|| Boolean(serverConfig.azureUrl && serverConfig.azureUrl.includes(".models.ai.azure.com"))
|
||||||
|
console.log("[Auth Header Name]", authHeaderName);
|
||||||
var authValue,
|
var authValue,
|
||||||
authHeaderName = "";
|
authHeaderName = "";
|
||||||
if (isAzure) {
|
if (isAzure) {
|
||||||
@ -51,16 +54,14 @@ console.log("[Auth Value Present]", !!authValue);
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (isAzure) {
|
if (isAzure) {
|
||||||
console.log("[Original Path]", req.nextUrl.pathname); // Log initial path
|
console.log("[Original Path: azure check]", req.nextUrl.pathname); // Log initial path
|
||||||
// const isAIFoundation = serverConfig.azureUrl?.includes(".models.ai.azure.com");
|
|
||||||
const azureApiVersion =
|
const azureApiVersion =
|
||||||
req?.nextUrl?.searchParams?.get("api-version") ||
|
req?.nextUrl?.searchParams?.get("api-version") ||
|
||||||
serverConfig.azureApiVersion;
|
serverConfig.azureApiVersion;
|
||||||
const isAIFoundation = baseUrl.includes(".models.ai.azure.com");
|
const modelConfig = useChatStore.getState().currentSession().mask.modelConfig;
|
||||||
console.log("[Is AI Foundation]", isAIFoundation);
|
const deepSeek = modelConfig.model.includes("deekseek");
|
||||||
if (isAIFoundation) {
|
console.log("[Is AI deepSeek?]", deepSeek);
|
||||||
// For AI Foundation models, use direct path without deployments
|
if (deepSeek) {
|
||||||
// failed to work. path = "chat/completions";
|
|
||||||
path = "chat/completions";
|
path = "chat/completions";
|
||||||
/* path = req.nextUrl.pathname
|
/* path = req.nextUrl.pathname
|
||||||
.replace("/api/azure/openai/", "")
|
.replace("/api/azure/openai/", "")
|
||||||
|
Loading…
Reference in New Issue
Block a user