Update common.ts

This commit is contained in:
Richard C Lim 2025-02-08 22:38:17 -05:00 committed by GitHub
parent 762f2cba5c
commit 06472adea9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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);
}