kobaIK commited on
Commit
648aa06
·
verified ·
1 Parent(s): 8c5c24b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -0
app.py CHANGED
@@ -18,6 +18,43 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
18
  """
19
  return "What magic will you build ?"
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
23
  """A tool that fetches the current local time in a specified timezone.
 
18
  """
19
  return "What magic will you build ?"
20
 
21
+ @tool
22
+ def generate_password(length: int, use_special_chars: bool = True, use_digits: bool = True) -> str:
23
+ """Generates a random secure password.
24
+ Args:
25
+ length: The length of the password.
26
+ use_special_chars: Whether to include special characters.
27
+ use_digits: Whether to include digits.
28
+ """
29
+ import string, random
30
+
31
+ characters = string.ascii_letters
32
+ if use_digits:
33
+ characters += string.digits
34
+ if use_special_chars:
35
+ characters += string.punctuation
36
+
37
+ if length < 4:
38
+ return "Error: Password length must be at least 4 characters."
39
+
40
+ password = ''.join(random.choice(characters) for _ in range(length))
41
+ return f"Your generated password is: {password}"
42
+
43
+ @tool
44
+ def daily_tip() -> str:
45
+ """Returns a random motivational tip or quote.
46
+ Args: None
47
+ """
48
+ import random
49
+ tips = [
50
+ "Start where you are. Use what you have. Do what you can.",
51
+ "Small steps every day lead to big results.",
52
+ "Progress is better than perfection.",
53
+ "Success is the sum of small efforts repeated day in and day out.",
54
+ "Keep going. Everything you need will come to you at the perfect time."
55
+ ]
56
+ return random.choice(tips)
57
+
58
  @tool
59
  def get_current_time_in_timezone(timezone: str) -> str:
60
  """A tool that fetches the current local time in a specified timezone.