alfulanny commited on
Commit
8da2155
·
verified ·
1 Parent(s): dbef2be

Update code_agent.py

Browse files
Files changed (1) hide show
  1. code_agent.py +27 -1
code_agent.py CHANGED
@@ -77,11 +77,37 @@ def make_code_agent(
77
  tools.append(DuckDuckGoSearchTool())
78
  except Exception as e:
79
  logger.debug("DuckDuckGoSearchTool unavailable: %s", e)
 
 
 
 
 
 
 
 
80
 
81
  try:
82
- tools.append(VisitWebpageTool())
 
 
 
 
 
 
 
 
83
  except Exception as e:
84
  logger.debug("VisitWebpageTool unavailable: %s", e)
 
 
 
 
 
 
 
 
 
 
85
 
86
  try:
87
  tools.append(FinalAnswerTool())
 
77
  tools.append(DuckDuckGoSearchTool())
78
  except Exception as e:
79
  logger.debug("DuckDuckGoSearchTool unavailable: %s", e)
80
+
81
+ # Also try to add our custom duckduckgo_search_tool for explicit interpreter access
82
+ try:
83
+ from tools import duckduckgo_search_tool
84
+ tools.append(duckduckgo_search_tool)
85
+ logger.info("Registered local tools.duckduckgo_search_tool for agent")
86
+ except Exception:
87
+ logger.debug("No local duckduckgo_search_tool available")
88
 
89
  try:
90
+ # Prefer the local `visit_page_tool` from our `browser_tools` which
91
+ # avoids extra dependencies that the smolagents VisitWebpageTool may require
92
+ try:
93
+ from browser_tools import visit_page_tool
94
+ tools.append(visit_page_tool)
95
+ logger.info("Using local browser_tools.visit_page_tool for webpage visits")
96
+ except Exception:
97
+ tools.append(VisitWebpageTool())
98
+ logger.info("Using smolagents.VisitWebpageTool for webpage visits")
99
  except Exception as e:
100
  logger.debug("VisitWebpageTool unavailable: %s", e)
101
+ # Try to add our wikipedia_search_tool (if present) so the agent can call it
102
+ try:
103
+ try:
104
+ from tools import wikipedia_search_tool
105
+ tools.append(wikipedia_search_tool)
106
+ logger.info("Registered local tools.wikipedia_search_tool for agent")
107
+ except Exception:
108
+ logger.debug("No local wikipedia_search_tool available, relying on built-in web tools")
109
+ except Exception:
110
+ pass
111
 
112
  try:
113
  tools.append(FinalAnswerTool())