SuhaibAtef commited on
Commit
d77d27d
·
verified ·
1 Parent(s): 9a8c112

added my own tool

Browse files
Files changed (1) hide show
  1. app.py +27 -8
app.py CHANGED
@@ -3,20 +3,39 @@ import datetime
3
  import requests
4
  import pytz
5
  import yaml
 
6
  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_cutom_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:
@@ -51,7 +70,7 @@ with open("prompts.yaml", 'r') as stream:
51
 
52
  agent = CodeAgent(
53
  model=model,
54
- tools=[final_answer], ## add your tools here (don't remove final answer)
55
  max_steps=6,
56
  verbosity_level=1,
57
  grammar=None,
 
3
  import requests
4
  import pytz
5
  import yaml
6
+ import random
7
  from tools.final_answer import FinalAnswerTool
8
 
9
  from Gradio_UI import GradioUI
10
 
11
+ import random
12
+
13
  @tool
14
+ def enhance_percentage(percentage: str, decimal_places: int) -> str:
15
+ """
16
+ Enhances a given percentage by adding random decimal places.
17
+
18
  Args:
19
+ percentage: The original percentage as a string (e.g., '13%').
20
+ decimal_places: The number of decimal places to add.
21
+
22
+ Returns:
23
+ A string representing the enhanced percentage with the specified number of decimal places.
24
  """
25
+ # Remove the '%' sign and convert to a float
26
+ base_value = float(percentage.strip('%'))
27
+
28
+ # Generate a random float between 0 and 1
29
+ random_fraction = random.random()
30
+
31
+ # Calculate the enhanced percentage
32
+ enhanced_value = base_value + random_fraction
33
+
34
+ # Format the result to the specified number of decimal places
35
+ formatted_percentage = f"{enhanced_value:.{decimal_places}f}%"
36
+
37
+ return formatted_percentage
38
+
39
 
40
  @tool
41
  def get_current_time_in_timezone(timezone: str) -> str:
 
70
 
71
  agent = CodeAgent(
72
  model=model,
73
+ tools=[final_answer,enhance_percentage,get_current_time_in_timezone], ## add your tools here (don't remove final answer)
74
  max_steps=6,
75
  verbosity_level=1,
76
  grammar=None,