Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,37 +11,26 @@ from Gradio_UI import GradioUI
|
|
| 11 |
|
| 12 |
|
| 13 |
@tool
|
| 14 |
-
def
|
| 15 |
-
"""
|
| 16 |
-
|
| 17 |
Args:
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
to_currency (str): The 3-letter currency code to convert to (e.g., 'EUR').
|
| 21 |
-
|
| 22 |
-
Returns:
|
| 23 |
-
str: A formatted string with the converted amount and exchange rate.
|
| 24 |
"""
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
return f"Error: Unsupported currency '{to_currency}'."
|
| 38 |
-
|
| 39 |
-
converted_amount = round(amount * rate, 2)
|
| 40 |
-
return f"{amount} {from_currency.upper()} is approximately {converted_amount} {to_currency.upper()} (Rate: {rate})."
|
| 41 |
|
| 42 |
-
except Exception as e:
|
| 43 |
-
return f"Error fetching exchange rates: {str(e)}"
|
| 44 |
-
|
| 45 |
@tool
|
| 46 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 47 |
"""A tool that fetches the current local time in a specified timezone.
|
|
@@ -79,7 +68,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 79 |
|
| 80 |
agent = CodeAgent(
|
| 81 |
model=model,
|
| 82 |
-
tools=[final_answer,
|
| 83 |
max_steps=6,
|
| 84 |
verbosity_level=1,
|
| 85 |
grammar=None,
|
|
|
|
| 11 |
|
| 12 |
|
| 13 |
@tool
|
| 14 |
+
def generate_password(arg1: str, arg2: int) -> str:
|
| 15 |
+
"""A tool that generates a random password based on the specified complexity.
|
| 16 |
+
|
| 17 |
Args:
|
| 18 |
+
arg1: The complexity type ('simple' or 'complex').
|
| 19 |
+
arg2: The length of the password.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
"""
|
| 21 |
+
if arg2 < 4:
|
| 22 |
+
return "Error: Password length must be at least 4 characters."
|
| 23 |
+
|
| 24 |
+
if arg1.lower() == "simple":
|
| 25 |
+
chars = string.ascii_letters + string.digits # Letters and numbers
|
| 26 |
+
elif arg1.lower() == "complex":
|
| 27 |
+
chars = string.ascii_letters + string.digits + string.punctuation # Includes symbols
|
| 28 |
+
else:
|
| 29 |
+
return "Error: Use 'simple' or 'complex' for the complexity type."
|
| 30 |
+
|
| 31 |
+
password = "".join(random.choice(chars) for _ in range(arg2))
|
| 32 |
+
return f"Generated {arg1.lower()} password: {password}"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
|
|
|
|
|
|
|
|
|
| 34 |
@tool
|
| 35 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 36 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
|
| 68 |
|
| 69 |
agent = CodeAgent(
|
| 70 |
model=model,
|
| 71 |
+
tools=[final_answer, generate_password], ## add your tools here (don't remove final answer)
|
| 72 |
max_steps=6,
|
| 73 |
verbosity_level=1,
|
| 74 |
grammar=None,
|