Skip to content

refa: route chat calls through ChatModel - #20441

Merged
wangq8 merged 1 commit into
infiniflow:mainfrom
buua436:go092
Sep 30, 2026
Merged

wangq8 merged 1 commit into
infiniflow:mainfrom
buua436:go092

Conversation

@buua436

@buua436 buua436 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Routes chat model call sites through the ChatModel wrapper so chat behavior is centralized and consistent with the other model wrappers.

Type of change

  • Refactor (no functional change)

@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 043eac52-2480-4bba-b2d6-e213ccb23f46

📥 Commits

Reviewing files that changed from the base of the PR and between 16e19da and e8accd5.

📒 Files selected for processing (14)
  • internal/entity/models/types.go
  • internal/ingestion/component/media_dispatch.go
  • internal/ingestion/component/pdf_vision_dispatch.go
  • internal/ingestion/component/vision_enhancement.go
  • internal/service/chat_pipeline.go
  • internal/service/deep_researcher.go
  • internal/service/generator.go
  • internal/service/graph/retrieval.go
  • internal/service/memory_extractor.go
  • internal/service/metadata_filter.go
  • internal/service/model_call.go
  • internal/service/model_chat.go
  • internal/service/model_service.go
  • internal/service/toc_enhancer.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

ChatModel adds non-streaming and streaming chat methods. Ingestion and service call sites now use these methods instead of calling the driver directly.

Changes

ChatModel Wrapper Adoption

Layer / File(s) Summary
Add ChatModel chat methods
internal/entity/models/types.go
Adds non-streaming and streaming methods. Each checks for a nil receiver or driver, then forwards the request and configured model name to the driver.
Route primary chat paths through ChatModel
internal/service/chat_pipeline.go, internal/service/model_call.go, internal/service/model_chat.go
Regular and solo chat, SQL generation and repair, and model chat entry points use the wrapper methods for streaming and non-streaming requests.
Route ingestion and auxiliary callers through ChatModel
internal/ingestion/component/*, internal/service/deep_researcher.go, internal/service/generator.go, internal/service/graph/retrieval.go, internal/service/memory_extractor.go, internal/service/metadata_filter.go, internal/service/model_service.go, internal/service/toc_enhancer.go
Vision ingestion, model verification, and other service callers use ChatModel methods instead of calling the driver directly.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Refactor

Suggested reviewers: jinhai-cn, qinling0210

Merge Risk: ⚪ Minimal · up to e8acc

The change centralizes chat calls without an identified behavior regression. No actionable merge-blocking issue remains; merge after normal checks pass.

Security Architecture Review

Security architecture risk: 🔵 Low · up to e8acc

The inspected changes preserve existing request targets, access-resolution steps, and cancellation behavior without an observed expansion of authority. Risk is low, but incomplete baseline and runtime coverage limits confidence.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The shared forwarding contract affects multiple existing chat and ingestion paths. In inspected paths, messages still reach the previously resolved provider with its existing API configuration; the wrapper adds no independent credential, environment, or tool authority. Complete tenant exposure was not established.

Trust Boundaries and Controls

  • observed — Inspected service entrypoints retain target resolution before wrapper construction. The wrapper forwards the resolved target rather than accepting a new target-selection input, and provider-side validation remains downstream. This establishes the control ordering, not the completeness of authorization inside the resolver.

Resilience and Maintainability Implications

  • inferred — The inspected stream transition preserves callback and cancellation propagation through the wrapper, with channel cleanup owned by the service and response-body cleanup owned by transport. Provider-side mutable configuration remains an existing ownership contract rather than new wrapper state; concurrent reuse was not verified across all providers.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 61.54% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 14 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 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 and concisely describes the main change: routing chat calls through the ChatModel wrapper.
Description check ✅ Passed The description explains the problem and purpose of the refactor. It also identifies the change type as a refactor with no functional change. It uses a different heading from the template, but it prov…
  • Fix all pre-merge checks with AI

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

A rabbit checks the chat request,
Then sends it through the model’s nest.
The stream hops on, the words arrive,
Two wrappers help the calls run live.
I nibble greens and close the door,
While drivers answer as before.

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

@buua436 buua436 added the ci Continue Integration label Sep 30, 2026
@buua436
buua436 requested a review from wangq8 September 30, 2026 06:21
@wangq8
wangq8 merged commit dd8f570 into infiniflow:main Sep 30, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants