File size: 1,526 Bytes
fc83728
9b5b26a
5357699
5df72d6
672b80f
23fb26e
 
 
 
 
 
 
 
9b5b26a
 
5357699
c8e47b9
8c01ffb
5357699
687468d
00964f5
 
5357699
 
 
e1db81a
23fb26e
5357699
 
687468d
5357699
 
 
a96c9cc
5357699
 
687468d
5357699
 
9b5b26a
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
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: str, currency='usd'):

    """This is a tool to get current crypto token market prices in usd currency using the coingecko api.
    Args:
        args1: crypto_ids= Input for crypto_ids is a string
        args2: currency= Output for currency is an integer
        
    Responses: 
        You should return all valid requests with the crypto id, and its current price in usd denominations.
    """
    
    url = f"https://api.coingecko.com/api/v3/simple/price?ids={','.join(crypto_ids)}&vs_currencies={currency}"
    response = requests.get(url)
    
    if response.status_code == 200:
        data = response.json()
        return pd.DataFrame(data).T  # Transpose for better readability
    else:
        print("Failed to retrieve data")
        return None

# Specify the cryptocurrencies you want to check
cryptos = ['bitcoin', 'ethereum', 'ripple']

# Get current prices
prices = get_crypto_prices(cryptos)
print(prices)