Repository navigation
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 (4)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe PR standardizes typed OpenAI-compatible chat parsing across five providers, adds streaming usage extraction, records embedding and reranking usage, adjusts rerank defaults, and adds provider integration tests. ChangesProvider usage integration
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant ChatStreamlyWithSender
participant ProviderSSE
participant ModelUsage
Client->>ChatStreamlyWithSender: submit streaming chat request
ChatStreamlyWithSender->>ProviderSSE: send stream_options.include_usage
ProviderSSE-->>ChatStreamlyWithSender: return SSE deltas and usage event
ChatStreamlyWithSender->>ModelUsage: decode and apply token usage
ModelUsage-->>Client: expose UsageResult
Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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: 4
🧹 Nitpick comments (1)
internal/entity/models/aliyun.go (1)
505-511: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDead fallback:
topNcan never be 0 here.
topNstarts atlen(documents), which is guaranteed non-zero by the early return at Line 490, and is only reassigned whenrerankConfig.TopN > 0. Drop the leftover branch.♻️ Remove the unreachable branch
topN := len(documents) if rerankConfig != nil && rerankConfig.TopN > 0 { topN = rerankConfig.TopN } - if topN == 0 { - topN = len(documents) - }🤖 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/entity/models/aliyun.go` around lines 505 - 511, Remove the unreachable topN == 0 fallback branch in the reranking logic around topN initialization, while preserving the existing default to len(documents) and positive rerankConfig.TopN override.
🤖 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 76-91: The usage helpers create local records when no caller-owned
model usage exists, causing incomplete persistence. Update recordResponseUsage
and applyStreamUsage to return immediately when their model usage argument is
nil; keep existing usage collection unchanged for non-nil records, and note that
internal/entity/models/base_model.go lines 133-138 requires the same handling in
applyStreamUsage.
In `@internal/entity/models/non_chat_usage_test.go`:
- Around line 1-8: Add the standard InfiniFlow Apache-2.0 license header at the
top of non_chat_usage_test.go, matching the header used by
openai_compatible_usage_test.go.
In `@internal/entity/models/openai_compatible_usage_test.go`:
- Around line 62-65: In the httptest handler decode-error branches, replace
t.Fatalf with t.Errorf and immediately return so the handler terminates without
leaving the request unanswered. Apply this in
internal/entity/models/openai_compatible_usage_test.go lines 62-65 and
internal/entity/models/volcengine_test.go lines 119-122, using the existing
request-body decode logic in each handler.
In `@internal/entity/models/siliconflow.go`:
- Around line 254-261: Enable usage reporting in both streaming request bodies:
update internal/entity/models/siliconflow.go at lines 254-261 and
internal/entity/models/qiniu.go at lines 321-328 to add stream_options with
include_usage set to true where each request body is built, so
decodeOpenAICompatibleStreamUsage can receive the emitted usage chunk.
---
Nitpick comments:
In `@internal/entity/models/aliyun.go`:
- Around line 505-511: Remove the unreachable topN == 0 fallback branch in the
reranking logic around topN initialization, while preserving the existing
default to len(documents) and positive rerankConfig.TopN override.
🪄 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: 58a496aa-0710-4421-a928-f04795209f28
📒 Files selected for processing (10)
internal/entity/models/aliyun.gointernal/entity/models/base_model.gointernal/entity/models/huaweicloud.gointernal/entity/models/non_chat_usage_test.gointernal/entity/models/openai_compatible_usage_test.gointernal/entity/models/qiniu.gointernal/entity/models/siliconflow.gointernal/entity/models/siliconflow_test.gointernal/entity/models/volcengine.gointernal/entity/models/volcengine_test.go
Summary
Related to #17284
Testing
go vet ./internal/entity/modelsCGO_ENABLED=0 go test ./internal/entity/models -count=1