-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Validate provider model, auth, and endpoint before save #943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kgp0213
wants to merge
2
commits into
ValueCell-ai:main
Choose a base branch
from
kgp0213:feat/provider-model-check
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| # Add provider model-check support | ||
|
|
||
| ## Summary | ||
|
|
||
| This PR adds a lightweight **model check** workflow to the Add/Edit Provider UI so users can verify whether a provider endpoint, API key, and model ID are actually usable **before saving**. | ||
|
|
||
| ## Why | ||
|
|
||
| Today, adding or editing a provider often requires trial-and-error: | ||
|
|
||
| - users may save an invalid model ID | ||
| - users may save a bad API key | ||
| - users may save an unreachable / misconfigured endpoint | ||
| - the actual failure is only discovered later when the provider is used | ||
|
|
||
| This change adds an explicit pre-save validation step that performs a real request and reports a clear result. | ||
|
|
||
| ## What changed | ||
|
|
||
| ### UI | ||
|
|
||
| - Added a **"检测模型" / model-check** action in both: | ||
| - Add Provider dialog | ||
| - Edit Provider panel | ||
| - Added inline feedback text for: | ||
| - success | ||
| - degraded / slow response | ||
| - model not found | ||
| - auth failure | ||
| - timeout | ||
| - unsupported protocol | ||
|
|
||
| ### Frontend | ||
|
|
||
| - Added `src/lib/provider-model-check.ts` | ||
| - Wired `ProvidersSettings.tsx` to call the new API and surface results in the UI | ||
|
|
||
| ### Backend | ||
|
|
||
| - Added `/api/provider-model-check` | ||
| - Added `electron/services/providers/provider-model-check.ts` | ||
| - The backend performs a real streaming request and treats the first returned chunk as proof that the model is usable | ||
|
|
||
| ### Supported protocol paths | ||
|
|
||
| - `openai-completions` | ||
| - `openai-responses` | ||
| - `anthropic-messages` | ||
|
|
||
| ## Validation behavior | ||
|
|
||
| The check intentionally stays lightweight: | ||
|
|
||
| - uses a tiny prompt (`Hi`) | ||
| - uses small token limits | ||
| - uses streaming mode | ||
| - considers the request successful once the first response chunk arrives | ||
|
|
||
| This makes the check fast while still proving that: | ||
|
|
||
| - the endpoint is reachable | ||
| - auth works | ||
| - the requested model exists / is accepted | ||
|
|
||
| ## Verification | ||
|
|
||
| Validated locally on a clean upstream-based working tree with only the minimal feature patch applied. | ||
|
|
||
| Commands used: | ||
|
|
||
| ```bash | ||
| pnpm run ext:bridge | ||
| pnpm exec tsc --noEmit | ||
| pnpm exec vite build | ||
| ``` | ||
|
|
||
| All passed successfully. | ||
|
|
||
| ## Screenshot | ||
|
|
||
| A local verification screenshot is included in this branch: | ||
|
|
||
| - `docs/pr/provider-model-check-test.png` | ||
|
|
||
| It shows the provider settings UI with the model-check entry point and successful validation state used during testing. | ||
|
|
||
| ## Scope / non-goals | ||
|
|
||
| This PR intentionally avoids unrelated customization: | ||
|
|
||
| - no branding changes | ||
| - no provider list policy changes | ||
| - no advanced-settings refactor | ||
| - no packaging / release pipeline changes | ||
|
|
||
| The goal is to keep this patch reviewable and upstream-friendly. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this file. (docs/pr/* change is useless)