SamarthPujari commited on
Commit
c889709
·
verified ·
1 Parent(s): 41a8e13

Update Gradio_UI.py

Browse files
Files changed (1) hide show
  1. 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
- # Match tools based on description (from docstring) or fallback string
19
- desc = getattr(tool, "description", "") or str(tool)
20
- if "current local time" in desc or "timezone" in desc:
 
21
  self.get_time_tool = tool
22
- elif "weather" in desc.lower():
23
  self.get_weather_tool = tool
24
- elif "question" in desc.lower() and "pdf" in desc.lower():
25
  self.doc_qa_tool = tool
26
- elif "text-to-image" in desc.lower() or "image" in str(tool).lower():
27
  self.image_gen_tool = tool
28
- elif "duckduckgo" in str(tool).lower() or "search" in desc.lower():
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"