martinjolif commited on
Commit
0983cc2
·
verified ·
1 Parent(s): 8c5c24b

new tools for the agent

Browse files
Files changed (1) hide show
  1. app.py +23 -8
app.py CHANGED
@@ -1,4 +1,4 @@
1
- from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
  import datetime
3
  import requests
4
  import pytz
@@ -9,14 +9,24 @@ from Gradio_UI import GradioUI
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
- def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
- #Keep this format for the description / args / args description but feel free to modify the tool
14
- """A tool that does nothing yet
15
  Args:
16
- arg1: the first argument
17
- arg2: the second argument
18
  """
19
- return "What magic will you build ?"
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -55,7 +65,12 @@ 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,
 
1
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
2
  import datetime
3
  import requests
4
  import pytz
 
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
+ def get_addition_between_two_numbers(x:float, y:float)-> float:
13
+ """A tool that does the addition of two numbers.
 
14
  Args:
15
+ x: a float representing the first member of the addition
16
+ y: a float representing the second member of the addition
17
  """
18
+ return x+y
19
+
20
+ @tool
21
+ def get_search_on_internet(search_request: str) -> str:
22
+ """A tool that search something on internet.
23
+ Args:
24
+ search_request: a string which corresponds to the search request to do
25
+ """
26
+ web_search_tool = DuckDuckGoSearchTool(max_results=3, rate_limit=2.0)
27
+ results = web_search_tool(search_request)
28
+ return results
29
+
30
 
31
  @tool
32
  def get_current_time_in_timezone(timezone: str) -> str:
 
65
 
66
  agent = CodeAgent(
67
  model=model,
68
+ tools=[final_answer,
69
+ get_addition_between_two_numbers,
70
+ get_search_on_internet,
71
+ get_current_time_in_timezone,
72
+ image_generation_tool
73
+ ], ## add your tools here (don't remove final answer)
74
  max_steps=6,
75
  verbosity_level=1,
76
  grammar=None,