Skip to content

fix: unable to use multi model chat - #17097

Merged
JinHai-CN merged 1 commit into
infiniflow:mainfrom
Haruko386:major
Jul 20, 2026
Merged

JinHai-CN merged 1 commit into
infiniflow:mainfrom
Haruko386:major

Conversation

@Haruko386

@Haruko386 Haruko386 commented Jul 20, 2026 •

Copy link
Copy Markdown
Member

Summary

As title

image

@Haruko386 Haruko386 added 🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration labels Jul 20, 2026
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jul 20, 2026
@Haruko386
Haruko386 marked this pull request as draft July 20, 2026 07:07
@Haruko386
Haruko386 marked this pull request as ready for review July 20, 2026 07:07
@Haruko386
Haruko386 marked this pull request as draft July 20, 2026 07:07
@Haruko386
Haruko386 marked this pull request as ready for review July 20, 2026 07:07
@Haruko386 Haruko386 added ci Continue Integration and removed ci Continue Integration labels Jul 20, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

ChatSessionService now resolves tenant model configuration through an injectable model provider service. Tests add a fake resolver and verify explicit model IDs are passed to it and stored on the dialog.

Changes

Chat model resolution

Layer / File(s) Summary
Resolver contract and service wiring
internal/service/chat_session.go
Defines the model configuration resolver interface and initializes ChatSessionService with NewModelProviderService().
Resolver execution and override validation
internal/service/chat_session.go, internal/service/chat_session_test.go
Routes API-key checks through the resolver and tests model ID override propagation and dialog updates.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested labels: ☯️ refactor

Suggested reviewers: jinhai-cn

Poem

I’m a rabbit with a resolver in tow,
Passing model IDs where they need to go.
The dialog remembers the chosen delight,
API keys now resolve just right.
Hop, hop—clean wiring takes flight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is too vague and only repeats the title instead of explaining the issue or fix context. Replace "As title" with a brief summary of the bug, the change made, and any relevant background or impact.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 matches the main change: fixing multi-model chat usage.

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.

🧹 Nitpick comments (1)
internal/service/chat_session.go (1)

1946-1950: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove the defensive fallback to concrete implementation.

Adding a fallback to NewModelProviderService() when the resolver is nil defeats the purpose of dependency injection and couples this method to a concrete implementation. This pattern is often a workaround to accommodate incomplete test setups (where tests instantiate &ChatSessionService{} without supplying a mock).

Please consider relying directly on the injected s.modelProviderSvc. Any existing tests that fail as a result (such as TestChatCompletionsStreamFinalCarriesDecoratedReference in the test file) should be updated to inject a fake resolver instead.

♻️ Proposed refactor
-	resolver := s.modelProviderSvc
-	if resolver == nil {
-		resolver = NewModelProviderService()
-	}
-	_, _, _, _, err := resolver.GetChatModelConfig(tenantID, modelName)
+	_, _, _, _, err := s.modelProviderSvc.GetChatModelConfig(tenantID, modelName)
🤖 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 `@internal/service/chat_session.go` around lines 1946 - 1950, Remove the nil
fallback and call GetChatModelConfig directly through the injected
s.modelProviderSvc in the surrounding chat-session logic. Update affected tests,
including TestChatCompletionsStreamFinalCarriesDecoratedReference, to provide a
fake resolver through modelProviderSvc rather than relying on a concrete
default.
🤖 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.

Nitpick comments:
In `@internal/service/chat_session.go`:
- Around line 1946-1950: Remove the nil fallback and call GetChatModelConfig
directly through the injected s.modelProviderSvc in the surrounding chat-session
logic. Update affected tests, including
TestChatCompletionsStreamFinalCarriesDecoratedReference, to provide a fake
resolver through modelProviderSvc rather than relying on a concrete default.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f2ad4fd1-7a3e-4abb-b79e-9a05f7c578f4

📥 Commits

Reviewing files that changed from the base of the PR and between b2e88c9 and 063e89c.

📒 Files selected for processing (2)
  • internal/service/chat_session.go
  • internal/service/chat_session_test.go

@JinHai-CN
JinHai-CN merged commit 6454104 into infiniflow:main Jul 20, 2026
9 of 12 checks passed
@Haruko386
Haruko386 deleted the major branch July 21, 2026 02:10
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