Spaces:
Running
Running
Update analytics_tool.py
Browse files- tools/analytics_tool.py +12 -10
tools/analytics_tool.py
CHANGED
|
@@ -1,23 +1,25 @@
|
|
| 1 |
from crewai.tools import BaseTool
|
| 2 |
from pydantic import BaseModel, Field
|
|
|
|
| 3 |
|
| 4 |
|
| 5 |
# ---------- Input Schema ----------
|
| 6 |
class AnalyticsInput(BaseModel):
|
| 7 |
-
market_data:
|
| 8 |
-
historical_data:
|
| 9 |
-
sentiment_data:
|
| 10 |
|
| 11 |
|
| 12 |
# ---------- Tool ----------
|
| 13 |
class AnalyticsTool(BaseTool):
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
def _run(self, market_data: dict, historical_data: dict, sentiment_data: dict) -> dict:
|
| 23 |
try:
|
|
|
|
| 1 |
from crewai.tools import BaseTool
|
| 2 |
from pydantic import BaseModel, Field
|
| 3 |
+
from typing import Dict, Any, Type
|
| 4 |
|
| 5 |
|
| 6 |
# ---------- Input Schema ----------
|
| 7 |
class AnalyticsInput(BaseModel):
|
| 8 |
+
market_data: str | Dict[str, Any] = Field(..., description="Structured JSON from MarketDataTool")
|
| 9 |
+
historical_data: str | Dict[str, Any] = Field(..., description="Structured JSON from HistoricalDataTool")
|
| 10 |
+
sentiment_data: str | Dict[str, Any] = Field(..., description="Structured JSON from SentimentTool")
|
| 11 |
|
| 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:
|