Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,24 @@ import requests # Import the requests library
|
|
11 |
from bs4 import BeautifulSoup #for parsing
|
12 |
from urllib.parse import quote
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
@tool
|
15 |
def get_full_poem(verse: str) -> str:
|
16 |
"""
|
|
|
11 |
from bs4 import BeautifulSoup #for parsing
|
12 |
from urllib.parse import quote
|
13 |
|
14 |
+
|
15 |
+
@tool
|
16 |
+
def get_crypto_price(crypto: str, currency: str = "usd") -> str:
|
17 |
+
"""
|
18 |
+
Fetches and returns the current price of a given cryptocurrency as a formatted USD string.
|
19 |
+
|
20 |
+
Args:
|
21 |
+
crypto: The ID of the cryptocurrency (e.g., 'bitcoin').
|
22 |
+
currency: The currency in which to return the price (default is 'usd').
|
23 |
+
"""
|
24 |
+
url = f"https://api.coingecko.com/api/v3/simple/price?ids={crypto}&vs_currencies={currency}"
|
25 |
+
try:
|
26 |
+
data = requests.get(url).json()
|
27 |
+
price = float(data[crypto][currency])
|
28 |
+
return f"${price:,.2f}"
|
29 |
+
except Exception as e:
|
30 |
+
return f"Error: {e}"
|
31 |
+
|
32 |
@tool
|
33 |
def get_full_poem(verse: str) -> str:
|
34 |
"""
|