Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/pages/Setting/Models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -1580,7 +1598,7 @@ export default function SettingModels() {
</DropdownMenuSubTrigger>
<DropdownMenuSubContent className="max-h-[440px] w-[220px] overflow-y-auto">
{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);

Expand Down Expand Up @@ -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
)
)}
</div>
Expand Down