Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,30 +4,24 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
import json
|
|
|
|
|
|
|
| 7 |
from tools.final_answer import FinalAnswerTool
|
| 8 |
-
import subprocess
|
| 9 |
|
| 10 |
from Gradio_UI import GradioUI
|
| 11 |
|
| 12 |
-
try:
|
| 13 |
-
subprocess.run(["pip", "install", "googletrans==4.0.0-rc1"], check=True)
|
| 14 |
-
except subprocess.CalledProcessError:
|
| 15 |
-
print("Failed to install googletrans.")
|
| 16 |
-
|
| 17 |
-
from googletrans import Translator
|
| 18 |
-
|
| 19 |
@tool
|
| 20 |
-
def
|
| 21 |
-
"""A tool that
|
| 22 |
Args:
|
| 23 |
-
|
| 24 |
"""
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
|
| 32 |
@tool
|
| 33 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -65,7 +59,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 65 |
|
| 66 |
agent = CodeAgent(
|
| 67 |
model=model,
|
| 68 |
-
tools=[
|
| 69 |
max_steps=6,
|
| 70 |
verbosity_level=1,
|
| 71 |
grammar=None,
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
import json
|
| 7 |
+
import random
|
| 8 |
+
import string
|
| 9 |
from tools.final_answer import FinalAnswerTool
|
|
|
|
| 10 |
|
| 11 |
from Gradio_UI import GradioUI
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
@tool
|
| 14 |
+
def generate_random_password(length: int = 12) -> str:
|
| 15 |
+
"""A tool that generates a secure random password.
|
| 16 |
Args:
|
| 17 |
+
length: The desired length of the password (default is 12).
|
| 18 |
"""
|
| 19 |
+
if length < 4:
|
| 20 |
+
return "Password length must be at least 4 characters."
|
| 21 |
+
|
| 22 |
+
characters = string.ascii_letters + string.digits + string.punctuation
|
| 23 |
+
password = ''.join(random.choice(characters) for _ in range(length))
|
| 24 |
+
return password
|
| 25 |
|
| 26 |
@tool
|
| 27 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 59 |
|
| 60 |
agent = CodeAgent(
|
| 61 |
model=model,
|
| 62 |
+
tools=[generate_random_password, final_answer], ## add your tools here (don't remove final answer)
|
| 63 |
max_steps=6,
|
| 64 |
verbosity_level=1,
|
| 65 |
grammar=None,
|