Skip to content

Fix: different llm in chat - #14162

Merged
JinHai-CN merged 1 commit into
infiniflow:mainfrom
Magicbook1108:llm
Apr 16, 2026
Merged

JinHai-CN merged 1 commit into
infiniflow:mainfrom
Magicbook1108:llm

Conversation

@Magicbook1108

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Fix: different llm in chat

Type of change

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

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Apr 16, 2026
@Magicbook1108 Magicbook1108 added ci Continue Integration and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Apr 16, 2026
@Magicbook1108
Magicbook1108 marked this pull request as draft April 16, 2026 11:24
@Magicbook1108
Magicbook1108 marked this pull request as ready for review April 16, 2026 11:24
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Apr 16, 2026
@coderabbitai

coderabbitai Bot commented Apr 16, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Two functions in the dialog service were updated to change the model configuration resolution precedence: dialog.llm_id is now checked first, followed by dialog.tenant_llm_id, then tenant defaults. Previously, tenant_llm_id was unconditionally queried before other options.

Changes

Cohort / File(s) Summary
Model Configuration Resolution
api/db/services/dialog_service.py
Modified async_chat_solo() and get_models() to prioritize dialog.llm_id over dialog.tenant_llm_id when resolving chat model configurations, with fallback to tenant default models. Removed unconditional tenant_llm_id lookup.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A model's path now starts anew,
From dialog's own choice, tried and true,
Then tenant defaults come to play,
Precedence leads the chatty way! 🎯

🚥 Pre-merge checks | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete; it repeats the title in the 'What problem does this PR solve?' section instead of providing actual context, background, or explanation of the issue. Replace the repeated title with a clear explanation of the bug, why it occurs, and how the fix resolves it. Provide context to help reviewers understand the impact.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Fix: different llm in chat' is vague and generic, using non-descriptive phrasing that doesn't convey the specific technical change being made. Revise the title to be more specific, e.g., 'Fix: prioritize dialog llm_id over tenant_llm_id in chat model resolution' to clearly describe what the fix addresses.

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


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

@dosubot dosubot Bot added the 🐞 bug Something isn't working, pull request that fix bug. label Apr 16, 2026

@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.

🧹 Nitpick comments (1)
api/db/services/dialog_service.py (1)

244-251: Model resolution logic looks correct.

The precedence change appropriately prioritizes dialog.llm_id over dialog.tenant_llm_id, which aligns with the bug fix intent. The truthiness checks handle empty strings and None values correctly.

Consider adding debug logging to trace which resolution path was taken, as this would help with troubleshooting model selection issues in production. As per coding guidelines: "Add logging for new flows."

🔧 Optional: Add debug logging
     if dialog.llm_id:
         model_config = get_model_config_by_type_and_name(dialog.tenant_id, LLMType.CHAT, dialog.llm_id)
+        logging.debug("async_chat_solo: resolved model via llm_id=%s", dialog.llm_id)
     elif dialog.tenant_llm_id:
         model_config = get_model_config_by_id(dialog.tenant_llm_id)
+        logging.debug("async_chat_solo: resolved model via tenant_llm_id=%s", dialog.tenant_llm_id)
     else:
         model_config = get_tenant_default_model_by_type(dialog.tenant_id, LLMType.CHAT)
+        logging.debug("async_chat_solo: resolved model via tenant default for tenant_id=%s", dialog.tenant_id)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@api/db/services/dialog_service.py` around lines 244 - 251, Add debug logging
to trace which model resolution path is taken: when dialog.llm_id is used call
out that get_model_config_by_type_and_name was selected for dialog.llm_id, when
dialog.tenant_llm_id is used log that get_model_config_by_id was selected for
dialog.tenant_llm_id, and when falling back log that
get_tenant_default_model_by_type was selected; include the dialog.tenant_id and
the resolved model identifier (or None) in the log messages to aid
troubleshooting, and place these logs immediately around the existing resolution
logic that calls get_model_config_by_type_and_name, get_model_config_by_id, and
get_tenant_default_model_by_type.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@api/db/services/dialog_service.py`:
- Around line 244-251: Add debug logging to trace which model resolution path is
taken: when dialog.llm_id is used call out that
get_model_config_by_type_and_name was selected for dialog.llm_id, when
dialog.tenant_llm_id is used log that get_model_config_by_id was selected for
dialog.tenant_llm_id, and when falling back log that
get_tenant_default_model_by_type was selected; include the dialog.tenant_id and
the resolved model identifier (or None) in the log messages to aid
troubleshooting, and place these logs immediately around the existing resolution
logic that calls get_model_config_by_type_and_name, get_model_config_by_id, and
get_tenant_default_model_by_type.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 910dc1f5-90df-4ef7-b482-a4bb06b4d038

📥 Commits

Reviewing files that changed from the base of the PR and between 655dd2f and d744318.

📒 Files selected for processing (1)
  • api/db/services/dialog_service.py

@codecov

codecov Bot commented Apr 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.66%. Comparing base (655dd2f) to head (d744318).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #14162   +/-   ##
=======================================
  Coverage   96.66%   96.66%           
=======================================
  Files          10       10           
  Lines         690      690           
  Branches      108      108           
=======================================
  Hits          667      667           
  Misses          8        8           
  Partials       15       15           

☔ 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.

@JinHai-CN
JinHai-CN merged commit ea8de1b into infiniflow:main Apr 16, 2026
1 check passed
@Magicbook1108
Magicbook1108 deleted the llm branch April 28, 2026 09:44
JasleenKaurSethi pushed a commit to stackhpc/ragflow that referenced this pull request Apr 28, 2026
### What problem does this PR solve?

Fix: different llm in chat

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
@coderabbitai coderabbitai Bot mentioned this pull request Jun 1, 2026
1 task done
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:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants