Siqi commited on
Commit
7ee7d4a
·
1 Parent(s): 33d4d05

Update tools

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -19,12 +19,25 @@ def my_search_tool(search_query: str) -> str:
19
  try:
20
  if not search_query or not search_query.strip():
21
  search_query = "latest popular arxiv papers in reinforcement learning"
22
- result = _search_tool.run(search_query=search_query)
23
  except Exception as e:
24
  result = f"An error occurred while performing the search, error: {e}."
25
  print(f"Error occurred: {e}")
26
  return result
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  @tool
29
  def get_current_time_in_timezone(timezone: str) -> str:
30
  """A tool that fetches the current local time in a specified timezone.
@@ -62,7 +75,7 @@ with open("prompts.yaml", 'r') as stream:
62
 
63
  agent = CodeAgent(
64
  model=model,
65
- tools=[final_answer, my_search_tool, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
66
  max_steps=6,
67
  verbosity_level=1,
68
  grammar=None,
 
19
  try:
20
  if not search_query or not search_query.strip():
21
  search_query = "latest popular arxiv papers in reinforcement learning"
22
+ result = _search_tool(search_query)
23
  except Exception as e:
24
  result = f"An error occurred while performing the search, error: {e}."
25
  print(f"Error occurred: {e}")
26
  return result
27
 
28
+ @tool
29
+ def get_weather(city: str) -> str:
30
+ """Get the current weather for a city.
31
+ Args:
32
+ city: the name of the city (e.g., 'London', 'Shanghai')
33
+ """
34
+ try:
35
+ response = requests.get(f"https://wttr.in/{city}?format=3", timeout=5)
36
+ response.raise_for_status()
37
+ return response.text.strip()
38
+ except Exception as e:
39
+ return f"Error fetching weather for '{city}': {e}"
40
+
41
  @tool
42
  def get_current_time_in_timezone(timezone: str) -> str:
43
  """A tool that fetches the current local time in a specified timezone.
 
75
 
76
  agent = CodeAgent(
77
  model=model,
78
+ tools=[final_answer, my_search_tool, get_weather, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
79
  max_steps=6,
80
  verbosity_level=1,
81
  grammar=None,