@@ -307,15 +307,19 @@ class Function(SubscriptableBaseModel):
307307 description : Optional [str ] = None
308308
309309 class Parameters (SubscriptableBaseModel ):
310+ model_config = ConfigDict (populate_by_name = True )
310311 type : Optional [Literal ['object' ]] = 'object'
312+ defs : Optional [Any ] = Field (None , alias = '$defs' )
313+ items : Optional [Any ] = None
311314 required : Optional [Sequence [str ]] = None
312315
313316 class Property (SubscriptableBaseModel ):
314317 model_config = ConfigDict (arbitrary_types_allowed = True )
315318
316319 type : Optional [Union [str , Sequence [str ]]] = None
320+ items : Optional [Any ] = None
317321 description : Optional [str ] = None
318- enum : Optional [Sequence ] = None
322+ enum : Optional [Sequence [ Any ] ] = None
319323
320324 properties : Optional [Mapping [str , Property ]] = None
321325
@@ -325,6 +329,15 @@ class Property(SubscriptableBaseModel):
325329
326330
327331class 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+
328341 messages : Optional [Sequence [Union [Mapping [str , Any ], Message ]]] = None
329342 'Messages to chat with.'
330343
0 commit comments