og223 commited on
Commit
42dbf19
·
verified ·
1 Parent(s): 8c5c24b

Added age_calculation tool

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -33,6 +33,18 @@ def get_current_time_in_timezone(timezone: str) -> str:
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  final_answer = FinalAnswerTool()
38
 
@@ -55,7 +67,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,
 
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
36
+ @tool
37
+ def calculate_age(birthday: str) -> int:
38
+ """A tool that calculates the age of user based on the birthday that user inputs.
39
+ Args:
40
+ birthday: A string representing the date at birth (e.g., "1999-09-19")
41
+ """
42
+ current_date = datetime.date.today()
43
+ birth_date = datetime.datetime.strptime(birthday, "%Y-%m-%d")
44
+ age = int((current_date - birth_date).days / 365)
45
+ return f"Your current age is: {age}"
46
+
47
+
48
 
49
  final_answer = FinalAnswerTool()
50
 
 
67
 
68
  agent = CodeAgent(
69
  model=model,
70
+ tools=[final_answer], [DuckDuckGoSearchTool], [image_generation_tool], [calculate_age], ## add your tools here (don't remove final answer)
71
  max_steps=6,
72
  verbosity_level=1,
73
  grammar=None,