Spaces:
Sleeping
Sleeping
added my own tool
Browse files
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 |
-
|
|
|
11 |
@tool
|
12 |
-
def
|
13 |
-
|
14 |
-
|
|
|
15 |
Args:
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
18 |
"""
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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,
|