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

Update Gradio_UI.py

Browse files
Files changed (1) hide show
  1. 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
- 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"
 
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"