Spaces:
Sleeping
Sleeping
Update Gradio_UI.py
Browse files- Gradio_UI.py +9 -8
Gradio_UI.py
CHANGED
|
@@ -15,21 +15,22 @@ class GradioUI:
|
|
| 15 |
tools = agent.tools if isinstance(agent.tools, (list, tuple)) else list(agent.tools)
|
| 16 |
|
| 17 |
for tool in tools:
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
if "
|
| 22 |
self.get_time_tool = tool
|
| 23 |
-
elif "weather" in
|
| 24 |
self.get_weather_tool = tool
|
| 25 |
-
elif "document_qna_tool" in
|
| 26 |
self.doc_qa_tool = tool
|
| 27 |
-
elif "image" in
|
| 28 |
self.image_gen_tool = tool
|
| 29 |
-
elif "
|
| 30 |
self.search_tool = tool
|
| 31 |
|
| 32 |
-
|
| 33 |
# Validate all tools are loaded
|
| 34 |
assert self.get_time_tool, "Missing: get_current_time_in_timezone"
|
| 35 |
assert self.get_weather_tool, "Missing: get_current_weather"
|
|
|
|
| 15 |
tools = agent.tools if isinstance(agent.tools, (list, tuple)) else list(agent.tools)
|
| 16 |
|
| 17 |
for tool in tools:
|
| 18 |
+
# Get raw function name if possible
|
| 19 |
+
raw_func = getattr(tool, "fn", None)
|
| 20 |
+
raw_func_name = getattr(raw_func, "__name__", "").lower()
|
| 21 |
+
tool_str = str(tool).lower()
|
| 22 |
|
| 23 |
+
if "timezone" in raw_func_name or "get_current_time_in_timezone" in raw_func_name:
|
| 24 |
self.get_time_tool = tool
|
| 25 |
+
elif "weather" in raw_func_name or "get_current_weather" in raw_func_name:
|
| 26 |
self.get_weather_tool = tool
|
| 27 |
+
elif "document_qna_tool" in raw_func_name:
|
| 28 |
self.doc_qa_tool = tool
|
| 29 |
+
elif "text-to-image" in tool_str or "image" in raw_func_name:
|
| 30 |
self.image_gen_tool = tool
|
| 31 |
+
elif "duckduckgo" in tool_str or "search" in raw_func_name:
|
| 32 |
self.search_tool = tool
|
| 33 |
|
|
|
|
| 34 |
# Validate all tools are loaded
|
| 35 |
assert self.get_time_tool, "Missing: get_current_time_in_timezone"
|
| 36 |
assert self.get_weather_tool, "Missing: get_current_weather"
|