Skip to content

Fix: model selection format compat and provider api_key wrapping - #17112

Merged
wangq8 merged 2 commits into
infiniflow:mainfrom
dcc123456:fix/model-provider-error-0720
Jul 20, 2026
Merged

wangq8 merged 2 commits into
infiniflow:mainfrom
dcc123456:fix/model-provider-error-0720

Conversation

@dcc123456

Copy link
Copy Markdown
Collaborator

Summary

Fix: model selection format compat and provider api_key wrapping

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 20, 2026
@dcc123456
dcc123456 requested a review from wangq8 July 20, 2026 09:21
@dosubot dosubot Bot added 🐞 bug Something isn't working, pull request that fix bug. 🧰 typescript Pull requests that update Typescript code labels Jul 20, 2026
@dcc123456 dcc123456 added ci Continue Integration bug labels Jul 20, 2026
@dcc123456
dcc123456 marked this pull request as draft July 20, 2026 09:21
@dcc123456
dcc123456 marked this pull request as ready for review July 20, 2026 09:21
@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Model selection now supports composed identity values when IDs are unavailable, and default-model requests accept either IDs or provider-specific fields. Provider configuration transforms also nest auxiliary metadata inside api_key.

Changes

Model configuration flow

Layer / File(s) Summary
Model selection and default persistence
web/src/interfaces/request/llm.ts, web/src/components/model-tree-select.tsx, web/src/hooks/use-llm-request.tsx, web/src/pages/user-setting/setting-model/layout/system-setting.tsx
Model values can use model_id or parsed provider, instance, and name fields across tree selection, dictionary construction, and default-model persistence.
Provider payload encoding
web/src/pages/user-setting/setting-model/provider-schema/field-config/*
Generic API key, local LLM, and Azure OpenAI submissions conditionally nest auxiliary metadata inside api_key.
Estimated code review effort: 3 (Moderate) ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SystemSetting
  participant parseModelValue
  participant setDefaultModel
  SystemSetting->>parseModelValue: parse selected model value
  parseModelValue-->>SystemSetting: parsed identity or fallback
  SystemSetting->>setDefaultModel: persist model type and identity
Loading

Possibly related PRs

Suggested reviewers: euvre

Poem

I’m a rabbit with models to choose,
With IDs or names, no values to lose.
Keys tuck metadata neatly inside,
Defaults parse softly and settle with pride.
Hop, hop—the settings now flow!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description has a Summary section but is too terse and lacks the required background context. Expand the Summary with the problem being solved, the reason for the change, and any relevant behavior or compatibility context.
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly reflects the main changes: model selection format compatibility and provider api_key wrapping.

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
`@web/src/pages/user-setting/setting-model/provider-schema/field-config/generic-api-key-config.ts`:
- Around line 80-89: Update the submitTransform function to include
values.model_info in its returned payload, preserving the model_info data
supplied by the parent hook while keeping the existing instance_name, api_key,
and api_base transformations 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: c4988839-1267-4ad3-ba34-750bfa2be512

📥 Commits

Reviewing files that changed from the base of the PR and between 0e3a579 and 0cfdf39.

📒 Files selected for processing (7)
  • web/src/components/model-tree-select.tsx
  • web/src/hooks/use-llm-request.tsx
  • web/src/interfaces/request/llm.ts
  • web/src/pages/user-setting/setting-model/layout/system-setting.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

Comment on lines +80 to +89
submitTransform: (values) => {
const apiKey = values.group_id
? { api_key: values.api_key ?? '', group_id: values.group_id }
: (values.api_key ?? '');
return {
instance_name: values.instance_name,
api_key: apiKey,
api_base: values.base_url || '',
};
},

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Include model_info in the submitted payload to satisfy the API contract.

The new submitTransform object drops the model_info field. Because the parent hook invokes this transform by spreading model_info into values (i.e. submitTransform({ ...values, model_info: modelInfoList })), omitting it here strips it from the final payload sent to the backend. This violates the IAddLlmRequestBody interface.

Please pass model_info through, just as it is explicitly handled in the other provider configurations.

🐛 Proposed fix
  submitTransform: (values) => {
    const apiKey = values.group_id
      ? { api_key: values.api_key ?? '', group_id: values.group_id }
      : (values.api_key ?? '');
    return {
      instance_name: values.instance_name,
      api_key: apiKey,
      api_base: values.base_url || '',
+     model_info: values.model_info || [],
    };
  },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
submitTransform: (values) => {
const apiKey = values.group_id
? { api_key: values.api_key ?? '', group_id: values.group_id }
: (values.api_key ?? '');
return {
instance_name: values.instance_name,
api_key: apiKey,
api_base: values.base_url || '',
};
},
submitTransform: (values) => {
const apiKey = values.group_id
? { api_key: values.api_key ?? '', group_id: values.group_id }
: (values.api_key ?? '');
return {
instance_name: values.instance_name,
api_key: apiKey,
api_base: values.base_url || '',
model_info: values.model_info || [],
};
},
🤖 Prompt for 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.

In
`@web/src/pages/user-setting/setting-model/provider-schema/field-config/generic-api-key-config.ts`
around lines 80 - 89, Update the submitTransform function to include
values.model_info in its returned payload, preserving the model_info data
supplied by the parent hook while keeping the existing instance_name, api_key,
and api_base transformations unchanged.

@wangq8 wangq8 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review: PR #17112

Title: Fix: model selection format compat and provider api_key wrapping
Author: @dcc123456
Files: 7 files, +76/-34

Overview

This PR addresses two issues: (1) models missing a model_id field now fall back to a composite identifier built from model_name/instance_name/provider_name, and (2) provider API key submission now supports passing extra metadata (e.g., group_id, provider_order, api_version) by wrapping api_key as an object when these extras are present.

✅ What works well

  • The model_id fallback in model-tree-select.tsx and use-llm-request.tsx is clean and backward-compatible — when model_id exists, behavior is unchanged.
  • The union type ISetDefaultModelRequestBody is well-typed and preserves the legacy interface.
  • The api_key wrapping is non-breaking when no extra fields are present (falls back to a plain string).

⚠️ Concerns

1. Backend compatibility of api_key wrapping (medium risk)
The most significant change is structural: fields like group_id, api_version, and provider_order were previously sent as top-level request body keys. Now they are nested inside the api_key object. This means:

  • generic-api-key-config.ts: group_id and max_tokens: 0 removed from top-level, group_id embedded in api_key object.
  • local-llm-configs.ts: provider_order removed from top-level, embedded in api_key object.
  • provider-config-map.ts (Azure): api_version removed from top-level, embedded in api_key object.

👉 This will silently break if the backend endpoint parses these fields from the top-level request body. Please verify that the backend handlers (PUT /api/v1/llm/{factory}/instance and related) have been updated (or already accept) this nested format.

2. Type safety of the union request body (low risk)
In system-setting.tsx, parseModelValue(value) returns { model_name, model_instance, model_provider } | null. If the returned object contains unexpected extra keys or the backend expects a strictly exact shape, the request may silently fail. Consider adding an explicit assertion or interface validation.

3. No tests (minor)
No test files are included. Given the non-trivial transformations in the submitTransform functions, at least a basic unit test on the api_key wrapping logic would improve confidence.

4. max_tokens: 0 removal (nit)
The generic-api-key-config.ts previously sent max_tokens: 0 as a top-level field. It has been removed entirely. If this was intentional cleanup, please confirm — if the backend defaults it, no issue.

Summary

The overall direction is good — both fixes are sensible improvements. The main concern is backend alignment for the api_key wrapping. As long as the receiving endpoints handle the nested format, this should be ready to merge after verification.

@wangq8
wangq8 merged commit b3f731d into infiniflow:main Jul 20, 2026
3 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. bug ci Continue Integration size:L This PR changes 100-499 lines, ignoring generated files. 🧰 typescript Pull requests that update Typescript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants