Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,19 +9,6 @@ from tools.final_answer import FinalAnswerTool
|
|
| 9 |
|
| 10 |
from Gradio_UI import GradioUI
|
| 11 |
|
| 12 |
-
@tool
|
| 13 |
-
def generate_secure_password(length: int) -> str:
|
| 14 |
-
"""A tool that generates a secure random password with a specific length.
|
| 15 |
-
Args:
|
| 16 |
-
length: The length of the password to be generated (must be an integer).
|
| 17 |
-
"""
|
| 18 |
-
if not isinstance(length, int) or length < 4:
|
| 19 |
-
return "Error: Password length must be an integer and at least 4."
|
| 20 |
-
|
| 21 |
-
characters = string.ascii_letters + string.digits + string.punctuation
|
| 22 |
-
password = ''.join(random.choice(characters) for i in range(length))
|
| 23 |
-
return f"Generated password: {password}"
|
| 24 |
-
|
| 25 |
@tool
|
| 26 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 27 |
"""A tool that fetches the current local time in a specified timezone.
|
|
@@ -37,8 +24,23 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 37 |
except Exception as e:
|
| 38 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
search_tool = DuckDuckGoSearchTool()
|
| 41 |
|
|
|
|
|
|
|
| 42 |
|
| 43 |
final_answer = FinalAnswerTool()
|
| 44 |
|
|
@@ -53,8 +55,6 @@ custom_role_conversions=None,
|
|
| 53 |
)
|
| 54 |
|
| 55 |
|
| 56 |
-
# Import tool from Hub
|
| 57 |
-
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 58 |
|
| 59 |
with open("prompts.yaml", 'r') as stream:
|
| 60 |
prompt_templates = yaml.safe_load(stream)
|
|
@@ -71,7 +71,7 @@ agent = CodeAgent(
|
|
| 71 |
verbosity_level=1,
|
| 72 |
grammar=None,
|
| 73 |
planning_interval=None,
|
| 74 |
-
name=
|
| 75 |
description="A smart agent that can generate images, search the web, tell time, and generate passwords.",
|
| 76 |
prompt_templates=prompt_templates
|
| 77 |
)
|
|
|
|
| 9 |
|
| 10 |
from Gradio_UI import GradioUI
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
@tool
|
| 13 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 14 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
|
| 24 |
except Exception as e:
|
| 25 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 26 |
|
| 27 |
+
@tool
|
| 28 |
+
def generate_secure_password(length: int) -> str:
|
| 29 |
+
"""A tool that generates a secure random password with a specific length.
|
| 30 |
+
Args:
|
| 31 |
+
length: The length of the password to be generated (must be an integer).
|
| 32 |
+
"""
|
| 33 |
+
if not isinstance(length, int) or length < 4:
|
| 34 |
+
return "Error: Password length must be an integer and at least 4."
|
| 35 |
+
|
| 36 |
+
characters = string.ascii_letters + string.digits + string.punctuation
|
| 37 |
+
password = ''.join(random.choice(characters) for i in range(length))
|
| 38 |
+
return f"Generated password: {password}"
|
| 39 |
+
|
| 40 |
search_tool = DuckDuckGoSearchTool()
|
| 41 |
|
| 42 |
+
# Import tool from Hub
|
| 43 |
+
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 44 |
|
| 45 |
final_answer = FinalAnswerTool()
|
| 46 |
|
|
|
|
| 55 |
)
|
| 56 |
|
| 57 |
|
|
|
|
|
|
|
| 58 |
|
| 59 |
with open("prompts.yaml", 'r') as stream:
|
| 60 |
prompt_templates = yaml.safe_load(stream)
|
|
|
|
| 71 |
verbosity_level=1,
|
| 72 |
grammar=None,
|
| 73 |
planning_interval=None,
|
| 74 |
+
name="My Super Assistant",
|
| 75 |
description="A smart agent that can generate images, search the web, tell time, and generate passwords.",
|
| 76 |
prompt_templates=prompt_templates
|
| 77 |
)
|