Skip to content

Commit 6de2d50

Browse files
committed
Fix tests
1 parent 2c5cb9e commit 6de2d50

File tree

5 files changed

+190
-129
lines changed

5 files changed

+190
-129
lines changed

pydantic_ai_slim/pydantic_ai/models/groq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ async def _get_event_iterator(self) -> AsyncIterator[ModelResponseStreamEvent]:
505505
)
506506
return
507507
except ValidationError as e:
508-
pass
508+
pass # pragma: no cover
509509
raise
510510

511511
@property

tests/models/cassettes/test_groq/test_tool_regular_error.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,53 @@ interactions:
4646
status:
4747
code: 404
4848
message: Not Found
49+
- request:
50+
headers:
51+
accept:
52+
- application/json
53+
accept-encoding:
54+
- gzip, deflate
55+
connection:
56+
- keep-alive
57+
content-length:
58+
- '92'
59+
content-type:
60+
- application/json
61+
cookie:
62+
- __cf_bm=iezhhe87vg5KFYcM9IscO.LHkV8Rv0iM504X.mfCjyk-1756847105-1.0.1.1-otC4FjCOjx._h6QtwT8RmzJksvvp7AaYmv5_.yVAgRa9R4Aon_.qtG1HP7KVwunhgrIiWaZPQhPwh81YLf3h9rC_loDrBn.TQgDMlZ19B0w
63+
host:
64+
- api.groq.com
65+
method: POST
66+
parsed_body:
67+
messages:
68+
- content: hello
69+
role: user
70+
model: non-existent
71+
n: 1
72+
stream: false
73+
uri: https://api.groq.com/openai/v1/chat/completions
74+
response:
75+
headers:
76+
alt-svc:
77+
- h3=":443"; ma=86400
78+
cache-control:
79+
- private, max-age=0, no-store, no-cache, must-revalidate
80+
connection:
81+
- keep-alive
82+
content-length:
83+
- '153'
84+
content-type:
85+
- application/json
86+
transfer-encoding:
87+
- chunked
88+
vary:
89+
- Origin
90+
parsed_body:
91+
error:
92+
code: model_not_found
93+
message: The model `non-existent` does not exist or you do not have access to it.
94+
type: invalid_request_error
95+
status:
96+
code: 404
97+
message: Not Found
4998
version: 1

tests/models/cassettes/test_groq/test_tool_use_failed_error.yaml

Lines changed: 59 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ interactions:
88
connection:
99
- keep-alive
1010
content-length:
11-
- '465'
11+
- '517'
1212
content-type:
1313
- application/json
1414
host:
1515
- api.groq.com
1616
method: POST
1717
parsed_body:
1818
messages:
19-
- content: Be concise
19+
- content: Be concise. Never use pretty double quotes, just regular ones.
2020
role: system
2121
- content: Please call the "get_something_by_name" tool with non-existent parameters to test error handling
2222
role: user
@@ -47,7 +47,7 @@ interactions:
4747
connection:
4848
- keep-alive
4949
content-length:
50-
- '380'
50+
- '401'
5151
content-type:
5252
- application/json
5353
vary:
@@ -57,10 +57,10 @@ interactions:
5757
code: tool_use_failed
5858
failed_generation: |-
5959
{"name": "get_something_by_name", "arguments": {
60-
"foo": "bar"
60+
"invalid_param": "test"
6161
}}
6262
message: 'Tool call validation failed: tool call validation failed: parameters for tool get_something_by_name did
63-
not match schema: errors: [missing properties: ''name'', additionalProperties ''foo'' not allowed]'
63+
not match schema: errors: [missing properties: ''name'', additionalProperties ''invalid_param'' not allowed]'
6464
type: invalid_request_error
6565
status:
6666
code: 400
@@ -74,26 +74,26 @@ interactions:
7474
connection:
7575
- keep-alive
7676
content-length:
77-
- '1109'
77+
- '1194'
7878
content-type:
7979
- application/json
8080
cookie:
81-
- __cf_bm=r4eifucGNAohgEHNfsCFalYUWV4qgqvy7XPQxbzI2a0-1756845611-1.0.1.1-9ZjyA2RbD1ht2aZwoOWmJvxbPjkLJ1m2UPjWtX.DRUxkovhj6V71XZqTgUjcYBx66MPRcX_rROEi7_PXMmZtmecAVLC01qCetrbiEqXAMDU
81+
- __cf_bm=WMG3BQS5HkdpU5Z0Li6BHrMf9LpbLVf439yJW6y0o_Y-1756847034-1.0.1.1-QyWCGYlk_BGpqUCXdhczqr0bBq94afUlKTqyv_FDO5ksNzCNdNY5QkKBCi.RoWCRo.oIhWHmFJ3mW_Ab3IyyI3wFCLdQql_yH0EkgoEi31M
8282
host:
8383
- api.groq.com
8484
method: POST
8585
parsed_body:
8686
messages:
87-
- content: Be concise
87+
- content: Be concise. Never use pretty double quotes, just regular ones.
8888
role: system
8989
- content: Please call the "get_something_by_name" tool with non-existent parameters to test error handling
9090
role: user
9191
- role: assistant
9292
tool_calls:
9393
- function:
94-
arguments: '{"foo":"bar"}'
94+
arguments: '{"invalid_param":"test"}'
9595
name: get_something_by_name
96-
id: pyd_ai_d17424eab8384327a78aa310bcc42683
96+
id: pyd_ai_ad025dbe97d74d7f8693ee8fe14fa558
9797
type: function
9898
- content: |-
9999
2 validation errors: [
@@ -104,22 +104,22 @@ interactions:
104104
],
105105
"msg": "Field required",
106106
"input": {
107-
"foo": "bar"
107+
"invalid_param": "test"
108108
}
109109
},
110110
{
111111
"type": "extra_forbidden",
112112
"loc": [
113-
"foo"
113+
"invalid_param"
114114
],
115115
"msg": "Extra inputs are not permitted",
116-
"input": "bar"
116+
"input": "test"
117117
}
118118
]
119119
120120
Fix the errors and try again.
121121
role: tool
122-
tool_call_id: pyd_ai_d17424eab8384327a78aa310bcc42683
122+
tool_call_id: pyd_ai_ad025dbe97d74d7f8693ee8fe14fa558
123123
model: openai/gpt-oss-120b
124124
n: 1
125125
stream: false
@@ -147,7 +147,7 @@ interactions:
147147
connection:
148148
- keep-alive
149149
content-length:
150-
- '826'
150+
- '827'
151151
content-type:
152152
- application/json
153153
transfer-encoding:
@@ -160,31 +160,31 @@ interactions:
160160
index: 0
161161
logprobs: null
162162
message:
163-
reasoning: We need to call get_something_by_name with correct parameter name. Provide a name maybe "test".
163+
reasoning: 'We need to call with correct param name: name. Provide a non-existent name perhaps "nonexistent".'
164164
role: assistant
165165
tool_calls:
166166
- function:
167-
arguments: '{"name":"test"}'
167+
arguments: '{"name":"nonexistent"}'
168168
name: get_something_by_name
169-
id: fc_8d40b390-5c76-4f01-93d3-fffebc4b8229
169+
id: fc_c8fd1e7c-0e6b-4a28-8ef2-516c38aa9ba8
170170
type: function
171-
created: 1756845613
172-
id: chatcmpl-03c37f57-259e-4e67-9b56-af0af248c7c8
171+
created: 1756847034
172+
id: chatcmpl-01583e50-828f-4759-82e2-08b35493ebe6
173173
model: openai/gpt-oss-120b
174174
object: chat.completion
175175
service_tier: on_demand
176-
system_fingerprint: fp_82669fd91d
176+
system_fingerprint: fp_213abb2467
177177
usage:
178-
completion_time: 0.096969675
179-
completion_tokens: 48
180-
prompt_time: 0.031124029
181-
prompt_tokens: 270
182-
queue_time: 1.9301744730000001
183-
total_time: 0.128093704
184-
total_tokens: 318
178+
completion_time: 0.097360195
179+
completion_tokens: 49
180+
prompt_time: 0.01243387
181+
prompt_tokens: 283
182+
queue_time: 0.245412094
183+
total_time: 0.109794065
184+
total_tokens: 332
185185
usage_breakdown: null
186186
x_groq:
187-
id: req_01k462h63jfxe8xrcqgr5pa8dj
187+
id: req_01k463wm1xesw9bd2z9mvdrt70
188188
status:
189189
code: 200
190190
message: OK
@@ -197,26 +197,26 @@ interactions:
197197
connection:
198198
- keep-alive
199199
content-length:
200-
- '1401'
200+
- '1500'
201201
content-type:
202202
- application/json
203203
cookie:
204-
- __cf_bm=r4eifucGNAohgEHNfsCFalYUWV4qgqvy7XPQxbzI2a0-1756845611-1.0.1.1-9ZjyA2RbD1ht2aZwoOWmJvxbPjkLJ1m2UPjWtX.DRUxkovhj6V71XZqTgUjcYBx66MPRcX_rROEi7_PXMmZtmecAVLC01qCetrbiEqXAMDU
204+
- __cf_bm=WMG3BQS5HkdpU5Z0Li6BHrMf9LpbLVf439yJW6y0o_Y-1756847034-1.0.1.1-QyWCGYlk_BGpqUCXdhczqr0bBq94afUlKTqyv_FDO5ksNzCNdNY5QkKBCi.RoWCRo.oIhWHmFJ3mW_Ab3IyyI3wFCLdQql_yH0EkgoEi31M
205205
host:
206206
- api.groq.com
207207
method: POST
208208
parsed_body:
209209
messages:
210-
- content: Be concise
210+
- content: Be concise. Never use pretty double quotes, just regular ones.
211211
role: system
212212
- content: Please call the "get_something_by_name" tool with non-existent parameters to test error handling
213213
role: user
214214
- role: assistant
215215
tool_calls:
216216
- function:
217-
arguments: '{"foo":"bar"}'
217+
arguments: '{"invalid_param":"test"}'
218218
name: get_something_by_name
219-
id: pyd_ai_d17424eab8384327a78aa310bcc42683
219+
id: pyd_ai_ad025dbe97d74d7f8693ee8fe14fa558
220220
type: function
221221
- content: |-
222222
2 validation errors: [
@@ -227,32 +227,32 @@ interactions:
227227
],
228228
"msg": "Field required",
229229
"input": {
230-
"foo": "bar"
230+
"invalid_param": "test"
231231
}
232232
},
233233
{
234234
"type": "extra_forbidden",
235235
"loc": [
236-
"foo"
236+
"invalid_param"
237237
],
238238
"msg": "Extra inputs are not permitted",
239-
"input": "bar"
239+
"input": "test"
240240
}
241241
]
242242
243243
Fix the errors and try again.
244244
role: tool
245-
tool_call_id: pyd_ai_d17424eab8384327a78aa310bcc42683
245+
tool_call_id: pyd_ai_ad025dbe97d74d7f8693ee8fe14fa558
246246
- role: assistant
247247
tool_calls:
248248
- function:
249-
arguments: '{"name":"test"}'
249+
arguments: '{"name":"nonexistent"}'
250250
name: get_something_by_name
251-
id: fc_8d40b390-5c76-4f01-93d3-fffebc4b8229
251+
id: fc_c8fd1e7c-0e6b-4a28-8ef2-516c38aa9ba8
252252
type: function
253-
- content: 'Something with name: test'
253+
- content: 'Something with name: nonexistent'
254254
role: tool
255-
tool_call_id: fc_8d40b390-5c76-4f01-93d3-fffebc4b8229
255+
tool_call_id: fc_c8fd1e7c-0e6b-4a28-8ef2-516c38aa9ba8
256256
model: openai/gpt-oss-120b
257257
n: 1
258258
stream: false
@@ -280,7 +280,7 @@ interactions:
280280
connection:
281281
- keep-alive
282282
content-length:
283-
- '809'
283+
- '1019'
284284
content-type:
285285
- application/json
286286
transfer-encoding:
@@ -293,27 +293,29 @@ interactions:
293293
index: 0
294294
logprobs: null
295295
message:
296-
content: 'The tool was called with the required parameter `name` and returned: “Something with name: test.”'
297-
reasoning: We need to respond. The user asked to call the tool with non-existent parameters to test error handling,
298-
we fixed it. Now respond concisely.
296+
content: 'Something with name: nonexistent'
297+
reasoning: 'The user asked: "Please call the ''get_something_by_name'' tool with non-existent parameters to test
298+
error handling". They wanted to test error handling with non-existent parameters, but we corrected to proper parameters.
299+
The response from tool: "Something with name: nonexistent". Should we respond? Probably just output the result.
300+
Follow developer instruction: be concise, no fancy quotes. Use regular quotes only.'
299301
role: assistant
300-
created: 1756845613
301-
id: chatcmpl-996ac630-03a7-4a06-bec8-11a457ceed68
302+
created: 1756847037
303+
id: chatcmpl-5b729d91-3507-4942-bd0d-27e7732afc6d
302304
model: openai/gpt-oss-120b
303305
object: chat.completion
304306
service_tier: on_demand
305-
system_fingerprint: fp_ed9190d8b7
307+
system_fingerprint: fp_213abb2467
306308
usage:
307-
completion_time: 0.123180761
308-
completion_tokens: 62
309-
prompt_time: 0.013627929
310-
prompt_tokens: 305
311-
queue_time: 0.266530314
312-
total_time: 0.13680869
313-
total_tokens: 367
309+
completion_time: 0.205303865
310+
completion_tokens: 96
311+
prompt_time: 0.018679785
312+
prompt_tokens: 319
313+
queue_time: 2.222792642
314+
total_time: 0.22398365
315+
total_tokens: 415
314316
usage_breakdown: null
315317
x_groq:
316-
id: req_01k462h86bfxea5fv8wkzpev0s
318+
id: req_01k463wmgvfwwbcdj54311368h
317319
status:
318320
code: 200
319321
message: OK

0 commit comments

Comments
 (0)