Skip to content

Commit

Permalink
✨ feat: 调整模型列表,将自定义模型放在前面显示
Browse files Browse the repository at this point in the history
  • Loading branch information
frostime committed Aug 3, 2024
1 parent d9e407f commit 8a4b8a8
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions app/utils/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@ export function collectModelTable(
}
> = {};

// default models
models.forEach((m) => {
// using <modelName>@<providerId> as fullName
modelTable[`${m.name}@${m?.provider?.id}`] = {
...m,
displayName: m.name, // 'provider' is copied over if it exists
};
});

// server custom models
customModels
.split(",")
Expand Down Expand Up @@ -89,6 +80,15 @@ export function collectModelTable(
}
});

// default models
models.forEach((m) => {
// using <modelName>@<providerId> as fullName
modelTable[`${m.name}@${m?.provider?.id}`] = {
...m,
displayName: m.name, // 'provider' is copied over if it exists
};
});

return modelTable;
}

Expand All @@ -99,13 +99,16 @@ export function collectModelTableWithDefaultModel(
) {
let modelTable = collectModelTable(models, customModels);
if (defaultModel && defaultModel !== "") {
if (defaultModel.includes('@')) {
if (defaultModel.includes("@")) {
if (defaultModel in modelTable) {
modelTable[defaultModel].isDefault = true;
}
} else {
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;
break;
}
Expand Down

0 comments on commit 8a4b8a8

Please sign in to comment.