using default azure api-version value

This commit is contained in:
lloydzhou 2024-07-06 00:05:59 +08:00
parent 14bc1b6aac
commit 6dc4844c12
2 changed files with 9 additions and 4 deletions

View File

@ -58,7 +58,9 @@ export async function requestOpenai(req: NextRequest) {
); );
if (isAzure) { if (isAzure) {
const azureApiVersion = req?.nextUrl?.searchParams?.get("api-version"); const azureApiVersion =
req?.nextUrl?.searchParams?.get("api-version") ||
serverConfig.azureApiVersion;
baseUrl = baseUrl.split("/deployments").shift() as string; baseUrl = baseUrl.split("/deployments").shift() as string;
path = `${req.nextUrl.pathname.replaceAll( path = `${req.nextUrl.pathname.replaceAll(
"/api/azure/", "/api/azure/",

View File

@ -146,8 +146,11 @@ export class ChatGPTApi implements LLMApi {
// find model, and get displayName as deployName // find model, and get displayName as deployName
const { models: configModels, customModels: configCustomModels } = const { models: configModels, customModels: configCustomModels } =
useAppConfig.getState(); useAppConfig.getState();
const { defaultModel, customModels: accessCustomModels } = const {
useAccessStore.getState(); defaultModel,
customModels: accessCustomModels,
useCustomConfig,
} = useAccessStore.getState();
const models = collectModelsWithDefaultModel( const models = collectModelsWithDefaultModel(
configModels, configModels,
[configCustomModels, accessCustomModels].join(","), [configCustomModels, accessCustomModels].join(","),
@ -161,7 +164,7 @@ export class ChatGPTApi implements LLMApi {
chatPath = this.path( chatPath = this.path(
Azure.ChatPath( Azure.ChatPath(
(model?.displayName ?? model?.name) as string, (model?.displayName ?? model?.name) as string,
useAccessStore.getState().azureApiVersion, useCustomConfig ? useAccessStore.getState().azureApiVersion : "",
), ),
); );
} else { } else {