Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,30 +7,30 @@ from tools.final_answer import FinalAnswerTool
|
|
7 |
|
8 |
from Gradio_UI import GradioUI
|
9 |
|
10 |
-
from diffusers import StableDiffusionPipeline
|
11 |
-
import torch
|
12 |
-
from io import BytesIO
|
13 |
-
|
14 |
-
# Load Stable Diffusion Model
|
15 |
-
pipeline = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
|
16 |
-
pipeline.to("cuda") # Use GPU if available
|
17 |
-
|
18 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
19 |
@tool
|
20 |
-
def
|
21 |
-
"""
|
22 |
Args:
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
Returns:
|
27 |
-
|
28 |
"""
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
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.
|
|
|
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 currency_converter(amount: float, from_currency: str, to_currency: str) -> str:
|
13 |
+
"""Converts an amount from one currency to another using real-time exchange rates.
|
14 |
Args:
|
15 |
+
amount: The amount of money to convert.
|
16 |
+
from_currency: The currency code to convert from (e.g., 'USD').
|
17 |
+
to_currency: The currency code to convert to (e.g., 'EUR').
|
18 |
Returns:
|
19 |
+
A string with the converted amount and exchange rate.
|
20 |
"""
|
21 |
+
api_url = f"https://api.frankfurter.app/latest?from={from_currency.upper()}&to={to_currency.upper()}"
|
22 |
+
try:
|
23 |
+
response = requests.get(api_url)
|
24 |
+
data = response.json()
|
25 |
+
if 'rates' in data and to_currency.upper() in data['rates']:
|
26 |
+
rate = data['rates'][to_currency.upper()]
|
27 |
+
converted_amount = amount * rate
|
28 |
+
return f"{amount} {from_currency.upper()} = {converted_amount:.2f} {to_currency.upper()} (Rate: {rate})"
|
29 |
+
else:
|
30 |
+
return "Invalid currency code."
|
31 |
+
except Exception as e:
|
32 |
+
return f"Error fetching exchange rate: {str(e)}"
|
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.
|