linas-p commited on
Commit
bc320f6
·
verified ·
1 Parent(s): aa19db2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -33,7 +33,20 @@ def get_current_time_in_timezone(timezone: str) -> str:
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
 
 
 
 
 
 
 
 
 
 
36
 
 
 
 
37
  final_answer = FinalAnswerTool()
38
 
39
  # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
@@ -56,7 +69,8 @@ with open("prompts.yaml", 'r') as stream:
56
 
57
  agent = CodeAgent(
58
  model=model,
59
- tools=[final_answer, search_tool, image_generation_tool], ## add your tools here (don't remove final answer)
 
60
  max_steps=6,
61
  verbosity_level=1,
62
  grammar=None,
 
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
36
+ @tool
37
+ def get_recent_news(description: str) -> str:
38
+ """A tool that fetches the recent news on given topic.
39
+ Args:
40
+ timezone: A string representing a valid recent news (e.g., 'news/sports').
41
+ """
42
+ try:
43
+ search_tool = DuckDuckGoSearchTool()
44
+ search_results = search_tool(description)
45
+ return search_results
46
 
47
+ except Exception as e:
48
+ return f"Error fetching the news '{timezone}': {str(e)}"
49
+
50
  final_answer = FinalAnswerTool()
51
 
52
  # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
 
69
 
70
  agent = CodeAgent(
71
  model=model,
72
+ tools=[final_answer, search_tool, image_generation_tool,
73
+ get_current_time_in_timezone, get_recent_news], ## add your tools here (don't remove final answer)
74
  max_steps=6,
75
  verbosity_level=1,
76
  grammar=None,