Update relay-claude.go - #1385
Conversation
优化claude messages接口启用思考时的参数设置
WalkthroughThe update adjusts the handling of sampling parameters in the function that adapts OpenAI-style requests to Anthropic for models with names ending in "-thinking." Specifically, it sets Changes
Poem
✨ Finishing Touches
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. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
relay/channel/claude/relay-claude.go (1)
121-124: Parameter adjustments align with Anthropic's requirements for thinking models.The changes correctly implement Anthropic's requirements by setting
TopKtonilandTopPto0.95for thinking models. However, consider the following:
Hardcoded value: The
TopPis hardcoded to0.95. While this is within the acceptable range (0.95-1), it might not be optimal for all use cases.User input override: The implementation overrides any user-provided
TopPvalue without preserving or validating it, which could be unexpected behavior.Consider enhancing the implementation to respect user preferences within acceptable bounds:
- // Anthropic 要求去掉 top_k - claudeRequest.TopK = nil - //top_p值可以在0.95-1之间 - claudeRequest.TopP = 0.95 + // Anthropic 要求去掉 top_k + claudeRequest.TopK = nil + //top_p值可以在0.95-1之间 + if claudeRequest.TopP < 0.95 { + claudeRequest.TopP = 0.95 + }This approach would preserve user-provided
TopPvalues that are already within the acceptable range while ensuring compliance with Anthropic's requirements.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
relay/channel/claude/relay-claude.go(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: 9Ninety
PR: QuantumNous/new-api#1273
File: relay/channel/gemini/relay-gemini.go:97-116
Timestamp: 2025-06-21T03:37:41.726Z
Learning: In relay/channel/gemini/relay-gemini.go, the thinking budget calculation logic (including the MaxOutputTokens multiplication) was introduced in PR #1247. PR #1273 focused specifically on decoupling the thoughts summary feature from thinking budget settings and did not modify the existing thinking budget behavior.
relay/channel/claude/relay-claude.go (1)
Learnt from: 9Ninety
PR: QuantumNous/new-api#1273
File: relay/channel/gemini/relay-gemini.go:97-116
Timestamp: 2025-06-21T03:37:41.726Z
Learning: In relay/channel/gemini/relay-gemini.go, the thinking budget calculation logic (including the MaxOutputTokens multiplication) was introduced in PR #1247. PR #1273 focused specifically on decoupling the thoughts summary feature from thinking budget settings and did not modify the existing thinking budget behavior.
Update claude topP argument
优化claude messages接口启用思考时的参数设置
Summary by CodeRabbit