Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,14 +9,26 @@ 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(
|
13 |
-
|
14 |
-
"""A tool that does nothing yet
|
15 |
Args:
|
16 |
-
|
17 |
-
|
18 |
"""
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
@tool
|
22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
@@ -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,
|
|
|
9 |
|
10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
11 |
@tool
|
12 |
+
def my_custom_tool(length_label: str, num_special: int) -> str:
|
13 |
+
"""Generate a secure password based on input parameters.
|
|
|
14 |
Args:
|
15 |
+
length_label: Desired strength ('short', 'medium', 'strong').
|
16 |
+
num_special: Number of special characters to include.
|
17 |
"""
|
18 |
+
import random
|
19 |
+
import string
|
20 |
+
|
21 |
+
length_map = {'short': 8, 'medium': 12, 'strong': 16}
|
22 |
+
length = length_map.get(length_label.lower(), 12)
|
23 |
+
|
24 |
+
if num_special > length:
|
25 |
+
return "Number of special characters can't exceed total password length."
|
26 |
+
|
27 |
+
letters = string.ascii_letters + string.digits
|
28 |
+
special = string.punctuation
|
29 |
+
password = ''.join(random.choices(letters, k=length - num_special)) + \
|
30 |
+
''.join(random.choices(special, k=num_special))
|
31 |
+
return ''.join(random.sample(password, len(password)))
|
32 |
|
33 |
@tool
|
34 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
67 |
|
68 |
agent = CodeAgent(
|
69 |
model=model,
|
70 |
+
tools=[final_answer, DuckDuckGoSearchTool(), image_generation_tool, get_current_time_in_timezone, ], ## add your tools here (don't remove final answer)
|
71 |
max_steps=6,
|
72 |
verbosity_level=1,
|
73 |
grammar=None,
|