AlexGrig23 commited on
Commit
5eaa932
·
verified ·
1 Parent(s): 5b14307

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
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
- response = requests.get("https://bank.gov.ua/NBUStatService/v1/statdirectory/exchange?json")
20
- response.raise_for_status()
21
- data = response.json()
22
-
23
- usd_rate = next(item['rate'] for item in data if item['cc'] == 'USD')
 
24
 
25
- return f"{uah_amount} UAH = {round(amount_uah / usd_rate, 2} USD" )
 
 
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: