Da-Rabbit-Hole commited on
Commit
66c1c46
·
verified ·
1 Parent(s): ac11f08

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -14,8 +14,7 @@ import pandas as pd
14
 
15
  @tool
16
  # Function to get current prices of specified cryptocurrencies
17
- def get_crypto_prices(crypto_ids: str, currency='usd'):
18
-
19
  """This is a tool to get current crypto token market prices in usd currency using the coingecko api.
20
  Args:
21
  args1: crypto_ids= Input for crypto_ids is a string
@@ -25,19 +24,22 @@ def get_crypto_prices(crypto_ids: str, currency='usd'):
25
  You should return all valid requests with the crypto id, and its current price in usd denominations.
26
  """
27
 
28
- url = f"https://api.coingecko.com/api/v3/simple/price?ids={','.join(crypto_ids)}&vs_currencies={currency}"
29
- response = requests.get(url)
30
-
31
- if response.status_code == 200:
32
- data = response.json()
33
- return pd.DataFrame(data).T # Transpose for better readability
 
34
  else:
35
  print("Failed to retrieve data")
36
- return None
37
 
38
  # Specify the cryptocurrencies you want to check
39
- cryptos = ['bitcoin', 'ethereum', 'ripple']
 
 
40
 
41
  # Get current prices
42
- prices = get_crypto_prices(cryptos)
 
43
  print(prices)
 
14
 
15
  @tool
16
  # Function to get current prices of specified cryptocurrencies
17
+ def get_crypto_prices(crypto_ids='tokens', currency='usd'): str
 
18
  """This is a tool to get current crypto token market prices in usd currency using the coingecko api.
19
  Args:
20
  args1: crypto_ids= Input for crypto_ids is a string
 
24
  You should return all valid requests with the crypto id, and its current price in usd denominations.
25
  """
26
 
27
+ url = f" url = f"https://pro-api.coingecko.com/api/v3/simple/price?&x_cg_demo_api_key=CG-4TqTQv39JuPvRFmz3dz5Kcff""
28
+
29
+ response = requests.get(url)
30
+
31
+ if response.status_code == 200:
32
+ data = response.json()
33
+ return pd.DataFrame(data).T # Transpose for better readability
34
  else:
35
  print("Failed to retrieve data")
 
36
 
37
  # Specify the cryptocurrencies you want to check
38
+ cryptos_ids = ['bitcoin&vs_currencies=usd&x_cg_pro_api_key=CG-4TqTQv39JuPvRFmz3dz5Kcff',
39
+ 'ethereum&vs_currencies=usd&x_cg_pro_api_key=CG-4TqTQv39JuPvRFmz3dz5Kcff',
40
+ 'ripple&vs_currencies=usd&x_cg_pro_api_key=CG-4TqTQv39JuPvRFmz3dz5Kcff']
41
 
42
  # Get current prices
43
+ prices = get_crypto_prices(cryptos_ids)
44
+
45
  print(prices)