Spaces:
Sleeping
Sleeping
Update Gradio_UI.py
Browse files- Gradio_UI.py +9 -7
Gradio_UI.py
CHANGED
|
@@ -15,19 +15,21 @@ 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 |
self.get_time_tool = tool
|
| 22 |
-
elif "weather" in
|
| 23 |
self.get_weather_tool = tool
|
| 24 |
-
elif "
|
| 25 |
self.doc_qa_tool = tool
|
| 26 |
-
elif "
|
| 27 |
self.image_gen_tool = tool
|
| 28 |
-
elif "
|
| 29 |
self.search_tool = tool
|
| 30 |
|
|
|
|
| 31 |
# Validate all tools are loaded
|
| 32 |
assert self.get_time_tool, "Missing: get_current_time_in_timezone"
|
| 33 |
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 |
+
func_name = getattr(tool, "__name__", None)
|
| 19 |
+
raw_func_name = getattr(getattr(tool, "fn", None), "__name__", "")
|
| 20 |
+
|
| 21 |
+
if "time" in func_name or "timezone" in raw_func_name:
|
| 22 |
self.get_time_tool = tool
|
| 23 |
+
elif "weather" in func_name or "weather" in raw_func_name:
|
| 24 |
self.get_weather_tool = tool
|
| 25 |
+
elif "document_qna_tool" in func_name or "document_qna_tool" in raw_func_name:
|
| 26 |
self.doc_qa_tool = tool
|
| 27 |
+
elif "image" in func_name or "image" in raw_func_name:
|
| 28 |
self.image_gen_tool = tool
|
| 29 |
+
elif "search" in func_name or "duckduckgo" in raw_func_name:
|
| 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"
|