From 83feb492fbcf96c8f6cefcd6c2236983849ea895 Mon Sep 17 00:00:00 2001 From: "1808837298@qq.com" <1808837298@qq.com> Date: Tue, 25 Feb 2025 14:37:03 +0800 Subject: [PATCH] feat: Add support for Claude thinking parameter in request --- relay/channel/aws/dto.go | 2 ++ relay/channel/claude/dto.go | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/relay/channel/aws/dto.go b/relay/channel/aws/dto.go index 505967ad..e87ed6ec 100644 --- a/relay/channel/aws/dto.go +++ b/relay/channel/aws/dto.go @@ -16,6 +16,7 @@ type AwsClaudeRequest struct { StopSequences []string `json:"stop_sequences,omitempty"` Tools []claude.Tool `json:"tools,omitempty"` ToolChoice any `json:"tool_choice,omitempty"` + Thinking *claude.Thinking `json:"thinking,omitempty"` } func copyRequest(req *claude.ClaudeRequest) *AwsClaudeRequest { @@ -30,5 +31,6 @@ func copyRequest(req *claude.ClaudeRequest) *AwsClaudeRequest { StopSequences: req.StopSequences, Tools: req.Tools, ToolChoice: req.ToolChoice, + Thinking: req.Thinking, } } diff --git a/relay/channel/claude/dto.go b/relay/channel/claude/dto.go index 13a1430c..56633000 100644 --- a/relay/channel/claude/dto.go +++ b/relay/channel/claude/dto.go @@ -54,9 +54,15 @@ type ClaudeRequest struct { TopP float64 `json:"top_p,omitempty"` TopK int `json:"top_k,omitempty"` //ClaudeMetadata `json:"metadata,omitempty"` - Stream bool `json:"stream,omitempty"` - Tools []Tool `json:"tools,omitempty"` - ToolChoice any `json:"tool_choice,omitempty"` + Stream bool `json:"stream,omitempty"` + Tools []Tool `json:"tools,omitempty"` + ToolChoice any `json:"tool_choice,omitempty"` + Thinking *Thinking `json:"thinking,omitempty"` +} + +type Thinking struct { + Type string `json:"type"` + BudgetTokens int `json:"budget_tokens"` } type ClaudeError struct {