Spaces:
Running
Running
Update market_data.py
Browse files- tools/market_data.py +11 -10
tools/market_data.py
CHANGED
|
@@ -1,23 +1,24 @@
|
|
| 1 |
import requests
|
| 2 |
from crewai.tools import BaseTool
|
| 3 |
from pydantic import BaseModel, Field
|
|
|
|
| 4 |
|
| 5 |
|
| 6 |
# ---------- Input Schema ----------
|
| 7 |
class MarketDataInput(BaseModel):
|
| 8 |
-
symbol: str = Field(
|
| 9 |
-
currency: str = Field(default="usd", description="Fiat currency
|
| 10 |
-
|
| 11 |
|
| 12 |
# ---------- Tool ----------
|
| 13 |
class MarketDataTool(BaseTool):
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
| 21 |
def _run(self, symbol: str = "bitcoin", currency: str = "usd") -> dict:
|
| 22 |
"""
|
| 23 |
Returns structured JSON:
|
|
|
|
| 1 |
import requests
|
| 2 |
from crewai.tools import BaseTool
|
| 3 |
from pydantic import BaseModel, Field
|
| 4 |
+
from typing import Type
|
| 5 |
|
| 6 |
|
| 7 |
# ---------- Input Schema ----------
|
| 8 |
class MarketDataInput(BaseModel):
|
| 9 |
+
symbol: str = Field(default="bitcoin", description="Crypto asset ID on CoinGecko")
|
| 10 |
+
currency: str = Field(default="usd", description="Fiat currency (usd, eur, etc.)")
|
|
|
|
| 11 |
|
| 12 |
# ---------- Tool ----------
|
| 13 |
class MarketDataTool(BaseTool):
|
| 14 |
+
args_schema = Type[BaseModel] = MarketDataInput
|
| 15 |
+
class config:
|
| 16 |
+
name = "get_market_data"
|
| 17 |
+
description = (
|
| 18 |
+
"Fetches the current market price of a cryptocurrency "
|
| 19 |
+
"in a chosen fiat currency using the CoinGecko API."
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
def _run(self, symbol: str = "bitcoin", currency: str = "usd") -> dict:
|
| 23 |
"""
|
| 24 |
Returns structured JSON:
|