fix: format code with gofmt -s
- 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 <noreply@anthropic.com>
This commit is contained in:
parent
27a626c4d9
commit
25725005df
2 changed files with 24 additions and 24 deletions
|
|
@ -30,8 +30,8 @@ type (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
defaultAPIVersion = "2023-06-01"
|
defaultAPIVersion = "2023-06-01"
|
||||||
defaultBaseURL = "https://api.anthropic.com/v1"
|
defaultBaseURL = "https://api.anthropic.com/v1"
|
||||||
defaultRequestTimeout = 120 * time.Second
|
defaultRequestTimeout = 120 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -145,9 +145,9 @@ func buildRequestBody(
|
||||||
options map[string]any,
|
options map[string]any,
|
||||||
) (map[string]any, error) {
|
) (map[string]any, error) {
|
||||||
result := map[string]any{
|
result := map[string]any{
|
||||||
"model": model,
|
"model": model,
|
||||||
"max_tokens": int64(4096),
|
"max_tokens": int64(4096),
|
||||||
"messages": []any{},
|
"messages": []any{},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set max_tokens from options
|
// Set max_tokens from options
|
||||||
|
|
@ -179,9 +179,9 @@ func buildRequestBody(
|
||||||
// Tool result message
|
// Tool result message
|
||||||
content := []map[string]any{
|
content := []map[string]any{
|
||||||
{
|
{
|
||||||
"type": "tool_result",
|
"type": "tool_result",
|
||||||
"tool_use_id": msg.ToolCallID,
|
"tool_use_id": msg.ToolCallID,
|
||||||
"content": msg.Content,
|
"content": msg.Content,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
apiMessages = append(apiMessages, map[string]any{
|
apiMessages = append(apiMessages, map[string]any{
|
||||||
|
|
@ -227,9 +227,9 @@ func buildRequestBody(
|
||||||
// Tool result (alternative format)
|
// Tool result (alternative format)
|
||||||
content := []map[string]any{
|
content := []map[string]any{
|
||||||
{
|
{
|
||||||
"type": "tool_result",
|
"type": "tool_result",
|
||||||
"tool_use_id": msg.ToolCallID,
|
"tool_use_id": msg.ToolCallID,
|
||||||
"content": msg.Content,
|
"content": msg.Content,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
apiMessages = append(apiMessages, map[string]any{
|
apiMessages = append(apiMessages, map[string]any{
|
||||||
|
|
@ -259,8 +259,8 @@ func buildTools(tools []ToolDefinition) []any {
|
||||||
result := make([]any, len(tools))
|
result := make([]any, len(tools))
|
||||||
for i, tool := range tools {
|
for i, tool := range tools {
|
||||||
toolDef := map[string]any{
|
toolDef := map[string]any{
|
||||||
"name": tool.Function.Name,
|
"name": tool.Function.Name,
|
||||||
"description": tool.Function.Description,
|
"description": tool.Function.Description,
|
||||||
"input_schema": tool.Function.Parameters,
|
"input_schema": tool.Function.Parameters,
|
||||||
}
|
}
|
||||||
result[i] = toolDef
|
result[i] = toolDef
|
||||||
|
|
@ -369,13 +369,13 @@ func asFloat(v any) (float64, bool) {
|
||||||
// Anthropic API response structures
|
// Anthropic API response structures
|
||||||
|
|
||||||
type anthropicMessageResponse struct {
|
type anthropicMessageResponse struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Role string `json:"role"`
|
Role string `json:"role"`
|
||||||
Content []contentBlock `json:"content"`
|
Content []contentBlock `json:"content"`
|
||||||
StopReason string `json:"stop_reason"`
|
StopReason string `json:"stop_reason"`
|
||||||
Model string `json:"model"`
|
Model string `json:"model"`
|
||||||
Usage usageInfo `json:"usage"`
|
Usage usageInfo `json:"usage"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type contentBlock struct {
|
type contentBlock struct {
|
||||||
|
|
|
||||||
|
|
@ -202,9 +202,9 @@ func TestParseResponseBody(t *testing.T) {
|
||||||
}
|
}
|
||||||
}`),
|
}`),
|
||||||
want: &LLMResponse{
|
want: &LLMResponse{
|
||||||
Content: "Hello, how can I help?",
|
Content: "Hello, how can I help?",
|
||||||
ToolCalls: []ToolCall{},
|
ToolCalls: []ToolCall{},
|
||||||
FinishReason: "stop",
|
FinishReason: "stop",
|
||||||
Usage: &UsageInfo{
|
Usage: &UsageInfo{
|
||||||
PromptTokens: 10,
|
PromptTokens: 10,
|
||||||
CompletionTokens: 5,
|
CompletionTokens: 5,
|
||||||
|
|
@ -252,7 +252,7 @@ func TestParseResponseBody(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
FinishReason: "tool_calls",
|
FinishReason: "tool_calls",
|
||||||
Usage: &UsageInfo{
|
Usage: &UsageInfo{
|
||||||
PromptTokens: 20,
|
PromptTokens: 20,
|
||||||
CompletionTokens: 15,
|
CompletionTokens: 15,
|
||||||
|
|
@ -286,9 +286,9 @@ func TestParseResponseBody(t *testing.T) {
|
||||||
}
|
}
|
||||||
}`),
|
}`),
|
||||||
want: &LLMResponse{
|
want: &LLMResponse{
|
||||||
Content: "Partial response",
|
Content: "Partial response",
|
||||||
ToolCalls: []ToolCall{},
|
ToolCalls: []ToolCall{},
|
||||||
FinishReason: "length",
|
FinishReason: "length",
|
||||||
Usage: &UsageInfo{
|
Usage: &UsageInfo{
|
||||||
PromptTokens: 100,
|
PromptTokens: 100,
|
||||||
CompletionTokens: 4096,
|
CompletionTokens: 4096,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue