mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-10 03:56:37 +08:00
fix: close 5315
This commit is contained in:
parent
718782f5b1
commit
cdd74de666
@ -62,6 +62,26 @@ export function collectModelTable(
|
||||
};
|
||||
});
|
||||
|
||||
function parseModelName(name: string): {
|
||||
customModelName: string;
|
||||
customProviderName: string;
|
||||
} {
|
||||
let customModelName, customProviderName;
|
||||
if (name.startsWith("'") || name.startsWith('"')) {
|
||||
const match = name.match(/^(['"])(.*?)\1(@.*)?$/);
|
||||
if (match) {
|
||||
customModelName = match[2];
|
||||
customProviderName = match[3]?.slice(1) || customModelName;
|
||||
}
|
||||
} else {
|
||||
[customModelName, customProviderName] = name.split("@");
|
||||
}
|
||||
return { customModelName, customProviderName } as {
|
||||
customModelName: string;
|
||||
customProviderName: string;
|
||||
};
|
||||
}
|
||||
|
||||
// server custom models
|
||||
customModels
|
||||
.split(",")
|
||||
@ -79,7 +99,12 @@ export function collectModelTable(
|
||||
);
|
||||
} else {
|
||||
// 1. find model by name, and set available value
|
||||
const [customModelName, customProviderName] = name.split("@");
|
||||
// modelName@azure => 'modelName', 'azure'
|
||||
// 'modelName@azure' => 'modelName@azure', ''
|
||||
// modelName@azure=deploymentName => 'modelName', 'azure=deploymentName'
|
||||
// 'modelName@azure'=deploymentName => 'modelName@azure', '=deploymentName
|
||||
// 'modelName@azure'@azure=deploymentName => 'modelName@azure', 'azure=deploymentName'
|
||||
let { customModelName, customProviderName } = parseModelName(name);
|
||||
let count = 0;
|
||||
for (const fullName in modelTable) {
|
||||
const [modelName, providerName] = fullName.split("@");
|
||||
@ -102,7 +127,7 @@ export function collectModelTable(
|
||||
}
|
||||
// 2. if model not exists, create new model with available value
|
||||
if (count === 0) {
|
||||
let [customModelName, customProviderName] = name.split("@");
|
||||
let { customModelName, customProviderName } = parseModelName(name);
|
||||
const provider = customProvider(
|
||||
customProviderName || customModelName,
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user