Repository navigation
fix: normalize reasoning model families - #15612
xugangqiang merged 10 commits into
Conversation
📝 WalkthroughWalkthroughNormalizeModelFamily canonicalizes provider-prefixed and variant Qwen model names; GetThinkingAndAnswer and extractThinkContent are nil-safe and use the normalized family to consistently extract inline reasoning from provider responses. ChangesModel-family normalization and reasoning extraction
Sequence DiagramsequenceDiagram
participant TestClient
participant ReasoningServer
participant ChatHandler
participant Parser
TestClient->>ReasoningServer: POST /chat/completions (JSON, Authorization)
ReasoningServer->>ChatHandler: deliver request body
ChatHandler->>Parser: parse response content (contains <think>...</think>\nanswer)
Parser->>ChatHandler: ReasonContent + Answer
ChatHandler->>TestClient: return ChatResponse with ReasonContent and Answer
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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: 1
🤖 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/reasoning_family_provider_test.go`:
- Around line 119-129: The helper assertThinkingEnabled runs inside HTTP handler
goroutines so replace its t.Fatalf calls with t.Errorf and return to ensure
failures are reported to the main test goroutine; specifically update
assertThinkingEnabled (the checks for ok/type) to call t.Errorf with the same
messages and then return immediately after each error instead of calling
t.Fatalf.
🪄 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
Run ID: ccee648d-a4ee-41df-b780-0b1f215d515e
📒 Files selected for processing (3)
internal/entity/models/common.gointernal/entity/models/common_test.gointernal/entity/models/reasoning_family_provider_test.go
ed22de2 to
1fd29f1
Compare
|
Ready for review! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15612 +/- ##
=======================================
Coverage 93.16% 93.16%
=======================================
Files 10 10
Lines 717 717
Branches 118 118
=======================================
Hits 668 668
Misses 29 29
Partials 20 20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Lynn-Inf
left a comment
There was a problem hiding this comment.
The normalization looks necessary, but I'm not confident about the Go side. I'll have my colleague @Haruko386 review it.
|
Hi @wangq8, @JinHai-CN, @KevinHuSh, @yingfeng, @xugangqiang, would you please review my PR and give me your feedback? |
Lynn-Inf
left a comment
There was a problem hiding this comment.
LGTM. For context: the Python implementation doesn't pass the thinking parameter to the LLM call, so this issue doesn't apply there. We'll address it in the upcoming Go migration and leave Python unchanged for now.
What problem does this PR solve?
Closes #15611.
RAGFlow's fallback reasoning parser only recognized the exact model family
qwen3. For provider-prefixed Qwen model names such as SiliconFlow'sqwen/qwen3-8b, the derived model class can beqwen/qwen3, so inline<think>...</think>content was not split from the visible answer whenreasoning_contentwas absent.This PR normalizes model-family detection before fallback reasoning extraction, keeps the parser nil-safe, and adds focused tests for Qwen3 variants plus Gitee and SiliconFlow chat responses.
It also makes SiliconFlow propagate
ChatConfig.Thinkinginto the chat request body, matching the existing Gitee behavior, so Qwen thinking mode is actually enabled when requested.Type of change
Validation
/root/go/bin/gofmt -l internal/entity/models/common.go internal/entity/models/common_test.go internal/entity/models/reasoning_family_provider_test.go internal/entity/models/siliconflow.gogit diff --check/root/go/bin/go test ./internal/entity/models -run 'Test(NormalizeModelFamily|GetThinkingAndAnswer|GiteeChatExtractsQwenThinkingFromInlineContent|SiliconflowChatExtractsProviderPrefixedQwenThinkingFromInlineContent)' -vet=off -count=1Note: the full package command
/root/go/bin/go test ./internal/entity/models -vet=off -count=1now runs locally, but it currently fails on an unrelated existingTestAstraflowEmbedReturnsNoSuchMethodpanic ininternal/entity/models/astraflow.go:482.