silBERTa commited on
Commit
5f58088
·
verified ·
1 Parent(s): 8c5c24b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -7
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(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
- #Keep this format for the description / args / args description but feel free to modify the tool
14
- """A tool that does nothing yet
15
  Args:
16
- arg1: the first argument
17
- arg2: the second argument
18
  """
19
- return "What magic will you build ?"
 
 
 
 
 
 
 
 
 
 
 
 
 
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,