@@ -307,15 +307,19 @@ class Function(SubscriptableBaseModel):
307
307
description : Optional [str ] = None
308
308
309
309
class Parameters (SubscriptableBaseModel ):
310
+ model_config = ConfigDict (populate_by_name = True )
310
311
type : Optional [Literal ['object' ]] = 'object'
312
+ defs : Optional [Any ] = Field (None , alias = '$defs' )
313
+ items : Optional [Any ] = None
311
314
required : Optional [Sequence [str ]] = None
312
315
313
316
class Property (SubscriptableBaseModel ):
314
317
model_config = ConfigDict (arbitrary_types_allowed = True )
315
318
316
319
type : Optional [Union [str , Sequence [str ]]] = None
320
+ items : Optional [Any ] = None
317
321
description : Optional [str ] = None
318
- enum : Optional [Sequence ] = None
322
+ enum : Optional [Sequence [ Any ] ] = None
319
323
320
324
properties : Optional [Mapping [str , Property ]] = None
321
325
@@ -325,6 +329,15 @@ class Property(SubscriptableBaseModel):
325
329
326
330
327
331
class ChatRequest (BaseGenerateRequest ):
332
+ @model_serializer (mode = 'wrap' )
333
+ def serialize_model (self , nxt ):
334
+ output = nxt (self )
335
+ if 'tools' in output and output ['tools' ]:
336
+ for tool in output ['tools' ]:
337
+ if 'function' in tool and 'parameters' in tool ['function' ] and 'defs' in tool ['function' ]['parameters' ]:
338
+ tool ['function' ]['parameters' ]['$defs' ] = tool ['function' ]['parameters' ].pop ('defs' )
339
+ return output
340
+
328
341
messages : Optional [Sequence [Union [Mapping [str , Any ], Message ]]] = None
329
342
'Messages to chat with.'
330
343
0 commit comments