Update common.ts

This commit is contained in:
Richard C Lim 2025-02-02 04:15:57 -05:00 committed by GitHub
parent 22da0d4bfc
commit e3e456e434
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -49,11 +49,15 @@ const isAzure = req.nextUrl.pathname.includes("azure/deployments") || Boolean(se
); );
if (isAzure) { if (isAzure) {
const isAIFoundation = serverConfig.azureUrl?.includes(".models.ai.azure.com"); // const isAIFoundation = serverConfig.azureUrl?.includes(".models.ai.azure.com");
if (!isAIFoundation) {
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");
if (isAIFoundation) {
// For AI Foundation models, use direct path without deployments
path = "chat/completions";
} else {
baseUrl = baseUrl.split("/deployments").shift() as string; baseUrl = baseUrl.split("/deployments").shift() as string;
// Forward compatibility: // Forward compatibility:
@ -82,7 +86,7 @@ const isAzure = req.nextUrl.pathname.includes("azure/deployments") || Boolean(se
path = path.replaceAll(modelName, realDeployName); path = path.replaceAll(modelName, realDeployName);
} }
} }
} }
} }
const fetchUrl = cloudflareAIGatewayUrl(`${baseUrl}/${path}`); const fetchUrl = cloudflareAIGatewayUrl(`${baseUrl}/${path}`);