feat: adapt Volcengine adaptor for deepseek3.1 with thinking mode - #1652
Conversation
|
Warning Rate limit exceeded@HynoR has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 14 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughAdds an import and a conditional in ConvertOpenAIRequest to detect upstream model names starting with "deepseek" and ending with "-thinking"; it trims the "-thinking" suffix and injects a JSON RawMessage into Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Caller
participant Convert as ConvertOpenAIRequest
participant Request as Outgoing OpenAI Request
Caller->>Convert: call ConvertOpenAIRequest(info)
activate Convert
Convert->>Convert: eval info.UpstreamModelName\nstartsWith("deepseek") && endsWith("-thinking")
alt deepseek thinking variant
Convert->>Request: Model = trimmed name (remove "-thinking")
Convert->>Request: THINKING = json.RawMessage({"thinking":{"type":"enabled"}})
else other models
Convert->>Request: build request normally
end
Convert-->>Caller: return request
deactivate Convert
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
relay/channel/volcengine/adaptor.go (1)
218-223: Don’t mutateinfo.UpstreamModelName; merge intoExtraBodywhen enabling “thinking”We’ve verified that:
ExtraBodyis defined asjson.RawMessageindto/openai_request.go(line 62), so it’s safe to unmarshal and re-marshal when merging .info.UpstreamModelNameis used pervasively after this block (logs, metrics, routing, downstream adaptors), so in-place mutation here would have unintended side effects across the relay pipeline .Location in question
• File relay/channel/volcengine/adaptor.go, lines 218–223Suggested optional refactor
- // 适配 方舟deepseek混合模型 的 thinking 后缀 - if strings.HasSuffix(info.UpstreamModelName, "-thinking") && strings.HasPrefix(info.UpstreamModelName, "deepseek") { - info.UpstreamModelName = strings.TrimSuffix(info.UpstreamModelName, "-thinking") - request.Model = info.UpstreamModelName - request.ExtraBody = json.RawMessage(`{"thinking": {"type": "enabled"}}`) - } + // 适配 方舟 deepseek 混合模型 的 thinking 后缀;不修改 info.UpstreamModelName,避免副作用 + name := strings.ToLower(info.UpstreamModelName) + if strings.HasSuffix(name, "-thinking") && strings.HasPrefix(name, "deepseek") { + trimmed := strings.TrimSuffix(info.UpstreamModelName, "-thinking") + request.Model = trimmed + if len(request.ExtraBody) == 0 { + request.ExtraBody = json.RawMessage(`{"thinking":{"type":"enabled"}}`) + } else { + var extra map[string]any + if err := json.Unmarshal(request.ExtraBody, &extra); err == nil { + if _, exists := extra["thinking"]; !exists { + extra["thinking"] = map[string]any{"type":"enabled"} + } + if b, err := json.Marshal(extra); err == nil { + request.ExtraBody = b + } + } + } + }Optional: add a unit test covering
- Input model
"deepseek-v3-1-250821-thinking"→ request.Model"deepseek-v3-1-250821"- Pre-populated
ExtraBodyretains existing keys and injects"thinking"only once.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
relay/channel/volcengine/adaptor.go(2 hunks)
🔇 Additional comments (1)
relay/channel/volcengine/adaptor.go (1)
5-5: Import looks correct and necessary
encoding/jsonis required forjson.RawMessagebelow. No issues.
19f6a2d to
a368e3a
Compare
feat: adapt Volcengine adaptor for deepseek3.1 with thinking mode
ref: #1638
适配火山方舟 Deepseek 3.1 思考后缀

模型名称为 deepseek-v3-1-250821-thinking 将会启用思考功能
Summary by CodeRabbit
New Features
Chores