manjuldube commited on
Commit
0a846d0
·
verified ·
1 Parent(s): 8c5c24b

Update app.py to add a tool called age_in_animal_years where the user enters name , age and pick animal they want to convert their age to

Browse files

added tool called age_in_animal_years where the user enters:
1. Their name (string)
2. Their age in human years (integer)
3. The animal (string) they want to convert their age to

Files changed (1) hide show
  1. app.py +23 -7
app.py CHANGED
@@ -7,16 +7,32 @@ from tools.final_answer import FinalAnswerTool
7
 
8
  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:
 
7
 
8
  from Gradio_UI import GradioUI
9
 
 
10
  @tool
11
+ def age_in_animal_years(name: str, age: int, animal: str) -> str:
12
+ """Converts a human age into equivalent years for a chosen animal.
13
+
14
  Args:
15
+ name: The person's name.
16
+ age: The age in human years.
17
+ animal: The animal to convert the age into (e.g., 'dog', 'cat', 'rabbit', 'turtle').
18
  """
19
+ # Conversion rates you can expand this!
20
+ conversion_rates = {
21
+ "dog": 7,
22
+ "cat": 6,
23
+ "rabbit": 12,
24
+ "turtle": 0.5,
25
+ "parrot": 5,
26
+ "elephant": 1,
27
+ "hamster": 25
28
+ }
29
+
30
+ animal_lower = animal.lower()
31
+ if animal_lower not in conversion_rates:
32
+ return f"Sorry, I don't know how to convert to '{animal}'. Try dog, cat, rabbit, turtle, parrot, elephant, or hamster."
33
+
34
+ converted_age = age * conversion_rates[animal_lower]
35
+ return f"{name} is {converted_age} years old in {animal_lower} years!"
36
 
37
  @tool
38
  def get_current_time_in_timezone(timezone: str) -> str: