Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,15 +16,17 @@ def exchange(amount_uah: float)-> str: #it's import to specify the return type
|
|
| 16 |
amount_uah (float): Amount in UAH.
|
| 17 |
|
| 18 |
"""
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
| 24 |
|
| 25 |
-
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
return "What magic will you build ?"
|
| 28 |
|
| 29 |
@tool
|
| 30 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 16 |
amount_uah (float): Amount in UAH.
|
| 17 |
|
| 18 |
"""
|
| 19 |
+
response = requests.get("https://bank.gov.ua/NBUStatService/v1/statdirectory/exchange?json")
|
| 20 |
+
response.raise_for_status()
|
| 21 |
+
data = response.json()
|
| 22 |
+
|
| 23 |
+
# Поиск курса USD
|
| 24 |
+
usd_rate = next(item['rate'] for item in data if item['cc'] == 'USD')
|
| 25 |
|
| 26 |
+
# Конвертация
|
| 27 |
+
return f"{amount_uah} UAH = {round(amount_uah / usd_rate, 2)} USD"
|
| 28 |
+
|
| 29 |
|
|
|
|
| 30 |
|
| 31 |
@tool
|
| 32 |
def get_current_time_in_timezone(timezone: str) -> str:
|