melihTAl commited on
Commit
4e2e022
·
verified ·
1 Parent(s): 8c5c24b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -10
app.py CHANGED
@@ -3,20 +3,23 @@ import datetime
3
  import requests
4
  import pytz
5
  import yaml
 
 
6
  from tools.final_answer import FinalAnswerTool
7
 
8
  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:
@@ -33,6 +36,8 @@ 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
 
@@ -55,13 +60,18 @@ 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,
62
  planning_interval=None,
63
  name=None,
64
- description=None,
65
  prompt_templates=prompt_templates
66
  )
67
 
 
3
  import requests
4
  import pytz
5
  import yaml
6
+ import random
7
+ import string
8
  from tools.final_answer import FinalAnswerTool
9
 
10
  from Gradio_UI import GradioUI
11
 
12
+ def generate_secure_password(length: int) -> str:
13
+ """A tool that generates a secure random password with a specific length.
 
 
 
14
  Args:
15
+ length: The length of the password to be generated (must be an integer).
 
16
  """
17
+ if not isinstance(length, int) or length < 4:
18
+ return "Error: Password length must be an integer and at least 4."
19
+
20
+ characters = string.ascii_letters + string.digits + string.punctuation
21
+ password = ''.join(random.choice(characters) for i in range(length))
22
+ return f"Generated password: {password}"
23
 
24
  @tool
25
  def get_current_time_in_timezone(timezone: str) -> str:
 
36
  except Exception as e:
37
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
38
 
39
+ search_tool = DuckDuckGoSearchTool()
40
+
41
 
42
  final_answer = FinalAnswerTool()
43
 
 
60
 
61
  agent = CodeAgent(
62
  model=model,
63
+ tools=[final_answer,
64
+ search_tool,
65
+ image_generation_tool,
66
+ get_current_time_in_timezone,
67
+ generate_secure_password
68
+ ], ## add your tools here (don't remove final answer)
69
  max_steps=6,
70
  verbosity_level=1,
71
  grammar=None,
72
  planning_interval=None,
73
  name=None,
74
+ description="A smart agent that can generate images, search the web, tell time, and generate passwords.",
75
  prompt_templates=prompt_templates
76
  )
77