@@ -50,13 +50,17 @@ class FunctionCallingMessage(BaseMessage):
5050 mask_output (Optional[bool]): Whether to return a sanitized placeholder
5151 instead of the raw tool output.
5252 (default: :obj:`False`)
53+ extra_content (Optional[Dict[str, Any]]): Additional content
54+ associated with the tool call.
55+ (default: :obj:`None`)
5356 """
5457
5558 func_name : Optional [str ] = None
5659 args : Optional [Dict ] = None
5760 result : Optional [Any ] = None
5861 tool_call_id : Optional [str ] = None
5962 mask_output : Optional [bool ] = False
63+ extra_content : Optional [Dict [str , Any ]] = None
6064
6165 def to_openai_message (
6266 self ,
@@ -131,19 +135,23 @@ def to_openai_assistant_message(self) -> OpenAIAssistantMessage:
131135 " due to missing function name or arguments."
132136 )
133137
138+ tool_call = {
139+ "id" : self .tool_call_id or "null" ,
140+ "type" : "function" ,
141+ "function" : {
142+ "name" : self .func_name ,
143+ "arguments" : json .dumps (self .args , ensure_ascii = False ),
144+ },
145+ }
146+
147+ # Include extra_content if available
148+ if self .extra_content is not None :
149+ tool_call ["extra_content" ] = self .extra_content
150+
134151 return {
135152 "role" : "assistant" ,
136153 "content" : self .content or "" ,
137- "tool_calls" : [
138- {
139- "id" : self .tool_call_id or "null" ,
140- "type" : "function" ,
141- "function" : {
142- "name" : self .func_name ,
143- "arguments" : json .dumps (self .args , ensure_ascii = False ),
144- },
145- }
146- ],
154+ "tool_calls" : [tool_call ], # type: ignore[list-item]
147155 }
148156
149157 def to_openai_tool_message (self ) -> OpenAIToolMessageParam :
@@ -187,4 +195,6 @@ def to_dict(self) -> Dict:
187195 if self .tool_call_id is not None :
188196 base ["tool_call_id" ] = self .tool_call_id
189197 base ["mask_output" ] = self .mask_output
198+ if self .extra_content is not None :
199+ base ["extra_content" ] = self .extra_content
190200 return base
0 commit comments