Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,14 +9,26 @@ 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 |
-
"""A tool that does nothing yet
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -55,7 +67,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[get_current_time_in_timezone, DuckDuckGoSearchTool, final_answer], ## 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 get_exchange_rate(base_currency: str, target_currency: str) -> str:
|
| 13 |
+
"""Fetches the exchange rate from one currency to another.
|
|
|
|
| 14 |
Args:
|
| 15 |
+
base_currency: The currency to convert from (e.g., 'USD').
|
| 16 |
+
target_currency: The currency to convert to (e.g., 'THB').
|
| 17 |
"""
|
| 18 |
+
try:
|
| 19 |
+
url = f"https://api.exchangerate-api.com/v4/latest/{base_currency.upper()}"
|
| 20 |
+
response = requests.get(url)
|
| 21 |
+
data = response.json()
|
| 22 |
+
|
| 23 |
+
if "rates" not in data or target_currency.upper() not in data["rates"]:
|
| 24 |
+
return f"Exchange rate for {base_currency} to {target_currency} not found."
|
| 25 |
+
|
| 26 |
+
rate = data["rates"][target_currency.upper()]
|
| 27 |
+
return f"1 {base_currency.upper()} = {rate} {target_currency.upper()}."
|
| 28 |
+
|
| 29 |
+
except Exception as e:
|
| 30 |
+
return f"Error fetching exchange rate: {str(e)}"
|
| 31 |
+
|
| 32 |
|
| 33 |
@tool
|
| 34 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 67 |
|
| 68 |
agent = CodeAgent(
|
| 69 |
model=model,
|
| 70 |
+
tools=[get_current_time_in_timezone, get_exchange_rate, DuckDuckGoSearchTool(), final_answer], ## add your tools here (don't remove final answer)
|
| 71 |
max_steps=6,
|
| 72 |
verbosity_level=1,
|
| 73 |
grammar=None,
|