Skip to content

Commit 0c68e1e

Browse files
Stainless BotRobertCraigie
authored andcommitted
chore(examples): minor formatting changes (#8)
1 parent c386c36 commit 0c68e1e

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func main() {
5454
Model: anthropic.F(anthropic.ModelClaude_3_5_Sonnet_20240620),
5555
MaxTokens: anthropic.F(int64(1024)),
5656
Messages: anthropic.F([]anthropic.MessageParam{
57-
anthropic.NewUserMessage(anthropic.NewTextBlock("What is the weather in SF?")),
57+
anthropic.NewUserMessage(anthropic.NewTextBlock("What is a quaternion?")),
5858
}),
5959
})
6060
if err != nil {
@@ -379,9 +379,7 @@ To handle errors, we recommend that you use the `errors.As` pattern:
379379
```go
380380
_, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
381381
MaxTokens: anthropic.F(int64(1024)),
382-
Messages: anthropic.F([]anthropic.MessageParam{
383-
anthropic.NewUserMessage(anthropic.NewTextBlock("What is the weather in SF?")),
384-
}),
382+
385383
Model: anthropic.F(anthropic.ModelClaude_3_5_Sonnet_20240620),
386384
})
387385
if err != nil {
@@ -413,7 +411,7 @@ client.Messages.New(
413411
anthropic.MessageNewParams{
414412
MaxTokens: anthropic.F(int64(1024)),
415413
Messages: anthropic.F([]anthropic.MessageParam{
416-
anthropic.NewUserMessage(anthropic.NewTextBlock("What is the weather in SF?")),
414+
anthropic.NewUserMessage(anthropic.NewTextBlock("What is a quaternion?")),
417415
}),
418416
Model: anthropic.F(anthropic.ModelClaude_3_5_Sonnet_20240620),
419417
},
@@ -455,7 +453,7 @@ client.Messages.New(
455453
anthropic.MessageNewParams{
456454
MaxTokens: anthropic.F(int64(1024)),
457455
Messages: anthropic.F([]anthropic.MessageParam{
458-
anthropic.NewUserMessage(anthropic.NewTextBlock("What is the weather in SF?")),
456+
anthropic.NewUserMessage(anthropic.NewTextBlock("What is a quaternion?")),
459457
}),
460458
Model: anthropic.F(anthropic.ModelClaude_3_5_Sonnet_20240620),
461459
},

client_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func TestUserAgentHeader(t *testing.T) {
4040
MaxTokens: anthropic.F(int64(1024)),
4141
Messages: anthropic.F([]anthropic.MessageParam{{
4242
Role: anthropic.F(anthropic.MessageParamRoleUser),
43-
Content: anthropic.F([]anthropic.MessageParamContentUnion{anthropic.TextBlockParam{Type: anthropic.F(anthropic.TextBlockParamTypeText), Text: anthropic.F("What is a quaternion?")}}),
43+
Content: anthropic.F([]anthropic.MessageParamContentUnion{anthropic.TextBlockParam{Text: anthropic.F("What is a quaternion?"), Type: anthropic.F(anthropic.TextBlockParamTypeText)}}),
4444
}}),
4545
Model: anthropic.F(anthropic.ModelClaude_3_5_Sonnet_20240620),
4646
})
@@ -70,7 +70,7 @@ func TestRetryAfter(t *testing.T) {
7070
MaxTokens: anthropic.F(int64(1024)),
7171
Messages: anthropic.F([]anthropic.MessageParam{{
7272
Role: anthropic.F(anthropic.MessageParamRoleUser),
73-
Content: anthropic.F([]anthropic.MessageParamContentUnion{anthropic.TextBlockParam{Type: anthropic.F(anthropic.TextBlockParamTypeText), Text: anthropic.F("What is a quaternion?")}}),
73+
Content: anthropic.F([]anthropic.MessageParamContentUnion{anthropic.TextBlockParam{Text: anthropic.F("What is a quaternion?"), Type: anthropic.F(anthropic.TextBlockParamTypeText)}}),
7474
}}),
7575
Model: anthropic.F(anthropic.ModelClaude_3_5_Sonnet_20240620),
7676
})
@@ -103,7 +103,7 @@ func TestRetryAfterMs(t *testing.T) {
103103
MaxTokens: anthropic.F(int64(1024)),
104104
Messages: anthropic.F([]anthropic.MessageParam{{
105105
Role: anthropic.F(anthropic.MessageParamRoleUser),
106-
Content: anthropic.F([]anthropic.MessageParamContentUnion{anthropic.TextBlockParam{Type: anthropic.F(anthropic.TextBlockParamTypeText), Text: anthropic.F("What is a quaternion?")}}),
106+
Content: anthropic.F([]anthropic.MessageParamContentUnion{anthropic.TextBlockParam{Text: anthropic.F("What is a quaternion?"), Type: anthropic.F(anthropic.TextBlockParamTypeText)}}),
107107
}}),
108108
Model: anthropic.F(anthropic.ModelClaude_3_5_Sonnet_20240620),
109109
})
@@ -132,7 +132,7 @@ func TestContextCancel(t *testing.T) {
132132
MaxTokens: anthropic.F(int64(1024)),
133133
Messages: anthropic.F([]anthropic.MessageParam{{
134134
Role: anthropic.F(anthropic.MessageParamRoleUser),
135-
Content: anthropic.F([]anthropic.MessageParamContentUnion{anthropic.TextBlockParam{Type: anthropic.F(anthropic.TextBlockParamTypeText), Text: anthropic.F("What is a quaternion?")}}),
135+
Content: anthropic.F([]anthropic.MessageParamContentUnion{anthropic.TextBlockParam{Text: anthropic.F("What is a quaternion?"), Type: anthropic.F(anthropic.TextBlockParamTypeText)}}),
136136
}}),
137137
Model: anthropic.F(anthropic.ModelClaude_3_5_Sonnet_20240620),
138138
})
@@ -158,7 +158,7 @@ func TestContextCancelDelay(t *testing.T) {
158158
MaxTokens: anthropic.F(int64(1024)),
159159
Messages: anthropic.F([]anthropic.MessageParam{{
160160
Role: anthropic.F(anthropic.MessageParamRoleUser),
161-
Content: anthropic.F([]anthropic.MessageParamContentUnion{anthropic.TextBlockParam{Type: anthropic.F(anthropic.TextBlockParamTypeText), Text: anthropic.F("What is a quaternion?")}}),
161+
Content: anthropic.F([]anthropic.MessageParamContentUnion{anthropic.TextBlockParam{Text: anthropic.F("What is a quaternion?"), Type: anthropic.F(anthropic.TextBlockParamTypeText)}}),
162162
}}),
163163
Model: anthropic.F(anthropic.ModelClaude_3_5_Sonnet_20240620),
164164
})
@@ -190,7 +190,7 @@ func TestContextDeadline(t *testing.T) {
190190
MaxTokens: anthropic.F(int64(1024)),
191191
Messages: anthropic.F([]anthropic.MessageParam{{
192192
Role: anthropic.F(anthropic.MessageParamRoleUser),
193-
Content: anthropic.F([]anthropic.MessageParamContentUnion{anthropic.TextBlockParam{Type: anthropic.F(anthropic.TextBlockParamTypeText), Text: anthropic.F("What is a quaternion?")}}),
193+
Content: anthropic.F([]anthropic.MessageParamContentUnion{anthropic.TextBlockParam{Text: anthropic.F("What is a quaternion?"), Type: anthropic.F(anthropic.TextBlockParamTypeText)}}),
194194
}}),
195195
Model: anthropic.F(anthropic.ModelClaude_3_5_Sonnet_20240620),
196196
})

message_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ func TestMessageNewWithOptionalParams(t *testing.T) {
2828
_, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
2929
MaxTokens: anthropic.F(int64(1024)),
3030
Messages: anthropic.F([]anthropic.MessageParam{{
31+
Content: anthropic.F([]anthropic.MessageParamContentUnion{anthropic.TextBlockParam{Text: anthropic.F("What is a quaternion?"), Type: anthropic.F(anthropic.TextBlockParamTypeText)}}),
3132
Role: anthropic.F(anthropic.MessageParamRoleUser),
32-
Content: anthropic.F([]anthropic.MessageParamContentUnion{anthropic.TextBlockParam{Type: anthropic.F(anthropic.TextBlockParamTypeText), Text: anthropic.F("What is a quaternion?")}}),
3333
}}),
3434
Model: anthropic.F(anthropic.ModelClaude_3_5_Sonnet_20240620),
3535
Metadata: anthropic.F(anthropic.MessageNewParamsMetadata{
3636
UserID: anthropic.F("13803d75-b4b5-4c3e-b2a2-6f21399b021b"),
3737
}),
3838
StopSequences: anthropic.F([]string{"string", "string", "string"}),
39-
System: anthropic.F([]anthropic.TextBlockParam{{Type: anthropic.F(anthropic.TextBlockParamTypeText), Text: anthropic.F("x")}, {Type: anthropic.F(anthropic.TextBlockParamTypeText), Text: anthropic.F("x")}, {Type: anthropic.F(anthropic.TextBlockParamTypeText), Text: anthropic.F("x")}}),
39+
System: anthropic.F([]anthropic.TextBlockParam{{Text: anthropic.F("x"), Type: anthropic.F(anthropic.TextBlockParamTypeText)}, {Text: anthropic.F("x"), Type: anthropic.F(anthropic.TextBlockParamTypeText)}, {Text: anthropic.F("x"), Type: anthropic.F(anthropic.TextBlockParamTypeText)}}),
4040
Temperature: anthropic.F(1.000000),
4141
ToolChoice: anthropic.F[anthropic.MessageNewParamsToolChoiceUnion](anthropic.MessageNewParamsToolChoiceToolChoiceAuto{
4242
Type: anthropic.F(anthropic.MessageNewParamsToolChoiceToolChoiceAutoTypeAuto),

usage_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestUsage(t *testing.T) {
2828
MaxTokens: anthropic.F(int64(1024)),
2929
Messages: anthropic.F([]anthropic.MessageParam{{
3030
Role: anthropic.F(anthropic.MessageParamRoleUser),
31-
Content: anthropic.F([]anthropic.MessageParamContentUnion{anthropic.TextBlockParam{Type: anthropic.F(anthropic.TextBlockParamTypeText), Text: anthropic.F("What is a quaternion?")}}),
31+
Content: anthropic.F([]anthropic.MessageParamContentUnion{anthropic.TextBlockParam{Text: anthropic.F("What is a quaternion?"), Type: anthropic.F(anthropic.TextBlockParamTypeText)}}),
3232
}}),
3333
Model: anthropic.F(anthropic.ModelClaude_3_5_Sonnet_20240620),
3434
})

0 commit comments

Comments
 (0)