Merge pull request #1075 from feitianbubu/fix-default-model-not-exist

fix: if default model is not exist, set the first one as default
This commit is contained in:
IcedTangerine
2025-05-26 17:21:14 +08:00
committed by GitHub

View File

@@ -64,8 +64,9 @@ const Playground = () => {
},
];
const defaultModel = 'gpt-4o-mini';
const [inputs, setInputs] = useState({
model: 'gpt-4o-mini',
model: defaultModel,
group: '',
max_tokens: 0,
temperature: 0,
@@ -108,6 +109,11 @@ const Playground = () => {
value: model,
}));
setModels(localModelOptions);
// if default model is not in the list, set the first one as default
const hasDefault = localModelOptions.some(option => option.value === defaultModel);
if (!hasDefault && localModelOptions.length > 0) {
setInputs((inputs) => ({ ...inputs, model: localModelOptions[0].value }));
}
} else {
showError(t(message));
}