Skip to content

fix(models): pass selected models into verify and catch constructor errors - #17132

Merged
JinHai-CN merged 20 commits into
infiniflow:mainfrom
ondery:fix/provider-verify-save-base-url
Aug 25, 2026
Merged

JinHai-CN merged 20 commits into
infiniflow:mainfrom
ondery:fix/provider-verify-save-base-url

Conversation

@ondery

@ondery ondery commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Two remaining verify-path fixes after #17158 (api_base -> base_url rename) and #17364 / #17397 (empty-catalog remote model discovery) landed on main.

The original scope of this PR also covered "Save all dropping the URL" and "Verify against an empty factory catalog". Those two sides are now fully addressed upstream, so this PR is trimmed to the parts that are not yet on main (including v0.27.0):

1. Pass selected models from the List-models picker into Verify

useVerifyProvider now accepts a modelInfoRef carrying the models selected in the List-models picker (which are not registered as form fields) and folds them into the verify payload. Without this, verify payloads for local / OpenAI-compatible providers often omit model_info, so the backend cannot verify the user's actual selection.

2. Guard Embedding/Chat model construction

Wrap EmbeddingModel[...] / ChatModel[...] construction in try/except so an init failure is recorded as a per-model FAIL (with a message) instead of aborting the whole verify_api_key call.

Review follow-up

Dropped SUCCESS-preserving failure recording per @Lynn-Inf: a later verification failure now overwrites a previous success so the latest status is always shown.

Already covered upstream (dropped from this PR)

Test plan

  • On Model Providers, add a VLLM (or OpenAI-API-Compatible) draft with a reachable base_url and API key.
  • Click List models, select one or more models in the picker.
  • Click Verify and confirm success (the selected models are now sent in model_info).
  • Click Verify without selecting models and confirm the backend still discovers models via Fix: verify remote model when model_list in argument and factory_llms is empty #17364.
  • For a model registered with multiple capability types, confirm that a later type failure overwrites an earlier SUCCESS for the same llm_name.
  • Confirm an Embedding/Chat constructor exception is reported as a per-model failure instead of crashing the verify endpoint.

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. 🧰 typescript Pull requests that update Typescript code labels Jul 20, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Provider verification now accepts base_url or api_base, includes selected model metadata, discovers models when catalogs are empty, and preserves successful per-model verification results across modality checks.

Changes

Provider verification alignment

Layer / File(s) Summary
Provider payload contracts
web/src/pages/user-setting/setting-model/instance-card/hooks.tsx, web/src/pages/user-setting/setting-model/instance-card/provider-instance-card.tsx, api/apps/restful_apis/provider_api.py
Verification and draft-save payloads include selected models and normalize URLs from base_url or api_base; REST endpoints accept either field.
Verification inputs and model discovery
api/apps/services/provider_api_service.py
Requested model types are expanded, invalid model metadata is rejected, and empty factory catalogs trigger remote model-list validation.
Per-model verification outcomes
api/apps/services/provider_api_service.py
Model initialization and modality checks record failures without overwriting an existing successful result.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant InstanceCard
  participant useVerifyProvider
  participant ProviderAPI
  participant verify_api_key
  participant ModelMeta
  participant CapabilityVerifier

  InstanceCard->>useVerifyProvider: provide selected models and URL fields
  useVerifyProvider->>ProviderAPI: submit model_info and normalized base_url
  ProviderAPI->>verify_api_key: verify credentials and model capabilities
  verify_api_key->>ModelMeta: fetch models when local catalog is empty
  ModelMeta-->>verify_api_key: return model list or failure
  verify_api_key->>CapabilityVerifier: initialize and verify capability models
  CapabilityVerifier-->>verify_api_key: return capability outcomes
  verify_api_key-->>ProviderAPI: preserve successful per-model statuses
  ProviderAPI-->>InstanceCard: return verification result
Loading

Possibly related PRs

  • infiniflow/ragflow#17364: Updates the same provider verification flow for remote model discovery and model candidate reconstruction.

Poem

A bunny packed models in a URL-lined tray,
base_url or api_base led the way.
Failures were marked, successes held tight,
Remote model lists joined the verification flight.
Hop, hop—each provider now checks just right!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description includes the required Summary section and clearly explains the purpose, changes, scope, and test plan.
Title check ✅ Passed The title clearly identifies the two main changes: passing selected models to verification and handling model-constructor errors.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@api/apps/services/provider_api_service.py`:
- Around line 664-667: Preserve successful verification results when processing
multiple capability types for the same model. In the downstream assignment
within the model verification loop, update the FAIL path to write
ModelVerifyStatusEnum.FAIL only when model_verify_result does not already
contain SUCCESS for llm["llm_name"], while leaving successful assignments
unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9a7b68da-4111-4574-9d85-57b173fe1618

📥 Commits

Reviewing files that changed from the base of the PR and between 3670b04 and f07f396.

📒 Files selected for processing (7)
  • api/apps/restful_apis/provider_api.py
  • api/apps/services/provider_api_service.py
  • web/src/pages/user-setting/setting-model/instance-card/hooks.tsx
  • web/src/pages/user-setting/setting-model/instance-card/provider-instance-card.tsx
  • web/src/pages/user-setting/setting-model/provider-schema/field-config/generic-api-key-config.ts
  • web/src/pages/user-setting/setting-model/provider-schema/field-config/local-llm-configs.ts
  • web/src/pages/user-setting/setting-model/provider-schema/field-config/provider-config-map.ts

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jul 20, 2026
@ondery

ondery commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Note after #17158

#17158 already landed the frontend api_base → base_url rename, which covers the Save all dropping the URL side of this PR.

What remains here is the Verify path for local / OpenAI-compatible providers (e.g. VLLM):

  • Accept api_base as a backend alias for base_url (backward compatibility for older clients)
  • When Verify runs against an empty factory catalog without model_info, fall back to the same List-models connectivity check instead of falsely reporting an invalid API key
  • Pass selected models from the instance-card List-models picker into Verify
  • Preserve a prior SUCCESS when a later capability type for the same model fails

Happy to retitle / trim the description to focus on Verify if that helps review.

@coderabbitai coderabbitai Bot mentioned this pull request Jul 27, 2026
…er type fail

Two remaining verify-path fixes after infiniflow#17158 (api_base -> base_url rename)
and infiniflow#17364/infiniflow#17397 (empty-catalog remote model discovery) landed on main:

- useVerifyProvider now accepts a modelInfoRef carrying the models selected
  in the List-models picker (not registered as form fields) and folds them
  into the verify payload, so local/compatible providers no longer verify
  against an empty model_info.
- _record_model_verify_failure records FAIL without overwriting a prior
  SUCCESS for the same llm_name. model_info is unrolled into one
  factory_llms entry per capability type, so a later type failure must not
  erase an earlier successful capability result.
- Wrap Embedding/Chat model construction in try/except so an init failure
  is recorded as a per-model FAIL instead of aborting the whole verify.

Co-authored-by: Cursor <[email protected]>
@ondery
ondery force-pushed the fix/provider-verify-save-base-url branch from eec7389 to 48e9247 Compare July 28, 2026 08:40
@ondery ondery changed the title fix(models): accept api_base and verify local providers without catalog fix(models): pass selected models into verify and keep SUCCESS on later type fail Jul 28, 2026
@JinHai-CN
JinHai-CN requested a review from Lynn-Inf August 18, 2026 04:47
@Lynn-Inf
Lynn-Inf requested a review from dcc123456 August 18, 2026 05:48

@Lynn-Inf Lynn-Inf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a later verification failure should be able to overwrite a previous success — since API key balance or model availability may change over time, the latest status should always be reflected to the user.

As for the frontend changes, I'll ask my colleague @dcc123456 to take over the review on that side.

ondery and others added 4 commits August 19, 2026 16:07
Address Lynn-Inf's review: the latest verification status should always
be shown. Keep constructor try/except and passing List-models selection
into Verify.

Co-authored-by: Cursor <[email protected]>
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Aug 22, 2026
@ondery ondery changed the title fix(models): pass selected models into verify and keep SUCCESS on later type fail fix(models): pass selected models into verify and catch constructor errors Aug 22, 2026
@ondery

ondery commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @Lynn-Inf — agreed. The SUCCESS-preservation was meant to avoid a later capability-type failure in the same verify call (unrolled model_info) flipping an earlier type's SUCCESS, but reflecting the latest status is the right product behavior.

Dropped _record_model_verify_failure. FAIL now overwrites as before.

Still in this PR (not in v0.27.0 / main):

  1. Frontend: pass List-models picker selection into Verify via modelInfoRef (already approved by @dcc123456)
  2. Guard Embedding/Chat construction so an init exception is a per-model FAIL instead of aborting the whole verify_api_key

@Lynn-Inf Lynn-Inf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JinHai-CN JinHai-CN added the ci Continue Integration label Aug 25, 2026
@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.65%. Comparing base (7cb4e30) to head (bd2f67a).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17132      +/-   ##
==========================================
- Coverage   94.56%   90.65%   -3.91%     
==========================================
  Files          10       10              
  Lines         717      717              
  Branches      118      118              
==========================================
- Hits          678      650      -28     
- Misses         25       39      +14     
- Partials       14       28      +14     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JinHai-CN
JinHai-CN merged commit 65d8301 into infiniflow:main Aug 25, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:M This PR changes 30-99 lines, ignoring generated files. 🧰 typescript Pull requests that update Typescript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants