Skip to content

Commit

Permalink
Merge pull request ChatGPTNextWeb#5071 from ZTH7/main
Browse files Browse the repository at this point in the history
Fix defaultModel undefined error
  • Loading branch information
lloydzhou authored Jul 25, 2024
2 parents 941a03e + c4334d4 commit f5499ff
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions app/utils/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,18 @@ export function collectModelTableWithDefaultModel(
) {
let modelTable = collectModelTable(models, customModels);
if (defaultModel && defaultModel !== "") {
modelTable[defaultModel] = {
...modelTable[defaultModel],
name: defaultModel,
available: true,
isDefault: true,
};
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) {
modelTable[key].isDefault = true;
break;
}
}
}
}
return modelTable;
}
Expand Down

0 comments on commit f5499ff

Please sign in to comment.