diff --git a/src/pages/Setting/Models.tsx b/src/pages/Setting/Models.tsx index 07bf78982..23d213a3a 100644 --- a/src/pages/Setting/Models.tsx +++ b/src/pages/Setting/Models.tsx @@ -471,6 +471,12 @@ export default function SettingModels() { ), closeButton: true, }); + // Update is_valid to true when validation succeeds + setForm((prev) => { + const next = [...prev]; + next[idx] = { ...next[idx], is_valid: true }; + return next; + }); } else { console.log('failed', res.message); // Surface error inline on API Key input @@ -480,6 +486,12 @@ export default function SettingModels() { next[idx].apiKey = getValidateMessage(res); return next; }); + // Update is_valid to false when validation fails + setForm((prev) => { + const next = [...prev]; + next[idx] = { ...next[idx], is_valid: false }; + return next; + }); return; } console.log(res); @@ -492,6 +504,12 @@ export default function SettingModels() { next[idx].apiKey = getValidateMessage(e); return next; }); + // Update is_valid to false when validation fails + setForm((prev) => { + const next = [...prev]; + next[idx] = { ...next[idx], is_valid: false }; + return next; + }); return; } finally { setLoading(null); @@ -1580,7 +1598,7 @@ export default function SettingModels() { {items.map((item, idx) => { - const isConfigured = !!form[idx]?.provider_id; + const isConfigured = !!form[idx]?.provider_id && form[idx]?.is_valid !== false; const isPreferred = form[idx]?.prefer; const modelImage = getModelImage(item.id); @@ -1738,7 +1756,7 @@ export default function SettingModels() { item.id, selectedTab === `byok-${item.id}`, true, - !!form[idx].provider_id + !!form[idx].provider_id && form[idx].is_valid !== false ) )}