spatil50 commited on
Commit
ed73a99
·
verified ·
1 Parent(s): cc5a324

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -1,5 +1,6 @@
1
  from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
  import datetime
 
3
  import requests
4
  import pytz
5
  import yaml
@@ -9,15 +10,21 @@ 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:int, 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 add two integers and produce integer output
15
  Args:
16
- arg1: the first argument
17
- arg2: the second argument
18
- output: integer ouput
19
  """
20
- return arg1+arg2
 
 
 
 
 
 
21
 
22
  @tool
23
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -56,7 +63,7 @@ with open("prompts.yaml", 'r') as stream:
56
 
57
  agent = CodeAgent(
58
  model=model,
59
- tools=[final_answer, my_custom_tool], ## add your tools here (don't remove final answer)
60
  max_steps=6,
61
  verbosity_level=1,
62
  grammar=None,
 
1
  from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
  import datetime
3
+ from datetime import date
4
  import requests
5
  import pytz
6
  import yaml
 
10
 
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
12
  @tool
13
+ def birthday_calulator(day:int, month:int, year:int)-> str: #it's import to specify the return type
14
  #Keep this format for the description / args / args description but feel free to modify the tool
15
  """A tool that add two integers and produce integer output
16
  Args:
17
+ arg1: day of birth
18
+ arg2: month of birth
19
+ arg3: year of birth
20
  """
21
+ today = date.today()
22
+ birth_date = date(year, month, day)
23
+
24
+ # Calculate age
25
+ age = today.year - birth_date.year - ((today.month, today.day) < (birth_date.month, birth_date.day))
26
+
27
+ return f"You are {age} years old."
28
 
29
  @tool
30
  def get_current_time_in_timezone(timezone: str) -> str:
 
63
 
64
  agent = CodeAgent(
65
  model=model,
66
+ tools=[final_answer, birthday_calulator], ## add your tools here (don't remove final answer)
67
  max_steps=6,
68
  verbosity_level=1,
69
  grammar=None,