rezzie-rich commited on
Commit
57a9fad
·
verified ·
1 Parent(s): ae7a494

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -1
app.py CHANGED
@@ -18,6 +18,28 @@ 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.
@@ -55,7 +77,7 @@ with open("prompts.yaml", 'r') as stream:
55
 
56
  agent = CodeAgent(
57
  model=model,
58
- tools=[final_answer], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,
 
18
  """
19
  return "What magic will you build ?"
20
 
21
+ @tool
22
+ def fetch_latest_info(query: str, max_results: int = 5) -> str:
23
+ """Fetches the latest information using DuckDuckGo's search engine.
24
+
25
+ Args:
26
+ query: The search query string.
27
+ max_results: The maximum number of search results to retrieve.
28
+
29
+ Returns:
30
+ A formatted string containing the titles and URLs of the top search results.
31
+ """
32
+ from duckduckgo_search import DDGS
33
+
34
+ results = []
35
+ with DDGS() as ddgs:
36
+ for result in ddgs.text(query, max_results=max_results):
37
+ title = result.get("title", "No title")
38
+ href = result.get("href", "No URL")
39
+ results.append(f"- {title}: {href}")
40
+
41
+ return "\n".join(results)
42
+
43
  @tool
44
  def get_current_time_in_timezone(timezone: str) -> str:
45
  """A tool that fetches the current local time in a specified timezone.
 
77
 
78
  agent = CodeAgent(
79
  model=model,
80
+ tools=[final_answer], [fetch_latest_info], ## add your tools here (don't remove final answer)
81
  max_steps=6,
82
  verbosity_level=1,
83
  grammar=None,