33import streamlit as st
44from agentic_rag import get_agentic_rag_agent
55from agno .agent import Agent
6+ from agno .models .response import ToolExecution
67from agno .utils .log import logger
78
89
@@ -38,7 +39,7 @@ def export_chat_history():
3839 return ""
3940
4041
41- def display_tool_calls (tool_calls_container , tools ):
42+ def display_tool_calls (tool_calls_container , tools : List [ ToolExecution ] ):
4243 """Display tool calls in a streamlit container with expandable sections.
4344
4445 Args:
@@ -51,19 +52,10 @@ def display_tool_calls(tool_calls_container, tools):
5152 with tool_calls_container .container ():
5253 for tool_call in tools :
5354 # Handle different tool call formats
54- _tool_name = (
55- tool_call .get ("tool_name" ) or tool_call .get ("name" ) or "Unknown Tool"
56- )
57- _tool_args = tool_call .get ("tool_args" ) or tool_call .get ("arguments" ) or {}
58- _content = tool_call .get ("content" ) or tool_call .get ("result" , "" )
59- _metrics = tool_call .get ("metrics" , {})
60-
61- # Handle function objects
62- if hasattr (tool_call , "function" ) and tool_call .function :
63- if hasattr (tool_call .function , "name" ):
64- _tool_name = tool_call .function .name
65- if hasattr (tool_call .function , "arguments" ):
66- _tool_args = tool_call .function .arguments
55+ _tool_name = tool_call .tool_name or "Unknown Tool"
56+ _tool_args = tool_call .tool_args or {}
57+ _content = tool_call .result or ""
58+ _metrics = tool_call .metrics or {}
6759
6860 # Safely create the title with a default if tool name is None
6961 title = f"🛠️ { _tool_name .replace ('_' , ' ' ).title () if _tool_name else 'Tool Call' } "
@@ -101,7 +93,9 @@ def display_tool_calls(tool_calls_container, tools):
10193
10294 if _metrics :
10395 st .markdown ("**Metrics:**" )
104- st .json (_metrics )
96+ st .json (
97+ _metrics if isinstance (_metrics , dict ) else _metrics ._to_dict ()
98+ )
10599
106100
107101def rename_session_widget (agent : Agent ) -> None :
0 commit comments