@@ -54,13 +54,17 @@ class FunctionCallingMessage(BaseMessage):
5454 mask_output (Optional[bool]): Whether to return a sanitized placeholder
5555 instead of the raw tool output.
5656 (default: :obj:`False`)
57+ extra_content (Optional[Dict[str, Any]]): Additional content
58+ associated with the tool call.
59+ (default: :obj:`None`)
5760 """
5861
5962 func_name : Optional [str ] = None
6063 args : Optional [Dict ] = None
6164 result : Optional [Any ] = None
6265 tool_call_id : Optional [str ] = None
6366 mask_output : Optional [bool ] = False
67+ extra_content : Optional [Dict [str , Any ]] = None
6468
6569 @classmethod
6670 def make_tool_message (
@@ -147,19 +151,23 @@ def to_openai_assistant_message(self) -> OpenAIAssistantMessage:
147151 " due to missing function name or arguments."
148152 )
149153
154+ tool_call = {
155+ "id" : self .tool_call_id or "null" ,
156+ "type" : "function" ,
157+ "function" : {
158+ "name" : self .func_name ,
159+ "arguments" : json .dumps (self .args , ensure_ascii = False ),
160+ },
161+ }
162+
163+ # Include extra_content if available
164+ if self .extra_content is not None :
165+ tool_call ["extra_content" ] = self .extra_content
166+
150167 return {
151168 "role" : "assistant" ,
152169 "content" : self .content or "" ,
153- "tool_calls" : [
154- {
155- "id" : self .tool_call_id or "null" ,
156- "type" : "function" ,
157- "function" : {
158- "name" : self .func_name ,
159- "arguments" : json .dumps (self .args , ensure_ascii = False ),
160- },
161- }
162- ],
170+ "tool_calls" : [tool_call ], # type: ignore[list-item]
163171 }
164172
165173 def to_openai_tool_message (self ) -> OpenAIToolMessageParam :
@@ -203,4 +211,6 @@ def to_dict(self) -> Dict:
203211 if self .tool_call_id is not None :
204212 base ["tool_call_id" ] = self .tool_call_id
205213 base ["mask_output" ] = self .mask_output
214+ if self .extra_content is not None :
215+ base ["extra_content" ] = self .extra_content
206216 return base
0 commit comments