From 8d3a6b5cb9360b887e9a4db2d63a4c45460e4447 Mon Sep 17 00:00:00 2001 From: "Laisky.Cai" Date: Tue, 25 Feb 2025 03:56:07 +0000 Subject: [PATCH] feat: ensure TopP is nil when using extended thinking in Claude request --- relay/adaptor/anthropic/main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/relay/adaptor/anthropic/main.go b/relay/adaptor/anthropic/main.go index fd6bdb7f..045bef9f 100644 --- a/relay/adaptor/anthropic/main.go +++ b/relay/adaptor/anthropic/main.go @@ -65,6 +65,12 @@ func ConvertRequest(textRequest model.GeneralOpenAIRequest) *Request { Tools: claudeTools, Thinking: textRequest.Thinking, } + + if claudeRequest.Thinking != nil { + // top_p must be nil when using extended thinking + claudeRequest.TopP = nil + } + if len(claudeTools) > 0 { claudeToolChoice := struct { Type string `json:"type"`