Merge remote-tracking branch 'origin/main' into feat-baidu

This commit is contained in:
lloydzhou
2024-07-09 15:06:10 +08:00
5 changed files with 43 additions and 3 deletions

View File

@@ -66,6 +66,31 @@ export async function requestOpenai(req: NextRequest) {
"/api/azure/",
"",
)}?api-version=${azureApiVersion}`;
// Forward compatibility:
// if display_name(deployment_name) not set, and '{deploy-id}' in AZURE_URL
// then using default '{deploy-id}'
if (serverConfig.customModels) {
const modelName = path.split("/")[1];
let realDeployName = "";
serverConfig.customModels
.split(",")
.filter((v) => !!v && !v.startsWith("-") && v.includes(modelName))
.forEach((m) => {
const [fullName, displayName] = m.split("=");
const [_, providerName] = fullName.split("@");
if (providerName === "azure" && !displayName) {
const [_, deployId] = serverConfig.azureUrl.split("deployments/");
if (deployId) {
realDeployName = deployId;
}
}
});
if (realDeployName) {
console.log("[Replace with DeployId", realDeployName);
path = path.replaceAll(modelName, realDeployName);
}
}
}
const fetchUrl = `${baseUrl}/${path}`;