Spaces:
Sleeping
Sleeping
Upload analytics_pipeline.py
Browse files- agents/analytics_pipeline.py +51 -0
agents/analytics_pipeline.py
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
from google.adk.agents import LlmAgent
|
3 |
+
from tools.csv_parser import parse_csv_tool
|
4 |
+
from tools.plot_generator import plot_sales_tool
|
5 |
+
from tools.forecaster import forecast_tool
|
6 |
+
|
7 |
+
trend_detector_agent = LlmAgent(
|
8 |
+
name="trend_detector_agent",
|
9 |
+
model="gemini-2.5-pro-exp-03-25",
|
10 |
+
description="Detects trends and anomalies in business data.",
|
11 |
+
instruction="""
|
12 |
+
Analyze the input table. Identify major trends, seasonal patterns,
|
13 |
+
and anomalies (spikes or drops). Return a concise summary.
|
14 |
+
""",
|
15 |
+
tools=[parse_csv_tool, plot_sales_tool]
|
16 |
+
)
|
17 |
+
|
18 |
+
forecast_agent = LlmAgent(
|
19 |
+
name="forecast_agent",
|
20 |
+
model="gemini-2.5-pro-exp-03-25",
|
21 |
+
description="Forecasts future metrics from time series data.",
|
22 |
+
instruction="""
|
23 |
+
Forecast next 3 months of sales based on historical patterns.
|
24 |
+
Use the forecast tool to generate a visual chart.
|
25 |
+
""",
|
26 |
+
tools=[forecast_tool]
|
27 |
+
)
|
28 |
+
|
29 |
+
strategy_agent = LlmAgent(
|
30 |
+
name="strategy_agent",
|
31 |
+
model="gemini-2.5-pro-exp-03-25",
|
32 |
+
description="Recommends strategic business decisions.",
|
33 |
+
instruction="""
|
34 |
+
Based on trends and forecasts, suggest optimization strategies
|
35 |
+
across marketing, operations, and finance (ROI, CAC, churn).
|
36 |
+
"""
|
37 |
+
)
|
38 |
+
|
39 |
+
analytics_coordinator = LlmAgent(
|
40 |
+
name="analytics_coordinator",
|
41 |
+
model="gemini-2.5-pro-exp-03-25",
|
42 |
+
description="Coordinates full BI pipeline: trends, forecast, strategy.",
|
43 |
+
instruction="""
|
44 |
+
Run the following:
|
45 |
+
1. Analyze the CSV with trend_detector_agent
|
46 |
+
2. Forecast future metrics using forecast_agent
|
47 |
+
3. Recommend business strategies using strategy_agent
|
48 |
+
Return a full dashboard-style summary.
|
49 |
+
""",
|
50 |
+
sub_agents=[trend_detector_agent, forecast_agent, strategy_agent]
|
51 |
+
)
|