azminetoushikwasi commited on
Commit
a1054b1
·
verified ·
1 Parent(s): e8d4494

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -1,4 +1,5 @@
1
  from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
 
2
  import datetime
3
  import requests
4
  import pytz
@@ -18,6 +19,12 @@ def my_cutom_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.
@@ -51,7 +58,7 @@ with open("prompts.yaml", 'r') as stream:
51
 
52
  agent = CodeAgent(
53
  model=model,
54
- tools=[final_answer], ## add your tools here (don't remove final answer)
55
  max_steps=6,
56
  verbosity_level=1,
57
  grammar=None,
 
1
  from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
+ from langchain_community.tools import DuckDuckGoSearchResults
3
  import datetime
4
  import requests
5
  import pytz
 
19
  """
20
  return "What magic will you build ?"
21
 
22
+ @tool
23
+ def search_web(query: str) -> str:
24
+ print('Performing query on',query)
25
+ search = DuckDuckGoSearchResults()
26
+ return json.dumps(search.run(query))
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.
 
58
 
59
  agent = CodeAgent(
60
  model=model,
61
+ tools=[search_web,get_current_time_in_timezone,final_answer], ## add your tools here (don't remove final answer)
62
  max_steps=6,
63
  verbosity_level=1,
64
  grammar=None,