From 25725005df1b6350f4172024a71ebb92b7bc16ea Mon Sep 17 00:00:00 2001 From: Zane Tung Date: Tue, 10 Mar 2026 11:06:56 +0800 Subject: [PATCH] fix: format code with gofmt -s MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Align constant definitions in provider.go - Align struct fields in test cases - Fix gofmt formatting issues reported in review 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- pkg/providers/anthropic_messages/provider.go | 34 +++++++++---------- .../anthropic_messages/provider_test.go | 14 ++++---- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pkg/providers/anthropic_messages/provider.go b/pkg/providers/anthropic_messages/provider.go index 0b0387d38..515673f86 100644 --- a/pkg/providers/anthropic_messages/provider.go +++ b/pkg/providers/anthropic_messages/provider.go @@ -30,8 +30,8 @@ type ( ) const ( - defaultAPIVersion = "2023-06-01" - defaultBaseURL = "https://api.anthropic.com/v1" + defaultAPIVersion = "2023-06-01" + defaultBaseURL = "https://api.anthropic.com/v1" defaultRequestTimeout = 120 * time.Second ) @@ -145,9 +145,9 @@ func buildRequestBody( options map[string]any, ) (map[string]any, error) { result := map[string]any{ - "model": model, + "model": model, "max_tokens": int64(4096), - "messages": []any{}, + "messages": []any{}, } // Set max_tokens from options @@ -179,9 +179,9 @@ func buildRequestBody( // Tool result message content := []map[string]any{ { - "type": "tool_result", + "type": "tool_result", "tool_use_id": msg.ToolCallID, - "content": msg.Content, + "content": msg.Content, }, } apiMessages = append(apiMessages, map[string]any{ @@ -227,9 +227,9 @@ func buildRequestBody( // Tool result (alternative format) content := []map[string]any{ { - "type": "tool_result", + "type": "tool_result", "tool_use_id": msg.ToolCallID, - "content": msg.Content, + "content": msg.Content, }, } apiMessages = append(apiMessages, map[string]any{ @@ -259,8 +259,8 @@ func buildTools(tools []ToolDefinition) []any { result := make([]any, len(tools)) for i, tool := range tools { toolDef := map[string]any{ - "name": tool.Function.Name, - "description": tool.Function.Description, + "name": tool.Function.Name, + "description": tool.Function.Description, "input_schema": tool.Function.Parameters, } result[i] = toolDef @@ -369,13 +369,13 @@ func asFloat(v any) (float64, bool) { // Anthropic API response structures type anthropicMessageResponse struct { - ID string `json:"id"` - Type string `json:"type"` - Role string `json:"role"` - Content []contentBlock `json:"content"` - StopReason string `json:"stop_reason"` - Model string `json:"model"` - Usage usageInfo `json:"usage"` + ID string `json:"id"` + Type string `json:"type"` + Role string `json:"role"` + Content []contentBlock `json:"content"` + StopReason string `json:"stop_reason"` + Model string `json:"model"` + Usage usageInfo `json:"usage"` } type contentBlock struct { diff --git a/pkg/providers/anthropic_messages/provider_test.go b/pkg/providers/anthropic_messages/provider_test.go index 76bff10d7..8025d6d1f 100644 --- a/pkg/providers/anthropic_messages/provider_test.go +++ b/pkg/providers/anthropic_messages/provider_test.go @@ -202,9 +202,9 @@ func TestParseResponseBody(t *testing.T) { } }`), want: &LLMResponse{ - Content: "Hello, how can I help?", - ToolCalls: []ToolCall{}, - FinishReason: "stop", + Content: "Hello, how can I help?", + ToolCalls: []ToolCall{}, + FinishReason: "stop", Usage: &UsageInfo{ PromptTokens: 10, CompletionTokens: 5, @@ -252,7 +252,7 @@ func TestParseResponseBody(t *testing.T) { }, }, }, - FinishReason: "tool_calls", + FinishReason: "tool_calls", Usage: &UsageInfo{ PromptTokens: 20, CompletionTokens: 15, @@ -286,9 +286,9 @@ func TestParseResponseBody(t *testing.T) { } }`), want: &LLMResponse{ - Content: "Partial response", - ToolCalls: []ToolCall{}, - FinishReason: "length", + Content: "Partial response", + ToolCalls: []ToolCall{}, + FinishReason: "length", Usage: &UsageInfo{ PromptTokens: 100, CompletionTokens: 4096,