diff --git a/app/api/common.ts b/app/api/common.ts index b7e41fa2647..dbbebe7443b 100644 --- a/app/api/common.ts +++ b/app/api/common.ts @@ -124,7 +124,7 @@ export async function requestOpenai(req: NextRequest) { [ ServiceProvider.OpenAI, ServiceProvider.Azure, - jsonBody?.model as string, // support provider-unspecified model + "custom" as string, // support provider-unspecified model ], ) ) { diff --git a/app/utils/model.ts b/app/utils/model.ts index a1a38a2f81c..83bc51f0214 100644 --- a/app/utils/model.ts +++ b/app/utils/model.ts @@ -66,8 +66,8 @@ export function collectModelTable( // default models models.forEach((m) => { - // using @ as fullName - modelTable[`${m.name}@${m?.provider?.id}`] = { + // using @ as fullName + modelTable[`${m.name}@${m?.provider?.providerType}`] = { ...m, displayName: m.name, // 'provider' is copied over if it exists }; @@ -126,7 +126,7 @@ export function collectModelTable( displayName: displayName || customModelName, available, provider, // Use optional chaining - sorted: CustomSeq.next(`${customModelName}@${provider?.id}`), + sorted: CustomSeq.next(`${customModelName}@${provider?.providerType}`), }; } } diff --git a/test/model-available.test.ts b/test/model-available.test.ts index 5c9fa9977d2..c338faa86a8 100644 --- a/test/model-available.test.ts +++ b/test/model-available.test.ts @@ -53,7 +53,7 @@ describe("isModelNotavailableInServer", () => { expect(result).toBe(true); }); - // FIXME: 这个测试用例有问题,需要修复 + // FIXME: 这个测试用例有问题,需要修复 ??? // test("support passing multiple providers, model available on one of the providers will return false", () => { // const customModels = "-all,gpt-4@google"; // const modelName = "gpt-4"; @@ -69,7 +69,19 @@ describe("isModelNotavailableInServer", () => { test("test custom model without setting provider", () => { const customModels = "-all,mistral-large"; const modelName = "mistral-large"; - const providerNames = modelName; + const providerNames = "custom"; + const result = isModelNotavailableInServer( + customModels, + modelName, + providerNames, + ); + expect(result).toBe(false); + }); + + test("test custom model with non-standard provider", () => { + const customModels = "-all,deepseek-chat@DeepSeek"; + const modelName = "deepseek-chat"; + const providerNames = "custom"; const result = isModelNotavailableInServer( customModels, modelName,