File size: 1,730 Bytes
fc83728
9b5b26a
5357699
5df72d6
672b80f
23fb26e
 
 
 
 
 
 
 
9b5b26a
 
5357699
66c1c46
5eaf43a
51c80ed
cfa85cc
7617dce
 
cfa85cc
 
5357699
cfa85cc
 
51c80ed
23fb26e
343f396
66c1c46
885adf2
66c1c46
ebe6cff
 
ceb168a
ebe6cff
5357699
687468d
5357699
66c1c46
 
 
9b5b26a
5357699
66c1c46
 
5357699
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from smolagents import tool
import requests
import pandas as pd
# Below is an example of a tool that does nothing. Amaze us with your creativity !
# @tool
# def my_custom_tool(arg1:str, arg2:int): str #it's important to specify the return type
#     #Keep this format for the description / args / args description but feel free to modify the tool
#     """A tool that does nothing yet 
#     Args:
#         arg1: the first argument
#         arg2: the second argument
#     """
#     # return

@tool
# Function to get current prices of specified cryptocurrencies
def get_crypto_prices(crypto_ids='tokens', currency='usd'): str
    
"""This is a tool to get current crypto token market prices in usd currency using the coingecko api.

    This is the crypto token prices tool

    args1 (str): Input for crypto_ids is a string
    args2: (str): Output for currency is an srting
        
    Returns: 
        (str): You should return all valid requests with the crypto id, and its current price in usd denominations.
"""
    
url = "https://pro-api.coingecko.com/api/v3/simple/price?&x_cg_demo_api_key=CG-4TqTQv39JuPvRFmz3dz5Kcff"

response = requests.get(url)

if response.status_code == 200:
    data = response.json()
    print (pd.DataFrame(data).T)  # Transpose for better readability
else:
        print("Failed to retrieve data")

# Specify the cryptocurrencies you want to check
cryptos_ids = ['bitcoin&vs_currencies=usd&x_cg_pro_api_key=CG-4TqTQv39JuPvRFmz3dz5Kcff',
               'ethereum&vs_currencies=usd&x_cg_pro_api_key=CG-4TqTQv39JuPvRFmz3dz5Kcff',
               'ripple&vs_currencies=usd&x_cg_pro_api_key=CG-4TqTQv39JuPvRFmz3dz5Kcff']

# Get current prices
prices = get_crypto_prices(cryptos_ids)

print(prices)