Spaces:
Sleeping
Sleeping
Update Gradio_UI.py
Browse files- Gradio_UI.py +22 -23
Gradio_UI.py
CHANGED
|
@@ -11,29 +11,28 @@ class GradioUI:
|
|
| 11 |
self.search_tool = None
|
| 12 |
self.doc_qa_tool = None
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
self.image_gen_tool
|
| 35 |
-
self.search_tool
|
| 36 |
-
self.doc_qa_tool = self.doc_qa_tool or self.agent.tools[4]
|
| 37 |
|
| 38 |
def launch(self):
|
| 39 |
with gr.Blocks() as demo:
|
|
|
|
| 11 |
self.search_tool = None
|
| 12 |
self.doc_qa_tool = None
|
| 13 |
|
| 14 |
+
# Try to detect tool types from dictionary-like access
|
| 15 |
+
tools = getattr(agent, "tools", {})
|
| 16 |
+
|
| 17 |
+
for tool in tools.values(): # ✅ Use `.values()` instead of indexing
|
| 18 |
+
tool_name = getattr(tool, "__name__", None)
|
| 19 |
+
if tool_name == "get_current_time_in_timezone":
|
| 20 |
+
self.get_time_tool = tool
|
| 21 |
+
elif tool_name == "get_current_weather":
|
| 22 |
+
self.get_weather_tool = tool
|
| 23 |
+
elif tool_name == "document_qna_tool":
|
| 24 |
+
self.doc_qa_tool = tool
|
| 25 |
+
elif "text-to-image" in str(tool):
|
| 26 |
+
self.image_gen_tool = tool
|
| 27 |
+
elif "DuckDuckGoSearchTool" in str(tool):
|
| 28 |
+
self.search_tool = tool
|
| 29 |
+
|
| 30 |
+
# Optional fallback with warnings
|
| 31 |
+
assert self.get_time_tool, "Missing: get_current_time_in_timezone"
|
| 32 |
+
assert self.get_weather_tool, "Missing: get_current_weather"
|
| 33 |
+
assert self.doc_qa_tool, "Missing: document_qna_tool"
|
| 34 |
+
assert self.image_gen_tool, "Missing: image generation tool"
|
| 35 |
+
assert self.search_tool, "Missing: search tool"
|
|
|
|
| 36 |
|
| 37 |
def launch(self):
|
| 38 |
with gr.Blocks() as demo:
|