Validate provider model, auth, and endpoint before save#943
Conversation
|
A few implementation notes that may help review:
If you prefer different UI wording or button placement, I can adjust that separately while keeping the validation behavior minimal. |
|
One final clarification on intent: This PR is meant to reduce setup-time friction, not to introduce a heavyweight provider health-check system. The benefit is mainly that users can catch the three most common configuration problems earlier:
That is why the implementation stays intentionally narrow, cheap, and opt-in. |
| @@ -0,0 +1,96 @@ | |||
| # Add provider model-check support | |||
There was a problem hiding this comment.
Remove this file. (docs/pr/* change is useless)
hazeone
left a comment
There was a problem hiding this comment.
Please fix the issue and submit again
| if (!result) return ''; | ||
| const suffix = result.responseTimeMs ? ` · ${result.responseTimeMs} ms` : ''; | ||
| if (result.success && result.status === 'operational') return `检测成功${suffix}`; | ||
| if (result.success && result.status === 'degraded') return `模型可用,但响应较慢${suffix}`; |
There was a problem hiding this comment.
Change test language to English version
| <div className="flex items-center justify-between gap-3"> | ||
| <div> | ||
| <p className={currentSectionLabelClasses}>模型检测</p> | ||
| <p className="text-[12px] text-muted-foreground">用当前配置发起一次真实流式请求,只要首包返回即判定通过。</p> |
| <div className="rounded-xl border border-black/10 dark:border-white/10 p-4 bg-white/60 dark:bg-white/[0.03] space-y-2"> | ||
| <div className="flex items-center justify-between gap-3"> | ||
| <div> | ||
| <p className={labelClasses}>模型检测</p> |
There was a problem hiding this comment.
You can set this function by i18n component
Validate provider model, auth, and endpoint before save
Summary
This PR adds a lightweight pre-save model check to both the Add Provider and Edit Provider flows.
Before saving a provider, users can run a small real request to verify that:
The goal is to reduce trial and error during provider setup and surface configuration mistakes earlier.
Problem
Right now, provider setup failures are often discovered only later, when the provider is actually used.
Common cases include:
From a user perspective, these all look like: save succeeded, but usage failed later.
That creates avoidable setup friction, especially for:
Why this belongs in the settings flow
This check is intentionally placed in Add/Edit Provider, not in a later runtime-only path, because the UX problem happens at configuration time.
Providing feedback before save helps users fix the exact field they are editing, instead of discovering the problem only after the provider is already stored and selected.
What this PR adds
UI
Adds a model check action to:
Also adds inline result feedback for:
Backend
Adds a dedicated endpoint:
/api/provider-model-checkAnd a small service that performs a real validation request for supported protocols.
Frontend
Adds a small client wrapper and wires the result into
ProvidersSettings.tsx.Design choices
This implementation is intentionally lightweight.
The check:
Hi)This keeps the request cheap while still validating the most important setup conditions.
Why first-chunk success is sufficient here
This is not intended to be a full semantic correctness test or a long health check.
It is a configuration validation step.
If the request reaches the provider, authenticates successfully, and the requested model starts returning streamed output, then the setup is already validated well enough for this UI purpose.
That gives fast feedback without turning the check into a heavier probe.
Supported protocols in this PR
This PR currently supports:
openai-completionsopenai-responsesanthropic-messagesThat scope is intentional:
Scope and non-goals
This PR intentionally does not include unrelated changes:
The goal is to keep the patch small, reviewable, and upstream-friendly.
Verification
Validated locally on an upstream-based working tree with only the minimal feature patch applied.
Commands used:
All passed successfully.
Screenshot
Tested UI screenshot from the validation build:
This screenshot is included in the branch at:
docs/pr/provider-model-check-test.pngFiles added or touched
electron/api/routes/providers.tselectron/services/providers/provider-model-check.tssrc/components/settings/ProvidersSettings.tsxsrc/lib/provider-model-check.tsWhy I think this is merge-worthy
This change addresses a real setup pain point with a relatively small surface area:
If maintainers prefer different UI wording or button placement, I am happy to adjust that while keeping the validation behavior minimal.