File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -308,7 +308,6 @@ class Function(SubscriptableBaseModel):
308
308
309
309
class Parameters (SubscriptableBaseModel ):
310
310
model_config = ConfigDict (populate_by_name = True )
311
-
312
311
type : Optional [Literal ['object' ]] = 'object'
313
312
defs : Optional [Any ] = Field (None , alias = '$defs' )
314
313
items : Optional [Any ] = None
@@ -330,6 +329,15 @@ class Property(SubscriptableBaseModel):
330
329
331
330
332
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
+
333
341
messages : Optional [Sequence [Union [Mapping [str , Any ], Message ]]] = None
334
342
'Messages to chat with.'
335
343
You can’t perform that action at this time.
0 commit comments