Skip to content

Commit eef4526

Browse files
committed
Add cassettes
1 parent 29f8da0 commit eef4526

File tree

8 files changed

+1502
-165
lines changed

8 files changed

+1502
-165
lines changed

pydantic_ai_slim/pydantic_ai/models/openai.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,6 +2132,15 @@ async def _get_event_iterator(self) -> AsyncIterator[ModelResponseStreamEvent]:
21322132
elif isinstance(chunk, responses.ResponseMcpCallCompletedEvent):
21332133
pass # there's nothing we need to do here
21342134

2135+
elif isinstance(chunk, responses.ResponseFileSearchCallCompletedEvent):
2136+
pass # there's nothing we need to do here
2137+
2138+
elif isinstance(chunk, responses.ResponseFileSearchCallSearchingEvent):
2139+
pass # there's nothing we need to do here
2140+
2141+
elif isinstance(chunk, responses.ResponseFileSearchCallInProgressEvent):
2142+
pass # there's nothing we need to do here
2143+
21352144
else: # pragma: no cover
21362145
warnings.warn(
21372146
f'Handling of this event type is not yet implemented. Please report on our GitHub: {chunk}',

tests/json_body_serializer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
FILTERED_HEADER_PREFIXES = ['anthropic-', 'cf-', 'x-']
1717
FILTERED_HEADERS = {'authorization', 'date', 'request-id', 'server', 'user-agent', 'via', 'set-cookie', 'api-key'}
18+
ALLOWED_HEADERS = {'x-goog-upload-url', 'x-goog-upload-status'} # required for test_google_model_file_search_tool
1819

1920

2021
class LiteralDumper(Dumper):
@@ -55,7 +56,9 @@ def serialize(cassette_dict: Any): # pragma: lax no cover
5556
headers = {k: v for k, v in headers.items() if k not in FILTERED_HEADERS}
5657
# filter headers by prefix
5758
headers = {
58-
k: v for k, v in headers.items() if not any(k.startswith(prefix) for prefix in FILTERED_HEADER_PREFIXES)
59+
k: v
60+
for k, v in headers.items()
61+
if not any(k.startswith(prefix) for prefix in FILTERED_HEADER_PREFIXES) or k in ALLOWED_HEADERS
5962
}
6063
# update headers on source object
6164
data['headers'] = headers

tests/models/cassettes/test_google/test_google_model_file_search_tool.yaml

Lines changed: 174 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ interactions:
2626
content-type:
2727
- application/json; charset=UTF-8
2828
server-timing:
29-
- gfet4t7; dur=455
29+
- gfet4t7; dur=373
3030
transfer-encoding:
3131
- chunked
3232
vary:
3333
- Origin
3434
- X-Origin
3535
- Referer
3636
parsed_body:
37-
createTime: '2025-11-14T13:06:44.036465Z'
37+
createTime: '2025-11-20T23:37:08.933211Z'
3838
displayName: test-file-search-store
39-
name: fileSearchStores/testfilesearchstore-yc4nqyu6bkpo
40-
updateTime: '2025-11-14T13:06:44.036465Z'
39+
name: fileSearchStores/testfilesearchstore-s6zmrh92ulpr
40+
updateTime: '2025-11-20T23:37:08.933211Z'
4141
status:
4242
code: 200
4343
message: OK
@@ -58,7 +58,7 @@ interactions:
5858
method: POST
5959
parsed_body:
6060
mimeType: text/plain
61-
uri: https://generativelanguage.googleapis.com/upload/v1beta/fileSearchStores/testfilesearchstore-yc4nqyu6bkpo:uploadToFileSearchStore
61+
uri: https://generativelanguage.googleapis.com/upload/v1beta/fileSearchStores/testfilesearchstore-s6zmrh92ulpr:uploadToFileSearchStore
6262
response:
6363
body:
6464
string: ''
@@ -69,6 +69,10 @@ interactions:
6969
- '0'
7070
content-type:
7171
- text/plain; charset=utf-8
72+
x-goog-upload-status:
73+
- active
74+
x-goog-upload-url:
75+
- https://generativelanguage.googleapis.com/upload/v1beta/fileSearchStores/testfilesearchstore-s6zmrh92ulpr:uploadToFileSearchStore?upload_id=AOCedOHMyp8-WH0roPvEsby85i78ZlUxHR4ZVhKtN6xXYFFUkHedk2H5w7cIOz4M9p4LeWPKM46woeaM3jNrhq6vfgJmt4ds3RnrIiO5LEsa3g&upload_protocol=resumable
7276
status:
7377
code: 200
7478
message: OK
@@ -86,7 +90,7 @@ interactions:
8690
host:
8791
- generativelanguage.googleapis.com
8892
method: POST
89-
uri: https://generativelanguage.googleapis.com/upload/v1beta/fileSearchStores/testfilesearchstore-yc4nqyu6bkpo:uploadToFileSearchStore?upload_id=AOCedOGMFY9IXAkbC4iGTlw4gkakgbCCpXweCb8TJzUJMegDkFGYkygsxUAtdzCgKeOt3GTgFDmt9ynY1SQsUcVSSI2sK2rSi6i8RrGC7y276ls&upload_protocol=resumable
93+
uri: https://generativelanguage.googleapis.com/upload/v1beta/fileSearchStores/testfilesearchstore-s6zmrh92ulpr:uploadToFileSearchStore?upload_id=AOCedOHMyp8-WH0roPvEsby85i78ZlUxHR4ZVhKtN6xXYFFUkHedk2H5w7cIOz4M9p4LeWPKM46woeaM3jNrhq6vfgJmt4ds3RnrIiO5LEsa3g&upload_protocol=resumable
9094
response:
9195
headers:
9296
alt-svc:
@@ -99,13 +103,15 @@ interactions:
99103
- Origin
100104
- X-Origin
101105
- Referer
106+
x-goog-upload-status:
107+
- final
102108
parsed_body:
103-
name: fileSearchStores/testfilesearchstore-yc4nqyu6bkpo/upload/operations/7k9hlotn1ptc-zy3bg6jfttw0
109+
name: fileSearchStores/testfilesearchstore-s6zmrh92ulpr/upload/operations/k742l26km1p8-jjheny21pwon
104110
response:
105111
'@type': type.googleapis.com/google.ai.generativelanguage.v1main.UploadToFileSearchStoreResponse
106-
documentName: fileSearchStores/testfilesearchstore-yc4nqyu6bkpo/documents/7k9hlotn1ptc-zy3bg6jfttw0
112+
documentName: fileSearchStores/testfilesearchstore-s6zmrh92ulpr/documents/k742l26km1p8-jjheny21pwon
107113
mimeType: text/plain
108-
parent: fileSearchStores/testfilesearchstore-yc4nqyu6bkpo
114+
parent: fileSearchStores/testfilesearchstore-s6zmrh92ulpr
109115
sizeBytes: '79'
110116
status:
111117
code: 200
@@ -119,7 +125,7 @@ interactions:
119125
connection:
120126
- keep-alive
121127
content-length:
122-
- '274'
128+
- '344'
123129
content-type:
124130
- application/json
125131
host:
@@ -128,40 +134,186 @@ interactions:
128134
parsed_body:
129135
contents:
130136
- parts:
131-
- text: What is the capital of France according to my files?
137+
- text: What is the capital of France?
132138
role: user
133139
generationConfig:
134140
responseModalities:
135141
- TEXT
142+
systemInstruction:
143+
parts:
144+
- text: You are a helpful assistant.
145+
role: user
146+
tools:
147+
- fileSearch:
148+
file_search_store_names:
149+
- fileSearchStores/testfilesearchstore-s6zmrh92ulpr
150+
uri: https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-pro:generateContent
151+
response:
152+
headers:
153+
alt-svc:
154+
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
155+
content-length:
156+
- '2105'
157+
content-type:
158+
- application/json; charset=UTF-8
159+
server-timing:
160+
- gfet4t7; dur=11428
161+
transfer-encoding:
162+
- chunked
163+
vary:
164+
- Origin
165+
- X-Origin
166+
- Referer
167+
parsed_body:
168+
candidates:
169+
- content:
170+
parts:
171+
- text: |-
172+
The capital of France is Paris.
173+
174+
Paris is a major global center for art, fashion, gastronomy, and culture. A famous landmark in the city is the Eiffel Tower. The city is also known for its 19th-century cityscape, which is crisscrossed by wide boulevards and the River Seine.
175+
role: model
176+
finishReason: STOP
177+
groundingMetadata:
178+
groundingChunks:
179+
- retrievedContext:
180+
fileSearchStore: fileSearchStores/testfilesearchstore-s6zmrh92ulpr
181+
text: Paris is the capital of France. The Eiffel Tower is a famous landmark in Paris.
182+
- retrievedContext:
183+
fileSearchStore: fileSearchStores/testfilesearchstore-s6zmrh92ulpr
184+
text: Paris is the capital of France. The Eiffel Tower is a famous landmark in Paris.
185+
groundingSupports:
186+
- groundingChunkIndices:
187+
- 1
188+
segment:
189+
endIndex: 30
190+
text: The capital of France is Paris
191+
- groundingChunkIndices:
192+
- 1
193+
segment:
194+
endIndex: 156
195+
startIndex: 107
196+
text: A famous landmark in the city is the Eiffel Tower
197+
index: 0
198+
modelVersion: gemini-2.5-pro
199+
responseId: NKYfaZHSO4udqtsP5YSmuAs
200+
usageMetadata:
201+
candidatesTokenCount: 100
202+
promptTokenCount: 15
203+
promptTokensDetails:
204+
- modality: TEXT
205+
tokenCount: 15
206+
thoughtsTokenCount: 879
207+
toolUsePromptTokenCount: 1485
208+
toolUsePromptTokensDetails:
209+
- modality: TEXT
210+
tokenCount: 1485
211+
totalTokenCount: 2479
212+
status:
213+
code: 200
214+
message: OK
215+
- request:
216+
headers:
217+
accept:
218+
- '*/*'
219+
accept-encoding:
220+
- gzip, deflate
221+
connection:
222+
- keep-alive
223+
content-length:
224+
- '738'
225+
content-type:
226+
- application/json
227+
host:
228+
- generativelanguage.googleapis.com
229+
method: POST
230+
parsed_body:
231+
contents:
232+
- parts:
233+
- text: What is the capital of France?
234+
role: user
235+
- parts:
236+
- text: |-
237+
The capital of France is Paris.
238+
239+
Paris is a major global center for art, fashion, gastronomy, and culture. A famous landmark in the city is the Eiffel Tower. The city is also known for its 19th-century cityscape, which is crisscrossed by wide boulevards and the River Seine.
240+
role: model
241+
- parts:
242+
- text: Tell me about the Eiffel Tower.
243+
role: user
244+
generationConfig:
245+
responseModalities:
246+
- TEXT
247+
systemInstruction:
248+
parts:
249+
- text: You are a helpful assistant.
250+
role: user
136251
tools:
137252
- fileSearch:
138253
file_search_store_names:
139-
- fileSearchStores/testfilesearchstore-yc4nqyu6bkpo
254+
- fileSearchStores/testfilesearchstore-s6zmrh92ulpr
140255
uri: https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-pro:generateContent
141256
response:
142257
headers:
143258
alt-svc:
144259
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
145260
content-length:
146-
- '133'
261+
- '2782'
147262
content-type:
148263
- application/json; charset=UTF-8
149264
server-timing:
150-
- gfet4t7; dur=7289
265+
- gfet4t7; dur=8799
151266
transfer-encoding:
152267
- chunked
153268
vary:
154269
- Origin
155270
- X-Origin
156271
- Referer
157272
parsed_body:
158-
error:
159-
code: 503
160-
message: The model is overloaded. Please try again later.
161-
status: UNAVAILABLE
273+
candidates:
274+
- content:
275+
parts:
276+
- text: |-
277+
The Eiffel Tower is a famous landmark located in Paris, the capital of France. It is one of the most recognizable structures in the world.
278+
279+
Here are some key facts about the Eiffel Tower:
280+
281+
* **Construction:** It was designed by the engineer Gustave Eiffel, and his company built it between 1887 and 1889. It was created as the entrance arch for the 1889 Exposition Universelle (World's Fair), which celebrated the 100th anniversary of the French Revolution.
282+
* **Design and Material:** The tower is made of wrought iron and is a masterpiece of structural engineering. Its open-lattice design was innovative for its time and was chosen for its wind resistance and stability.
283+
* **Height:** The Eiffel Tower stands at a height of 330 meters (1,083 feet), including its antennas. For about 41 years, it held the title of the tallest man-made structure in the world until the Chrysler Building in New York City was completed in 1930.
284+
* **Visiting:** The tower has three levels for visitors. The first two levels can be reached by stairs or elevators and feature restaurants and shops. The top level, accessible only by elevator, offers panoramic views of Paris.
285+
* **Cultural Impact:** Initially criticized by some of France's leading artists and intellectuals for its design, the Eiffel Tower has since become a global cultural icon of France and a symbol of Paris itself. It is one of the most visited paid monuments in the world.
286+
role: model
287+
finishReason: STOP
288+
groundingMetadata:
289+
groundingChunks:
290+
- retrievedContext:
291+
fileSearchStore: fileSearchStores/testfilesearchstore-s6zmrh92ulpr
292+
text: Paris is the capital of France. The Eiffel Tower is a famous landmark in Paris.
293+
groundingSupports:
294+
- groundingChunkIndices:
295+
- 0
296+
segment:
297+
endIndex: 78
298+
text: The Eiffel Tower is a famous landmark located in Paris, the capital of France.
299+
index: 0
300+
modelVersion: gemini-2.5-pro
301+
responseId: PqYfadjYC8eHqtsPicvToAs
302+
usageMetadata:
303+
candidatesTokenCount: 339
304+
promptTokenCount: 88
305+
promptTokensDetails:
306+
- modality: TEXT
307+
tokenCount: 88
308+
thoughtsTokenCount: 167
309+
toolUsePromptTokenCount: 270
310+
toolUsePromptTokensDetails:
311+
- modality: TEXT
312+
tokenCount: 270
313+
totalTokenCount: 864
162314
status:
163-
code: 503
164-
message: Service Unavailable
315+
code: 200
316+
message: OK
165317
- request:
166318
body: ''
167319
headers:
@@ -176,7 +328,7 @@ interactions:
176328
host:
177329
- generativelanguage.googleapis.com
178330
method: DELETE
179-
uri: https://generativelanguage.googleapis.com/v1beta/fileSearchStores/testfilesearchstore-yc4nqyu6bkpo?force=True
331+
uri: https://generativelanguage.googleapis.com/v1beta/fileSearchStores/testfilesearchstore-s6zmrh92ulpr?force=True
180332
response:
181333
headers:
182334
alt-svc:
@@ -186,7 +338,7 @@ interactions:
186338
content-type:
187339
- application/json; charset=UTF-8
188340
server-timing:
189-
- gfet4t7; dur=858
341+
- gfet4t7; dur=528
190342
transfer-encoding:
191343
- chunked
192344
vary:

0 commit comments

Comments
 (0)