mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-09 19:46:37 +08:00
CUSTOM_MODELS - support wildcard and entire providerName https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/issues/5050
for CUSTOM_MODELS if start with "-", it supports -@providerName and -modelname support wildcard (*), eg: CUSTOM_MODELS=-ernie-*,-doubao-*,-@azure
This commit is contained in:
parent
f6a6c51d15
commit
a938587b75
@ -52,11 +52,28 @@ export function collectModelTable(
|
|||||||
let count = 0;
|
let count = 0;
|
||||||
for (const fullName in modelTable) {
|
for (const fullName in modelTable) {
|
||||||
const [modelName, providerName] = fullName.split("@");
|
const [modelName, providerName] = fullName.split("@");
|
||||||
|
|
||||||
|
let match = false;
|
||||||
if (
|
if (
|
||||||
customModelName == modelName &&
|
customModelName == modelName &&
|
||||||
(customProviderName === undefined ||
|
(customProviderName === undefined ||
|
||||||
customProviderName === providerName)
|
customProviderName === providerName)
|
||||||
) {
|
) match = true; //orginal full name match
|
||||||
|
|
||||||
|
if (!match && m.startsWith("-")) {
|
||||||
|
// if not match and it's '-'
|
||||||
|
if (nameConfig.startsWith("@")) {
|
||||||
|
if (nameConfig === "@" + providerName) match = true;
|
||||||
|
} else {
|
||||||
|
if (customModelName.includes("*")) {
|
||||||
|
const regexPattern = customModelName.replace(/\*/g, ".*");
|
||||||
|
const regex = new RegExp("^" + regexPattern + "$", "i");
|
||||||
|
if (regex.test(modelName)) match = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match) {
|
||||||
count += 1;
|
count += 1;
|
||||||
modelTable[fullName]["available"] = available;
|
modelTable[fullName]["available"] = available;
|
||||||
// swap name and displayName for bytedance
|
// swap name and displayName for bytedance
|
||||||
@ -99,13 +116,16 @@ export function collectModelTableWithDefaultModel(
|
|||||||
) {
|
) {
|
||||||
let modelTable = collectModelTable(models, customModels);
|
let modelTable = collectModelTable(models, customModels);
|
||||||
if (defaultModel && defaultModel !== "") {
|
if (defaultModel && defaultModel !== "") {
|
||||||
if (defaultModel.includes('@')) {
|
if (defaultModel.includes("@")) {
|
||||||
if (defaultModel in modelTable) {
|
if (defaultModel in modelTable) {
|
||||||
modelTable[defaultModel].isDefault = true;
|
modelTable[defaultModel].isDefault = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (const key of Object.keys(modelTable)) {
|
for (const key of Object.keys(modelTable)) {
|
||||||
if (modelTable[key].available && key.split('@').shift() == defaultModel) {
|
if (
|
||||||
|
modelTable[key].available &&
|
||||||
|
key.split("@").shift() == defaultModel
|
||||||
|
) {
|
||||||
modelTable[key].isDefault = true;
|
modelTable[key].isDefault = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user