cicboy commited on
Commit
7b0b449
·
1 Parent(s): a0c219b

Update market_data.py

Browse files
Files changed (1) hide show
  1. 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(..., description="Cryptocurrency ID in CoinGecko format, e.g., 'bitcoin'")
9
- currency: str = Field(default="usd", description="Fiat currency, e.g., 'usd', 'eur', 'gbp'")
10
-
11
 
12
  # ---------- Tool ----------
13
  class MarketDataTool(BaseTool):
14
- name = "get_market_data"
15
- description = (
16
- "Fetches structured market data for a cryptocurrency including price and 24h volume "
17
- "using the CoinGecko API."
18
- )
19
- args_schema = MarketDataInput
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: