cicboy commited on
Commit
a0a8d76
·
1 Parent(s): d872892

update tools

Browse files
tools/analytics_tool.py CHANGED
@@ -12,14 +12,13 @@ class AnalyticsInput(BaseModel):
12
 
13
  # ---------- Tool ----------
14
  class AnalyticsTool(BaseTool):
 
 
 
 
 
 
15
  args_schema: Type[BaseModel] = AnalyticsInput
16
- class Config:
17
- name = "analytics_tool"
18
- description = (
19
- "Aggregates structured market, historical, and sentiment data to produce "
20
- "quantitative indicators including pct_change, volatility, trend, sentiment, "
21
- "alignment consistency, and a composite confidence score."
22
- )
23
 
24
  def _run(self, market_data: dict, historical_data: dict, sentiment_data: dict) -> dict:
25
  try:
 
12
 
13
  # ---------- Tool ----------
14
  class AnalyticsTool(BaseTool):
15
+ name: str = "analytics_tool"
16
+ description: str = (
17
+ "Aggregates structured market, historical, and sentiment data to produce "
18
+ "quantitative indicators including pct_change, volatility, trend, sentiment, "
19
+ "alignment consistency, and a composite confidence score."
20
+ )
21
  args_schema: Type[BaseModel] = AnalyticsInput
 
 
 
 
 
 
 
22
 
23
  def _run(self, market_data: dict, historical_data: dict, sentiment_data: dict) -> dict:
24
  try:
tools/historical_data_tool.py CHANGED
@@ -15,14 +15,12 @@ class HistoricalInput(BaseModel):
15
 
16
  # ---------- Tool ----------
17
  class HistoricalDataTool(BaseTool):
 
 
 
 
 
18
  args_schema: Type[BaseModel] = HistoricalInput
19
-
20
- class Config:
21
- name = "get_historical_data"
22
- description = (
23
- "Fetches historical cryptocurrency market data from CoinGecko and computes "
24
- "trend, percent change, and volatility. Returns structured JSON."
25
- )
26
 
27
  def _run(self, symbol: str = "bitcoin", currency: str = "usd", days: int = 30) -> dict:
28
  url = f"https://api.coingecko.com/api/v3/coins/{symbol}/market_chart"
 
15
 
16
  # ---------- Tool ----------
17
  class HistoricalDataTool(BaseTool):
18
+ name: str = "get_historical_data"
19
+ description: str = (
20
+ "Fetches historical cryptocurrency market data from CoinGecko and computes "
21
+ "trend, percent change, and volatility. Returns structured JSON."
22
+ )
23
  args_schema: Type[BaseModel] = HistoricalInput
 
 
 
 
 
 
 
24
 
25
  def _run(self, symbol: str = "bitcoin", currency: str = "usd", days: int = 30) -> dict:
26
  url = f"https://api.coingecko.com/api/v3/coins/{symbol}/market_chart"
tools/market_data.py CHANGED
@@ -11,13 +11,12 @@ class MarketDataInput(BaseModel):
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
  """
 
11
 
12
  # ---------- Tool ----------
13
  class MarketDataTool(BaseTool):
14
+ name: str = "get_market_data"
15
+ description: str = (
16
+ "Fetches the current market price of a cryptocurrency "
17
+ "in a chosen fiat currency using the CoinGecko API."
18
+ )
19
  args_schema: Type[BaseModel] = MarketDataInput
 
 
 
 
 
 
20
 
21
  def _run(self, symbol: str = "bitcoin", currency: str = "usd") -> dict:
22
  """
tools/sentiment_tool.py CHANGED
@@ -2,18 +2,24 @@ import os
2
  import requests
3
  from crewai.tools import BaseTool
4
  from openai import OpenAI
 
 
5
 
6
  SERPER_API_KEY = os.getenv(key="SERPER_API_KEY")
7
  OPENAI_API_KEY = os.getenv(key = "OPENAI_API_KEY")
8
 
9
  client = OpenAI(api_key=OPENAI_API_KEY)
10
 
 
 
 
11
  class SentimentTool(BaseTool):
12
  name: str = "get_crypto_sentiment"
13
  description: str = (
14
  "Fetches recent cryptocurrency news and Reddit discussions,"
15
  "then analyses sentiment as bullish, bearish or neutral."
16
  )
 
17
 
18
  def _run(self, query: str = "bitcoin") -> str:
19
  try:
 
2
  import requests
3
  from crewai.tools import BaseTool
4
  from openai import OpenAI
5
+ from typing import Type
6
+ from pydantic import BaseModel, Field
7
 
8
  SERPER_API_KEY = os.getenv(key="SERPER_API_KEY")
9
  OPENAI_API_KEY = os.getenv(key = "OPENAI_API_KEY")
10
 
11
  client = OpenAI(api_key=OPENAI_API_KEY)
12
 
13
+ class SentimentInput(BaseModel):
14
+ query: str = Field(default="bitcoin", description="Cryptocurrency name to evaluate sentiment for.")
15
+
16
  class SentimentTool(BaseTool):
17
  name: str = "get_crypto_sentiment"
18
  description: str = (
19
  "Fetches recent cryptocurrency news and Reddit discussions,"
20
  "then analyses sentiment as bullish, bearish or neutral."
21
  )
22
+ arg_schema: Type[BaseModel] = SentimentInput
23
 
24
  def _run(self, query: str = "bitcoin") -> str:
25
  try: