hotfix: using custom models, create custom provider

This commit is contained in:
lloydzhou 2024-07-12 20:19:36 +08:00
parent 728c38396a
commit 9203870df5
1 changed files with 10 additions and 7 deletions

View File

@ -1,9 +1,9 @@
import { DEFAULT_MODELS } from "../constant"; import { DEFAULT_MODELS } from "../constant";
import { LLMModel } from "../client/api"; import { LLMModel } from "../client/api";
const customProvider = (modelName: string) => ({ const customProvider = (providerName: string) => ({
id: modelName, id: providerName.toLowerCase(),
providerName: "Custom", providerName: providerName,
providerType: "custom", providerType: "custom",
}); });
@ -71,10 +71,13 @@ export function collectModelTable(
} }
// 2. if model not exists, create new model with available value // 2. if model not exists, create new model with available value
if (count === 0) { if (count === 0) {
const provider = customProvider(name); const [customModelName, customProviderName] = name.split("@");
modelTable[`${name}@${provider?.id}`] = { const provider = customProvider(
name, customProviderName || customModelName,
displayName: displayName || name, );
modelTable[`${customModelName}@${provider?.id}`] = {
name: customModelName,
displayName: displayName || customModelName,
available, available,
provider, // Use optional chaining provider, // Use optional chaining
}; };