hotfix
This commit is contained in:
parent
7a5596b909
commit
aa08183439
|
@ -4,6 +4,7 @@ import {
|
||||||
Anthropic,
|
Anthropic,
|
||||||
ApiPath,
|
ApiPath,
|
||||||
DEFAULT_MODELS,
|
DEFAULT_MODELS,
|
||||||
|
ServiceProvider,
|
||||||
ModelProvider,
|
ModelProvider,
|
||||||
} from "@/app/constant";
|
} from "@/app/constant";
|
||||||
import { prettyObject } from "@/app/utils/format";
|
import { prettyObject } from "@/app/utils/format";
|
||||||
|
@ -143,7 +144,11 @@ async function request(req: NextRequest) {
|
||||||
|
|
||||||
// not undefined and is false
|
// not undefined and is false
|
||||||
if (
|
if (
|
||||||
isModelAvailableInServer(serverConfig.customModels, jsonBody?.model)
|
isModelAvailableInServer(
|
||||||
|
serverConfig.customModels,
|
||||||
|
jsonBody?.model,
|
||||||
|
ServiceProvider.Anthropic,
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
import { getServerSideConfig } from "../config/server";
|
import { getServerSideConfig } from "../config/server";
|
||||||
import { DEFAULT_MODELS, OPENAI_BASE_URL, GEMINI_BASE_URL } from "../constant";
|
import {
|
||||||
|
DEFAULT_MODELS,
|
||||||
|
OPENAI_BASE_URL,
|
||||||
|
GEMINI_BASE_URL,
|
||||||
|
ServiceProvider,
|
||||||
|
} from "../constant";
|
||||||
import { isModelAvailableInServer } from "../utils/model";
|
import { isModelAvailableInServer } from "../utils/model";
|
||||||
import { makeAzurePath } from "../azure";
|
import { makeAzurePath } from "../azure";
|
||||||
|
|
||||||
|
@ -90,7 +95,16 @@ export async function requestOpenai(req: NextRequest) {
|
||||||
|
|
||||||
// not undefined and is false
|
// not undefined and is false
|
||||||
if (
|
if (
|
||||||
isModelAvailableInServer(serverConfig.customModels, jsonBody?.model)
|
isModelAvailableInServer(
|
||||||
|
serverConfig.customModels,
|
||||||
|
jsonBody?.model,
|
||||||
|
ServiceProvider.OpenAI,
|
||||||
|
) ||
|
||||||
|
isModelAvailableInServer(
|
||||||
|
serverConfig.customModels,
|
||||||
|
jsonBody?.model,
|
||||||
|
ServiceProvider.Azure,
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
|
|
|
@ -116,12 +116,12 @@ export const useAppConfig = createPersistStore(
|
||||||
|
|
||||||
for (const model of oldModels) {
|
for (const model of oldModels) {
|
||||||
model.available = false;
|
model.available = false;
|
||||||
modelMap[`${model.name}@${model.provider.name}`] = model;
|
modelMap[`${model.name}@${model?.provider?.name}`] = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const model of newModels) {
|
for (const model of newModels) {
|
||||||
model.available = true;
|
model.available = true;
|
||||||
modelMap[`${model.name}@${model.provider.name}`] = model;
|
modelMap[`${model.name}@${model?.provider?.name}`] = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
set(() => ({
|
set(() => ({
|
||||||
|
|
|
@ -118,7 +118,12 @@ export function collectModelsWithDefaultModel(
|
||||||
return allModels;
|
return allModels;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isModelAvailableInServer(customModels, modelName) {
|
export function isModelAvailableInServer(
|
||||||
|
customModels,
|
||||||
|
modelName,
|
||||||
|
providerName,
|
||||||
|
) {
|
||||||
|
const fullName = `${modelName}@${providerName}`;
|
||||||
const modelTable = collectModelTable(DEFAULT_MODELS, customModels);
|
const modelTable = collectModelTable(DEFAULT_MODELS, customModels);
|
||||||
return modelTable[modelName ?? ""].available === false;
|
return modelTable[fullName]?.available === false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue