@@ -164,9 +164,17 @@ async def test_require_response_tool(allow_model_requests: None):
164
164
165
165
166
166
async def test_json_def_replaced (allow_model_requests : None ):
167
+ class Axis (BaseModel ):
168
+ label : str
169
+
170
+ class Chart (BaseModel ):
171
+ x_axis : Axis
172
+ y_axis : Axis
173
+
167
174
class Location (BaseModel ):
168
175
lat : float
169
176
lng : float = 1.1
177
+ chart : Chart
170
178
171
179
class Locations (BaseModel ):
172
180
locations : list [Location ]
@@ -175,15 +183,28 @@ class Locations(BaseModel):
175
183
assert json_schema == snapshot (
176
184
{
177
185
'$defs' : {
186
+ 'Axis' : {
187
+ 'properties' : {'label' : {'title' : 'Label' , 'type' : 'string' }},
188
+ 'required' : ['label' ],
189
+ 'title' : 'Axis' ,
190
+ 'type' : 'object' ,
191
+ },
192
+ 'Chart' : {
193
+ 'properties' : {'x_axis' : {'$ref' : '#/$defs/Axis' }, 'y_axis' : {'$ref' : '#/$defs/Axis' }},
194
+ 'required' : ['x_axis' , 'y_axis' ],
195
+ 'title' : 'Chart' ,
196
+ 'type' : 'object' ,
197
+ },
178
198
'Location' : {
179
199
'properties' : {
180
200
'lat' : {'title' : 'Lat' , 'type' : 'number' },
181
201
'lng' : {'default' : 1.1 , 'title' : 'Lng' , 'type' : 'number' },
202
+ 'chart' : {'$ref' : '#/$defs/Chart' },
182
203
},
183
- 'required' : ['lat' ],
204
+ 'required' : ['lat' , 'chart' ],
184
205
'title' : 'Location' ,
185
206
'type' : 'object' ,
186
- }
207
+ },
187
208
},
188
209
'properties' : {'locations' : {'items' : {'$ref' : '#/$defs/Location' }, 'title' : 'Locations' , 'type' : 'array' }},
189
210
'required' : ['locations' ],
@@ -201,20 +222,36 @@ class Locations(BaseModel):
201
222
mrp = ModelRequestParameters (function_tools = [], allow_text_output = True , output_tools = [output_tool ])
202
223
mrp = m .customize_request_parameters (mrp )
203
224
assert m ._get_tools (mrp ) == snapshot (
204
- _GeminiTools (
205
- function_declarations = [
206
- _GeminiFunction (
207
- name = 'result' ,
208
- description = 'This is the tool for the final Result' ,
209
- parameters = {
225
+ {
226
+ ' function_declarations' : [
227
+ {
228
+ ' name' : 'result' ,
229
+ ' description' : 'This is the tool for the final Result' ,
230
+ ' parameters' : {
210
231
'properties' : {
211
232
'locations' : {
212
233
'items' : {
213
234
'properties' : {
214
235
'lat' : {'type' : 'number' },
215
236
'lng' : {'type' : 'number' },
237
+ 'chart' : {
238
+ 'properties' : {
239
+ 'x_axis' : {
240
+ 'properties' : {'label' : {'type' : 'string' }},
241
+ 'required' : ['label' ],
242
+ 'type' : 'object' ,
243
+ },
244
+ 'y_axis' : {
245
+ 'properties' : {'label' : {'type' : 'string' }},
246
+ 'required' : ['label' ],
247
+ 'type' : 'object' ,
248
+ },
249
+ },
250
+ 'required' : ['x_axis' , 'y_axis' ],
251
+ 'type' : 'object' ,
252
+ },
216
253
},
217
- 'required' : ['lat' ],
254
+ 'required' : ['lat' , 'chart' ],
218
255
'type' : 'object' ,
219
256
},
220
257
'type' : 'array' ,
@@ -223,9 +260,9 @@ class Locations(BaseModel):
223
260
'required' : ['locations' ],
224
261
'type' : 'object' ,
225
262
},
226
- )
263
+ }
227
264
]
228
- )
265
+ }
229
266
)
230
267
231
268
0 commit comments