Spaces:
Sleeping
Sleeping
Update app.py
Browse filesadded random number generator
app.py
CHANGED
@@ -3,20 +3,27 @@ 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
|
13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
14 |
-
"""A tool that
|
15 |
Args:
|
16 |
-
arg1: the
|
17 |
-
arg2: the
|
18 |
"""
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
@tool
|
22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
@@ -55,7 +62,12 @@ with open("prompts.yaml", 'r') as stream:
|
|
55 |
|
56 |
agent = CodeAgent(
|
57 |
model=model,
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
59 |
max_steps=6,
|
60 |
verbosity_level=1,
|
61 |
grammar=None,
|
|
|
3 |
import requests
|
4 |
import pytz
|
5 |
import yaml
|
6 |
+
import numpy as np
|
7 |
from tools.final_answer import FinalAnswerTool
|
8 |
|
9 |
from Gradio_UI import GradioUI
|
10 |
|
11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
12 |
@tool
|
13 |
+
def random_normal_draws(arg1: float, arg2: float)-> str: #it's import to specify the return type
|
14 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
15 |
+
"""A tool that generates 10 draws from a normal distribution with mean and standard deviation given.
|
16 |
Args:
|
17 |
+
arg1: the mean of the distribution
|
18 |
+
arg2: the standard deviation of the distribution (must be positive)
|
19 |
"""
|
20 |
+
try:
|
21 |
+
if arg2 <= 0:
|
22 |
+
return "Error: Standard deviation must be positive."
|
23 |
+
rand_norm = np.random.normal(loc=arg1, scale=arg2, size=10)
|
24 |
+
return ", ".join(f"{x:.2f}" for x in rand_norm)
|
25 |
+
except Exception as e:
|
26 |
+
return f"Error generating distribution: {e}"
|
27 |
|
28 |
@tool
|
29 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
62 |
|
63 |
agent = CodeAgent(
|
64 |
model=model,
|
65 |
+
tools=[
|
66 |
+
final_answer,
|
67 |
+
image_generation_tool,
|
68 |
+
get_current_time_in_timezone, # even though it's decorated
|
69 |
+
my_custom_tool # same here
|
70 |
+
]
|
71 |
max_steps=6,
|
72 |
verbosity_level=1,
|
73 |
grammar=None,
|