mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-21 13:10:16 +09:00
fix custom models setting
This commit is contained in:
parent
e1cb8e36fa
commit
24ff78e1c5
@ -124,7 +124,7 @@ export async function requestOpenai(req: NextRequest) {
|
|||||||
[
|
[
|
||||||
ServiceProvider.OpenAI,
|
ServiceProvider.OpenAI,
|
||||||
ServiceProvider.Azure,
|
ServiceProvider.Azure,
|
||||||
jsonBody?.model as string, // support provider-unspecified model
|
"custom" as string, // support provider-unspecified model
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
@ -66,8 +66,8 @@ export function collectModelTable(
|
|||||||
|
|
||||||
// default models
|
// default models
|
||||||
models.forEach((m) => {
|
models.forEach((m) => {
|
||||||
// using <modelName>@<providerId> as fullName
|
// using <modelName>@<providerType> as fullName
|
||||||
modelTable[`${m.name}@${m?.provider?.id}`] = {
|
modelTable[`${m.name}@${m?.provider?.providerType}`] = {
|
||||||
...m,
|
...m,
|
||||||
displayName: m.name, // 'provider' is copied over if it exists
|
displayName: m.name, // 'provider' is copied over if it exists
|
||||||
};
|
};
|
||||||
@ -126,7 +126,7 @@ export function collectModelTable(
|
|||||||
displayName: displayName || customModelName,
|
displayName: displayName || customModelName,
|
||||||
available,
|
available,
|
||||||
provider, // Use optional chaining
|
provider, // Use optional chaining
|
||||||
sorted: CustomSeq.next(`${customModelName}@${provider?.id}`),
|
sorted: CustomSeq.next(`${customModelName}@${provider?.providerType}`),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ describe("isModelNotavailableInServer", () => {
|
|||||||
expect(result).toBe(true);
|
expect(result).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
// FIXME: 这个测试用例有问题,需要修复
|
// FIXME: 这个测试用例有问题,需要修复 ???
|
||||||
// test("support passing multiple providers, model available on one of the providers will return false", () => {
|
// test("support passing multiple providers, model available on one of the providers will return false", () => {
|
||||||
// const customModels = "-all,gpt-4@google";
|
// const customModels = "-all,gpt-4@google";
|
||||||
// const modelName = "gpt-4";
|
// const modelName = "gpt-4";
|
||||||
@ -69,7 +69,19 @@ describe("isModelNotavailableInServer", () => {
|
|||||||
test("test custom model without setting provider", () => {
|
test("test custom model without setting provider", () => {
|
||||||
const customModels = "-all,mistral-large";
|
const customModels = "-all,mistral-large";
|
||||||
const modelName = "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(
|
const result = isModelNotavailableInServer(
|
||||||
customModels,
|
customModels,
|
||||||
modelName,
|
modelName,
|
||||||
|
Loading…
Reference in New Issue
Block a user