Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,8 +10,12 @@ from Gradio_UI import GradioUI
|
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
|
| 12 |
|
|
|
|
|
|
|
|
|
|
| 13 |
@tool
|
| 14 |
def generate_password(arg1: str, arg2: int) -> str:
|
|
|
|
| 15 |
"""A tool that generates a random password based on the specified complexity.
|
| 16 |
|
| 17 |
Args:
|
|
@@ -21,10 +25,15 @@ def generate_password(arg1: str, arg2: int) -> str:
|
|
| 21 |
if arg2 < 4:
|
| 22 |
return "Error: Password length must be at least 4 characters."
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
if arg1.lower() == "simple":
|
| 25 |
-
chars =
|
| 26 |
elif arg1.lower() == "complex":
|
| 27 |
-
chars =
|
| 28 |
else:
|
| 29 |
return "Error: Use 'simple' or 'complex' for the complexity type."
|
| 30 |
|
|
|
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
|
| 12 |
|
| 13 |
+
import random
|
| 14 |
+
from smolagents import tool
|
| 15 |
+
|
| 16 |
@tool
|
| 17 |
def generate_password(arg1: str, arg2: int) -> str:
|
| 18 |
+
# Keep this format for the tool description / args description but feel free to modify the tool
|
| 19 |
"""A tool that generates a random password based on the specified complexity.
|
| 20 |
|
| 21 |
Args:
|
|
|
|
| 25 |
if arg2 < 4:
|
| 26 |
return "Error: Password length must be at least 4 characters."
|
| 27 |
|
| 28 |
+
# Manually define character sets (since `string` is blocked)
|
| 29 |
+
letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
| 30 |
+
digits = "0123456789"
|
| 31 |
+
symbols = "!@#$%^&*()-_=+[]{}|;:,.<>?/"
|
| 32 |
+
|
| 33 |
if arg1.lower() == "simple":
|
| 34 |
+
chars = letters + digits # Simple passwords: letters + numbers
|
| 35 |
elif arg1.lower() == "complex":
|
| 36 |
+
chars = letters + digits + symbols # Complex passwords: add symbols
|
| 37 |
else:
|
| 38 |
return "Error: Use 'simple' or 'complex' for the complexity type."
|
| 39 |
|