Skip to content

Commit c5516fc

Browse files
xqliuclaude
authored andcommitted
fix: Update model validation in handleSaveModelConfig to support both configured and supported models
- Change validation to check allModels first, then supportedModels - This allows saving new model configurations without "model does not exist" error - Fixes issue where users couldn't save AI model config after selecting from dropdown Fixes #245 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 0eb05dd commit c5516fc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

web/src/components/AITradersPage.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,17 +303,17 @@ export function AITradersPage({ onTraderSelect }: AITradersPageProps) {
303303

304304
const handleSaveModelConfig = async (modelId: string, apiKey: string, customApiUrl?: string, customModelName?: string) => {
305305
try {
306-
// 找到要配置的模型(从supportedModels中)
307-
const modelToUpdate = supportedModels?.find(m => m.id === modelId);
306+
// 创建或更新用户的模型配置
307+
const existingModel = allModels?.find(m => m.id === modelId);
308+
let updatedModels;
309+
310+
// 找到要配置的模型(优先从已配置列表,其次从支持列表)
311+
const modelToUpdate = existingModel || supportedModels?.find(m => m.id === modelId);
308312
if (!modelToUpdate) {
309313
alert(t('modelNotExist', language));
310314
return;
311315
}
312316

313-
// 创建或更新用户的模型配置
314-
const existingModel = allModels?.find(m => m.id === modelId);
315-
let updatedModels;
316-
317317
if (existingModel) {
318318
// 更新现有配置
319319
updatedModels = allModels?.map(m =>

0 commit comments

Comments
 (0)