mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-15 16:56:56 +08:00
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: tinkle-community <tinklefund@gmail.com>
This commit is contained in:
@@ -277,17 +277,17 @@ export function AITradersPage({ onTraderSelect }: AITradersPageProps) {
|
|||||||
|
|
||||||
const handleSaveModelConfig = async (modelId: string, apiKey: string, customApiUrl?: string, customModelName?: string) => {
|
const handleSaveModelConfig = async (modelId: string, apiKey: string, customApiUrl?: string, customModelName?: string) => {
|
||||||
try {
|
try {
|
||||||
// 找到要配置的模型(从supportedModels中)
|
// 创建或更新用户的模型配置
|
||||||
const modelToUpdate = supportedModels?.find(m => m.id === modelId);
|
const existingModel = allModels?.find(m => m.id === modelId);
|
||||||
|
let updatedModels;
|
||||||
|
|
||||||
|
// 找到要配置的模型(优先从已配置列表,其次从支持列表)
|
||||||
|
const modelToUpdate = existingModel || supportedModels?.find(m => m.id === modelId);
|
||||||
if (!modelToUpdate) {
|
if (!modelToUpdate) {
|
||||||
alert(t('modelNotExist', language));
|
alert(t('modelNotExist', language));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建或更新用户的模型配置
|
|
||||||
const existingModel = allModels?.find(m => m.id === modelId);
|
|
||||||
let updatedModels;
|
|
||||||
|
|
||||||
if (existingModel) {
|
if (existingModel) {
|
||||||
// 更新现有配置
|
// 更新现有配置
|
||||||
updatedModels = allModels?.map(m =>
|
updatedModels = allModels?.map(m =>
|
||||||
|
|||||||
Reference in New Issue
Block a user