From e3e456e434b2de9d42283c63ef7f6f7f11aedfef Mon Sep 17 00:00:00 2001 From: Richard C Lim <61879224+richardclim@users.noreply.github.com> Date: Sun, 2 Feb 2025 04:15:57 -0500 Subject: [PATCH] Update common.ts --- app/api/common.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/api/common.ts b/app/api/common.ts index 989c2d7a5..a94ce6297 100644 --- a/app/api/common.ts +++ b/app/api/common.ts @@ -49,11 +49,15 @@ const isAzure = req.nextUrl.pathname.includes("azure/deployments") || Boolean(se ); if (isAzure) { - const isAIFoundation = serverConfig.azureUrl?.includes(".models.ai.azure.com"); - if (!isAIFoundation) { + // const isAIFoundation = serverConfig.azureUrl?.includes(".models.ai.azure.com"); const azureApiVersion = req?.nextUrl?.searchParams?.get("api-version") || 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; // Forward compatibility: @@ -82,7 +86,7 @@ const isAzure = req.nextUrl.pathname.includes("azure/deployments") || Boolean(se path = path.replaceAll(modelName, realDeployName); } } - } + } } const fetchUrl = cloudflareAIGatewayUrl(`${baseUrl}/${path}`);