Skip to content

Fix: add model_type into llm_setting - #15141

Merged
wangq8 merged 6 commits into
infiniflow:mainfrom
Lynn-Inf:fix/validate-model
May 22, 2026
Merged

wangq8 merged 6 commits into
infiniflow:mainfrom
Lynn-Inf:fix/validate-model

Conversation

@Lynn-Inf

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Add model_type into llm_setting

Type of change

  • Bug Fix (non-breaking change which fixes an issue)

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label May 22, 2026
@Lynn-Inf
Lynn-Inf requested a review from cike8899 May 22, 2026 03:32
@coderabbitai

coderabbitai Bot commented May 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 46bef2e8-80c6-4bf0-b5d4-34808eedfdca

📥 Commits

Reviewing files that changed from the base of the PR and between 74fb671 and 184d318.

📒 Files selected for processing (3)
  • web/src/pages/next-chats/chat/app-settings/chat-settings.tsx
  • web/src/pages/next-chats/chat/chat-box/next-multiple-chat-box.tsx
  • web/src/pages/next-chats/hooks/use-rename-chat.ts

📝 Walkthrough

Walkthrough

Three chat UI components—ChatSettings, ChatCard, and useRenameChat—now use useFindLlmByUuid to resolve LLM model types and populate llm_setting.model_type during form submission, configuration updates, and modal initialization, with a fallback to 'chat' when resolution fails.

Changes

LLM Model Type Resolution Across Chat UI Flows

Layer / File(s) Summary
ChatSettings Model Type Resolution
web/src/pages/next-chats/chat/app-settings/chat-settings.tsx
ChatSettings imports and initializes useFindLlmByUuid, then augments llm_setting.model_type during form submission by looking up the selected llm_id and defaulting to 'chat' on miss.
ChatCard Model Configuration with LLM Type
web/src/pages/next-chats/chat/chat-box/next-multiple-chat-box.tsx
ChatCard imports and initializes useFindLlmByUuid, then updates the "apply config" handler to derive llm_id from form values, place it at top-level params, and compute llm_setting.model_type from the resolved LLM with 'chat' fallback.
RenameChat Modal Initial Data with LLM Type
web/src/pages/next-chats/hooks/use-rename-chat.ts
useRenameChat imports and initializes useFindLlmByUuid, then populates the rename modal's InitialData with llm_setting.model_type derived from the tenant's llm_id, adding findLlmByUuid to memoization dependencies.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • infiniflow/ragflow#14331: Addresses related LLM model resolution by updating backend lookup logic to allow IMAGE2TEXT models to resolve as CHAT when used with chat services.

Suggested labels

🐞 bug, size:S

Suggested reviewers

  • wangq8
  • Magicbook1108

🐰 Three components did unite,
With hooks to find the LLM light,
Model types now resolved with care,
Defaults to chat, everywhere!
The UI flows are set just right. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix: add model_type into llm_setting' clearly and concisely summarizes the main change across all modified files, which is adding model_type to llm_setting objects.
Description check ✅ Passed The pull request description includes the required section 'What problem does this PR solve?' and correctly identifies the type of change as a Bug Fix, matching the template structure.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@Lynn-Inf
Lynn-Inf marked this pull request as draft May 22, 2026 03:32
@Lynn-Inf
Lynn-Inf marked this pull request as ready for review May 22, 2026 03:32

@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: 2

🤖 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/next-chats/chat/app-settings/chat-settings.tsx`:
- Line 35: The llmList returned by useFetchLlmList() starts as {} which causes
getModelTypeByLlmId(llmId, llmList) to treat it as "ready" and default to
'chat'; update chat-settings.tsx to guard model_type derivation until the list
is truly populated by checking llmList is non-empty (e.g.,
Object.keys(llmList).length > 0) or until the query reports loaded, and either
(A) disable the submit path (or the submit button) until llmList is loaded, or
(B) pass null/omit the llmList to getModelTypeByLlmId so it falls back to
getCachedLlmList() instead; reference useFetchLlmList, llmList,
getModelTypeByLlmId, getCachedLlmList, and the submit handler/model_type
assignment in chat-settings.tsx when making the change.

In `@web/src/utils/llm-util.ts`:
- Around line 87-104: Extract the duplicated model-type normalization logic into
a single helper (e.g., normalizeModelType or getNormalizedModelType) and replace
the two identical blocks that compute
modelType->types->'chat'/'image2text'/fallback with calls to that helper; the
helper should accept the raw modelType (the value of model?.model_type ||
model?.type) and return the normalized string, then call it from both places
where the current logic exists (the branch handling object format and the branch
handling Array.isArray(data) with the model lookup using m.llm_name and m.fid).
🪄 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: 9cd2d51e-2554-4a52-ae1a-fff194a50294

📥 Commits

Reviewing files that changed from the base of the PR and between 57ddd79 and 74fb671.

📒 Files selected for processing (4)
  • web/src/pages/next-chats/chat/app-settings/chat-settings.tsx
  • web/src/pages/next-chats/chat/chat-box/next-multiple-chat-box.tsx
  • web/src/pages/next-chats/hooks/use-rename-chat.ts
  • web/src/utils/llm-util.ts

Comment thread web/src/utils/llm-util.ts Resolved
@Lynn-Inf Lynn-Inf added the ci Continue Integration label May 22, 2026
@codecov

codecov Bot commented May 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.12%. Comparing base (a9ec78c) to head (3ef114e).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15141   +/-   ##
=======================================
  Coverage   93.12%   93.12%           
=======================================
  Files          10       10           
  Lines         713      713           
  Branches      116      116           
=======================================
  Hits          664      664           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Sentry.
📢 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.

Comment thread web/src/utils/llm-util.ts Resolved
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels May 22, 2026
@wangq8
wangq8 merged commit 893980e into infiniflow:main May 22, 2026
1 check failed
@dosubot dosubot Bot mentioned this pull request May 29, 2026
4 tasks done
vincentlambert added a commit to Eurelis/Eurelis-RAGFlow-Fork that referenced this pull request Jun 4, 2026
model_type is a RAGFlow-internal field stored in llm_setting (injected by
the frontend since infiniflow#15141). It leaks into gen_conf which is passed verbatim
to litellm, causing a 400 Bad Request from providers that reject unknown
fields (e.g. Bedrock: "extraneous key [model_type] is not permitted").

Base._clean_conf already handles this implicitly via its allowlist filter.
LiteLLMBase._clean_conf uses a denylist approach and was missing this key.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
vincentlambert added a commit to Eurelis/Eurelis-RAGFlow-Fork that referenced this pull request Jun 4, 2026
model_type is a RAGFlow-internal field stored in llm_setting (injected by
the frontend since infiniflow#15141). It leaks into gen_conf which is passed verbatim
to litellm, causing a 400 Bad Request from providers that reject unknown
fields (e.g. Bedrock: "extraneous key [model_type] is not permitted").

Base._clean_conf already handles this implicitly via its allowlist filter.
LiteLLMBase._clean_conf uses a denylist approach and was missing this key.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
vincentlambert added a commit to Eurelis/Eurelis-RAGFlow-Fork that referenced this pull request Jun 9, 2026
model_type is a RAGFlow-internal field stored in llm_setting (injected by
the frontend since infiniflow#15141). It leaks into gen_conf which is passed verbatim
to litellm, causing a 400 Bad Request from providers that reject unknown
fields (e.g. Bedrock: "extraneous key [model_type] is not permitted").

Base._clean_conf already handles this implicitly via its allowlist filter.
LiteLLMBase._clean_conf uses a denylist approach and was missing this key.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
vincentlambert added a commit to Eurelis/Eurelis-RAGFlow-Fork that referenced this pull request Jun 9, 2026
model_type is a RAGFlow-internal field stored in llm_setting (injected by
the frontend since infiniflow#15141). It leaks into gen_conf which is passed verbatim
to litellm, causing a 400 Bad Request from providers that reject unknown
fields (e.g. Bedrock: "extraneous key [model_type] is not permitted").

Base._clean_conf already handles this implicitly via its allowlist filter.
LiteLLMBase._clean_conf uses a denylist approach and was missing this key.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants