CanerCoban commited on
Commit
ed6e3fb
·
verified ·
1 Parent(s): ae7a494

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -5
app.py CHANGED
@@ -1,4 +1,5 @@
1
  from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
 
2
  import datetime
3
  import requests
4
  import pytz
@@ -9,14 +10,30 @@ 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 +72,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,
 
1
  from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
+ from random import shuffle, randint, choice
3
  import datetime
4
  import requests
5
  import pytz
 
10
 
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
12
  @tool
13
+ def password_generator(nol:int, nod:int,nos:int)-> str: #it's import to specify the return type
14
  #Keep this format for the description / args / args description but feel free to modify the tool
15
  """A tool that does nothing yet
16
  Args:
17
+ nol: the number of letters to be included in generated password
18
+ nod: the number of digits to be included in generated password
19
+ nos: the number of symbols to be included in generated password
20
+
21
  """
22
+ letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
23
+ digits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
24
+ symbols = ['!', '#', '$', '%', '&', '(', ')', '*', '+']
25
+
26
+ paswword_letters = [choice(letters) for _ in range(nol)]
27
+ password_digits = [choice(digits) for _ in range(nod)]
28
+ password_symbols = [choice(symbols) for _ in range(nos)]
29
+
30
+ password_list = password_letters + password_symbols + password_numbers
31
+
32
+ shuffle(password_list)
33
+
34
+ generated_password = "":join(password_list)
35
+
36
+ return generated_password
37
 
38
  @tool
39
  def get_current_time_in_timezone(timezone: str) -> str:
 
72
 
73
  agent = CodeAgent(
74
  model=model,
75
+ tools=[final_answer, password_generator,get_current_time_in_timezone], ## add your tools here (don't remove final answer)
76
  max_steps=6,
77
  verbosity_level=1,
78
  grammar=None,