mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-02-11 17:40:35 +08:00
using <modelName>@<providerName> as fullName in modelTable
This commit is contained in:
parent
14f2a8f370
commit
b9ffd50992
@ -24,7 +24,8 @@ export function collectModelTable(
|
|||||||
|
|
||||||
// default models
|
// default models
|
||||||
models.forEach((m) => {
|
models.forEach((m) => {
|
||||||
modelTable[m.name] = {
|
// using <modelName>@<providerName> as fullName
|
||||||
|
modelTable[`${m.name}@${m?.provider?.name}`] = {
|
||||||
...m,
|
...m,
|
||||||
displayName: m.name, // 'provider' is copied over if it exists
|
displayName: m.name, // 'provider' is copied over if it exists
|
||||||
};
|
};
|
||||||
@ -46,12 +47,27 @@ export function collectModelTable(
|
|||||||
(model) => (model.available = available),
|
(model) => (model.available = available),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
modelTable[name] = {
|
// 1. find model by name(), and set available value
|
||||||
name,
|
let count = 0;
|
||||||
displayName: displayName || name,
|
for (const fullName in modelTable) {
|
||||||
available,
|
if (fullName.includes(name)) {
|
||||||
provider: modelTable[name]?.provider ?? customProvider(name), // Use optional chaining
|
count += 1;
|
||||||
};
|
modelTable[fullName]["available"] = available;
|
||||||
|
if (displayName) {
|
||||||
|
modelTable[fullName]["displayName"] = displayName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 2. if model not exists, create new model with available value
|
||||||
|
if (count === 0) {
|
||||||
|
const provider = customProvider(name);
|
||||||
|
modelTable[`${name}@${provider.name}`] = {
|
||||||
|
name,
|
||||||
|
displayName: displayName || name,
|
||||||
|
available,
|
||||||
|
provider, // Use optional chaining
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user