hyraxdata commited on
Commit
e2126bf
·
verified ·
1 Parent(s): ae7a494

added a new tool to calculate the days between two days

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 days_between_dates(start_date: str, end_date: str) -> int:
23
+ """A tool that calculates the number of days between two given dates.
24
+
25
+ Args:
26
+ start_date: The start date in 'YYYY-MM-DD' format.
27
+ end_date: The end date in 'YYYY-MM-DD' format.
28
+
29
+ Returns:
30
+ The number of days between the two dates.
31
+ """
32
+
33
+ try:
34
+ start = datetime.datetime.strptime(start_date, "%Y-%m-%d")
35
+ end = datetime.datetime.strptime(end_date, "%Y-%m-%d")
36
+ difference = (end - start).days
37
+ return abs(difference)
38
+ except ValueError:
39
+ print("Error: Please provide dates in the correct 'YYYY-MM-DD' format.")
40
+ return None
41
+
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, days_between_dates], ## add your tools here (don't remove final answer)
81
  max_steps=6,
82
  verbosity_level=1,
83
  grammar=None,