CalebMaresca commited on
Commit
93152b2
·
verified ·
1 Parent(s): 279219a

Add simple web browser tool

Browse files
Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -18,6 +18,20 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
18
  """
19
  return "What magic will you build ?"
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
23
  """A tool that fetches the current local time in a specified timezone.
@@ -56,7 +70,7 @@ with open("prompts.yaml", 'r') as stream:
56
 
57
  agent = CodeAgent(
58
  model=model,
59
- tools=[final_answer, duck_duck_go_search], ## add your tools here (don't remove final answer)
60
  max_steps=6,
61
  verbosity_level=1,
62
  grammar=None,
 
18
  """
19
  return "What magic will you build ?"
20
 
21
+ @tool
22
+ def web_browser_tool(url: str) -> str:
23
+ """A tool that fetches and returns the content of a webpage
24
+
25
+ Args:
26
+ url: The URL of the webpage to fetch
27
+ """
28
+ try:
29
+ response = requests.get(url)
30
+ response.raise_for_status()
31
+ return response.text
32
+ except Exception as e:
33
+ return f"Error fetching webpage: {str(e)}"
34
+
35
  @tool
36
  def get_current_time_in_timezone(timezone: str) -> str:
37
  """A tool that fetches the current local time in a specified timezone.
 
70
 
71
  agent = CodeAgent(
72
  model=model,
73
+ tools=[final_answer, duck_duck_go_search, web_browser_tool], ## add your tools here (don't remove final answer)
74
  max_steps=6,
75
  verbosity_level=1,
76
  grammar=None,