fix: if default model is not exist, set the first one as default

This commit is contained in:
skynono
2025-05-19 14:28:29 +08:00
parent 0ca17d3e6d
commit 9c12e02cb5

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));
}