Skip to content

Commit 11ca423

Browse files
authored
Drop exclusiveMaximum/exclusiveMinimum from Gemini (#1341)
1 parent 6d5ccac commit 11ca423

File tree

4 files changed

+503
-0
lines changed

4 files changed

+503
-0
lines changed

pydantic_ai_slim/pydantic_ai/models/gemini.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,8 @@ def simplify(self) -> dict[str, Any]:
770770
def _simplify(self, schema: dict[str, Any], refs_stack: tuple[str, ...]) -> None:
771771
schema.pop('title', None)
772772
schema.pop('default', None)
773+
schema.pop('exclusiveMaximum', None)
774+
schema.pop('exclusiveMinimum', None)
773775
if ref := schema.pop('$ref', None):
774776
# noinspection PyTypeChecker
775777
key = re.sub(r'^#/\$defs/', '', ref)
Lines changed: 326 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,326 @@
1+
interactions:
2+
- request:
3+
headers:
4+
accept:
5+
- '*/*'
6+
accept-encoding:
7+
- gzip, deflate
8+
connection:
9+
- keep-alive
10+
content-length:
11+
- '277'
12+
content-type:
13+
- application/json
14+
host:
15+
- generativelanguage.googleapis.com
16+
method: POST
17+
parsed_body:
18+
contents:
19+
- parts:
20+
- text: I want to know my chinese zodiac. I am 20 years old.
21+
role: user
22+
tools:
23+
function_declarations:
24+
- description: ''
25+
name: get_chinese_zodiac
26+
parameters:
27+
properties:
28+
age:
29+
type: integer
30+
required:
31+
- age
32+
type: object
33+
uri: https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent
34+
response:
35+
headers:
36+
alt-svc:
37+
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
38+
content-length:
39+
- '734'
40+
content-type:
41+
- application/json; charset=UTF-8
42+
server-timing:
43+
- gfet4t7; dur=477
44+
transfer-encoding:
45+
- chunked
46+
vary:
47+
- Origin
48+
- X-Origin
49+
- Referer
50+
parsed_body:
51+
candidates:
52+
- avgLogprobs: 3.357185050845146e-06
53+
content:
54+
parts:
55+
- functionCall:
56+
args:
57+
age: 20
58+
name: get_chinese_zodiac
59+
role: model
60+
finishReason: STOP
61+
modelVersion: gemini-2.0-flash
62+
usageMetadata:
63+
candidatesTokenCount: 7
64+
candidatesTokensDetails:
65+
- modality: TEXT
66+
tokenCount: 7
67+
promptTokenCount: 24
68+
promptTokensDetails:
69+
- modality: TEXT
70+
tokenCount: 24
71+
totalTokenCount: 31
72+
status:
73+
code: 200
74+
message: OK
75+
- request:
76+
headers:
77+
accept:
78+
- '*/*'
79+
accept-encoding:
80+
- gzip, deflate
81+
connection:
82+
- keep-alive
83+
content-length:
84+
- '483'
85+
content-type:
86+
- application/json
87+
host:
88+
- generativelanguage.googleapis.com
89+
method: POST
90+
parsed_body:
91+
contents:
92+
- parts:
93+
- text: I want to know my chinese zodiac. I am 20 years old.
94+
role: user
95+
- parts:
96+
- functionCall:
97+
args:
98+
age: 20
99+
name: get_chinese_zodiac
100+
role: model
101+
- parts:
102+
- functionResponse:
103+
name: get_chinese_zodiac
104+
response:
105+
return_value: Dragon
106+
role: user
107+
tools:
108+
function_declarations:
109+
- description: ''
110+
name: get_chinese_zodiac
111+
parameters:
112+
properties:
113+
age:
114+
type: integer
115+
required:
116+
- age
117+
type: object
118+
uri: https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent
119+
response:
120+
headers:
121+
alt-svc:
122+
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
123+
content-length:
124+
- '636'
125+
content-type:
126+
- application/json; charset=UTF-8
127+
server-timing:
128+
- gfet4t7; dur=461
129+
transfer-encoding:
130+
- chunked
131+
vary:
132+
- Origin
133+
- X-Origin
134+
- Referer
135+
parsed_body:
136+
candidates:
137+
- avgLogprobs: -2.039197300161634e-06
138+
content:
139+
parts:
140+
- text: |
141+
Your Chinese zodiac is Dragon.
142+
role: model
143+
finishReason: STOP
144+
modelVersion: gemini-2.0-flash
145+
usageMetadata:
146+
candidatesTokenCount: 7
147+
candidatesTokensDetails:
148+
- modality: TEXT
149+
tokenCount: 7
150+
promptTokenCount: 41
151+
promptTokensDetails:
152+
- modality: TEXT
153+
tokenCount: 41
154+
totalTokenCount: 48
155+
status:
156+
code: 200
157+
message: OK
158+
- request:
159+
headers:
160+
accept:
161+
- '*/*'
162+
accept-encoding:
163+
- gzip, deflate
164+
connection:
165+
- keep-alive
166+
content-length:
167+
- '277'
168+
content-type:
169+
- application/json
170+
host:
171+
- generativelanguage.googleapis.com
172+
method: POST
173+
parsed_body:
174+
contents:
175+
- parts:
176+
- text: I want to know my chinese zodiac. I am 17 years old.
177+
role: user
178+
tools:
179+
function_declarations:
180+
- description: ''
181+
name: get_chinese_zodiac
182+
parameters:
183+
properties:
184+
age:
185+
type: integer
186+
required:
187+
- age
188+
type: object
189+
uri: https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent
190+
response:
191+
headers:
192+
alt-svc:
193+
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
194+
content-length:
195+
- '734'
196+
content-type:
197+
- application/json; charset=UTF-8
198+
server-timing:
199+
- gfet4t7; dur=440
200+
transfer-encoding:
201+
- chunked
202+
vary:
203+
- Origin
204+
- X-Origin
205+
- Referer
206+
parsed_body:
207+
candidates:
208+
- avgLogprobs: 2.7694373524614742e-06
209+
content:
210+
parts:
211+
- functionCall:
212+
args:
213+
age: 17
214+
name: get_chinese_zodiac
215+
role: model
216+
finishReason: STOP
217+
modelVersion: gemini-2.0-flash
218+
usageMetadata:
219+
candidatesTokenCount: 7
220+
candidatesTokensDetails:
221+
- modality: TEXT
222+
tokenCount: 7
223+
promptTokenCount: 24
224+
promptTokensDetails:
225+
- modality: TEXT
226+
tokenCount: 24
227+
totalTokenCount: 31
228+
status:
229+
code: 200
230+
message: OK
231+
- request:
232+
headers:
233+
accept:
234+
- '*/*'
235+
accept-encoding:
236+
- gzip, deflate
237+
connection:
238+
- keep-alive
239+
content-length:
240+
- '685'
241+
content-type:
242+
- application/json
243+
host:
244+
- generativelanguage.googleapis.com
245+
method: POST
246+
parsed_body:
247+
contents:
248+
- parts:
249+
- text: I want to know my chinese zodiac. I am 17 years old.
250+
role: user
251+
- parts:
252+
- functionCall:
253+
args:
254+
age: 17
255+
name: get_chinese_zodiac
256+
role: model
257+
- parts:
258+
- functionResponse:
259+
name: get_chinese_zodiac
260+
response:
261+
call_error: |-
262+
1 validation errors: [
263+
{
264+
"type": "greater_than",
265+
"loc": [
266+
"age"
267+
],
268+
"msg": "Input should be greater than 18",
269+
"input": 17
270+
}
271+
]
272+
273+
Fix the errors and try again.
274+
role: user
275+
tools:
276+
function_declarations:
277+
- description: ''
278+
name: get_chinese_zodiac
279+
parameters:
280+
properties:
281+
age:
282+
type: integer
283+
required:
284+
- age
285+
type: object
286+
uri: https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent
287+
response:
288+
headers:
289+
alt-svc:
290+
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
291+
content-length:
292+
- '688'
293+
content-type:
294+
- application/json; charset=UTF-8
295+
server-timing:
296+
- gfet4t7; dur=442
297+
transfer-encoding:
298+
- chunked
299+
vary:
300+
- Origin
301+
- X-Origin
302+
- Referer
303+
parsed_body:
304+
candidates:
305+
- avgLogprobs: -0.09825141863389449
306+
content:
307+
parts:
308+
- text: |
309+
I am sorry, I cannot fulfill this request. The age needs to be greater than 18.
310+
role: model
311+
finishReason: STOP
312+
modelVersion: gemini-2.0-flash
313+
usageMetadata:
314+
candidatesTokenCount: 22
315+
candidatesTokensDetails:
316+
- modality: TEXT
317+
tokenCount: 22
318+
promptTokenCount: 108
319+
promptTokensDetails:
320+
- modality: TEXT
321+
tokenCount: 108
322+
totalTokenCount: 130
323+
status:
324+
code: 200
325+
message: OK
326+
version: 1

0 commit comments

Comments
 (0)