Repository navigation
refactor(go-models): share chat response handling - #17289
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughDeepSeek and Zhipu AI now share typed chat-response parsing, streaming usage decoding, model-usage collection, and centralized tool-call handling. ChangesChat response and usage integration
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Provider
participant ChatParser
participant UsageCollector
participant ClickHouse
Provider->>ChatParser: chat completion response
ChatParser->>UsageCollector: normalized response and usage
UsageCollector->>ClickHouse: collect model usage
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
There was a problem hiding this comment.
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 `@internal/entity/models/base_model.go`:
- Around line 60-107: Make usage/analytics recording best-effort in
parseChatCompletionResponse, applyStreamUsage, and the streaming SSE callbacks
in deepseek.go and zhipu-ai.go: preserve the successfully parsed response and
continue through stream completion even when collectModelUsage or
clickhouse.GetDriver().CollectModelUsage fails. Handle or log usage-write errors
without returning them as primary chat or stream errors.
- Around line 93-95: Update ChatStreamlyWithSender and its applyStreamUsage
streaming path to populate modelUsage.RequestID from the first available usage
or response event before calling collectModelUsage(). Ensure both DeepSeek and
Zhipu streaming implementations preserve and pass the request ID when recording
usage.
🪄 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 Plus
Run ID: e807f662-72f7-4814-a911-9322488dc710
📒 Files selected for processing (3)
internal/entity/models/base_model.gointernal/entity/models/deepseek.gointernal/entity/models/zhipu-ai.go
Summary
Testing
go test -c -o /tmp/ragflow-models.test ./internal/entity/models#17284