rodato commited on
Commit
391b8bc
·
verified ·
1 Parent(s): 8c5c24b

Update app.py with password genertor tool

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py CHANGED
@@ -1,5 +1,7 @@
1
  from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
  import datetime
 
 
3
  import requests
4
  import pytz
5
  import yaml
@@ -33,6 +35,30 @@ def get_current_time_in_timezone(timezone: str) -> str:
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  final_answer = FinalAnswerTool()
38
 
 
1
  from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
  import datetime
3
+ import random
4
+ import string
5
  import requests
6
  import pytz
7
  import yaml
 
35
  except Exception as e:
36
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
37
 
38
+ @toll
39
+ def password_generator_tool(length: int) -> str:
40
+ """
41
+ Generate a secure password with uppercase, lowercase, numbers, and symbols.
42
+
43
+ Args:
44
+ length (int): password lenght, it must be at least 4 characters.
45
+
46
+ Returns:
47
+ str: password generated.
48
+ """
49
+
50
+ # Validación
51
+ if length < 4:
52
+ return "Error: The password length must be at least 4 characters."
53
+
54
+ # Todos los caracteres disponibles
55
+ characters = string.ascii_uppercase + string.ascii_lowercase + string.digits + "!@#$%^&*()_+-=[]{}|;:,.<>?"
56
+
57
+ # Generar contraseña
58
+ password = ''.join(random.choice(characters) for _ in range(length))
59
+
60
+ return password
61
+
62
 
63
  final_answer = FinalAnswerTool()
64