Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,14 +9,33 @@ 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
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
Args:
|
| 16 |
-
arg1: the first argument
|
| 17 |
-
arg2: the second argument
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -55,7 +74,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[final_answer,get_current_time_in_timezone], ## 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 convert_currency(amount: float, from_currency: str, to_currency: str) -> str:
|
| 13 |
+
"""
|
| 14 |
+
Convert amount from one currency to another using fixed exchange rates.
|
|
|
|
|
|
|
|
|
|
| 15 |
"""
|
| 16 |
+
# Mock exchange rates relative to USD
|
| 17 |
+
exchange_rates = {
|
| 18 |
+
"USD": 1.0,
|
| 19 |
+
"EUR": 0.91,
|
| 20 |
+
"GBP": 0.78,
|
| 21 |
+
"JPY": 134.23,
|
| 22 |
+
"INR": 83.12,
|
| 23 |
+
"CNY": 7.25,
|
| 24 |
+
"AED": 3.64
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
from_currency = from_currency.upper()
|
| 28 |
+
to_currency = to_currency.upper()
|
| 29 |
+
|
| 30 |
+
if from_currency not in exchange_rates or to_currency not in exchange_rates:
|
| 31 |
+
return f"Unsupported currency. Supported currencies: {', '.join(exchange_rates.keys())}"
|
| 32 |
+
|
| 33 |
+
# Convert to USD first, then to target currency
|
| 34 |
+
amount_in_usd = amount / exchange_rates[from_currency]
|
| 35 |
+
converted_amount = amount_in_usd * exchange_rates[to_currency]
|
| 36 |
+
|
| 37 |
+
return f"{amount:.2f} {from_currency} = {converted_amount:.2f} {to_currency}"
|
| 38 |
+
|
| 39 |
|
| 40 |
@tool
|
| 41 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 74 |
|
| 75 |
agent = CodeAgent(
|
| 76 |
model=model,
|
| 77 |
+
tools=[final_answer,get_current_time_in_timezone,convert_currency], ## add your tools here (don't remove final answer)
|
| 78 |
max_steps=6,
|
| 79 |
verbosity_level=1,
|
| 80 |
grammar=None,
|