File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -221,6 +221,14 @@ async def tool_call_handler(tool_call):
221221 except Exception as e :
222222 tool_result = str (e )
223223
224+ tool_result_files = []
225+ if isinstance (tool_result , list ):
226+ for item in tool_result :
227+ # check if string
228+ if isinstance (item , str ) and item .startswith ("data:" ):
229+ tool_result_files .append (item )
230+ tool_result .remove (item )
231+
224232 if isinstance (tool_result , dict ) or isinstance (tool_result , list ):
225233 tool_result = json .dumps (tool_result , indent = 2 )
226234
@@ -240,7 +248,7 @@ async def tool_call_handler(tool_call):
240248 else f"{ tool_function_name } "
241249 ),
242250 },
243- "document" : [tool_result ],
251+ "document" : [tool_result , * tool_result_files ],
244252 "metadata" : [
245253 {
246254 "source" : (
@@ -256,7 +264,7 @@ async def tool_call_handler(tool_call):
256264 sources .append (
257265 {
258266 "source" : {},
259- "document" : [tool_result ],
267+ "document" : [tool_result , * tool_result_files ],
260268 "metadata" : [
261269 {
262270 "source" : (
You can’t perform that action at this time.
0 commit comments