manuvats commited on
Commit
5d127de
·
verified ·
1 Parent(s): ac9e80b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -19,16 +19,16 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
19
  return "What magic will you build ?"
20
 
21
  @tool
22
- def get_latest_news(topic: str) -> str:
23
- """Get the latest news about a topic
24
  Args:
25
- topic: Name of the topic
26
  """
27
  try:
28
 
29
  search_tool = DuckDuckGoSearchTool(max_results=10)
30
  results = search_tool.forward(
31
- f"""Get the latest news on {topic}"""
32
  )
33
 
34
  if results:
@@ -37,7 +37,7 @@ def get_latest_news(topic: str) -> str:
37
  else:
38
  return "No results found."
39
  except requests.exceptions.RequestException as e:
40
- return f"Error: Failed to fetch image: {str(e)}"
41
  except Exception as e:
42
  return f"Error: An unexpected error occurred: {str(e)}"
43
 
@@ -79,7 +79,7 @@ with open("prompts.yaml", 'r') as stream:
79
 
80
  agent = CodeAgent(
81
  model=model,
82
- tools=[final_answer, get_latest_news, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
83
  max_steps=6,
84
  verbosity_level=1,
85
  grammar=None,
 
19
  return "What magic will you build ?"
20
 
21
  @tool
22
+ def get_trending_topic(country: str) -> str:
23
+ """Get the most trending topic in a country
24
  Args:
25
+ country: Name of the country
26
  """
27
  try:
28
 
29
  search_tool = DuckDuckGoSearchTool(max_results=10)
30
  results = search_tool.forward(
31
+ f"""Get the most trending topic in the {country}"""
32
  )
33
 
34
  if results:
 
37
  else:
38
  return "No results found."
39
  except requests.exceptions.RequestException as e:
40
+ return f"Error: Failed to fetch any topic: {str(e)}"
41
  except Exception as e:
42
  return f"Error: An unexpected error occurred: {str(e)}"
43
 
 
79
 
80
  agent = CodeAgent(
81
  model=model,
82
+ tools=[final_answer, get_trending_topic, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
83
  max_steps=6,
84
  verbosity_level=1,
85
  grammar=None,