Create pipeline.py
Browse files- app/routes/pipeline.py +34 -0
app/routes/pipeline.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# app/routes/pipeline.py
|
2 |
+
|
3 |
+
from fastapi import APIRouter, Depends, Query
|
4 |
+
from datetime import datetime
|
5 |
+
from agent_manager import AgentManager
|
6 |
+
from memory.database import init_db, log_action
|
7 |
+
from app.dependencies import require_api_key
|
8 |
+
|
9 |
+
router = APIRouter(
|
10 |
+
prefix="/pipeline",
|
11 |
+
tags=["Pipeline"],
|
12 |
+
dependencies=[Depends(require_api_key)]
|
13 |
+
)
|
14 |
+
|
15 |
+
@router.on_event("startup")
|
16 |
+
def startup_db():
|
17 |
+
init_db()
|
18 |
+
|
19 |
+
@router.get("/run", summary="Run full multi‑agent pipeline")
|
20 |
+
def run_pipeline(
|
21 |
+
niche: str = Query("fitness"),
|
22 |
+
business_type: str = Query("dropshipping")
|
23 |
+
):
|
24 |
+
manager = AgentManager(niche, business_type)
|
25 |
+
summary = manager.run_all()
|
26 |
+
for agent_name, result in summary.items():
|
27 |
+
log_action(agent_name, "pipeline_run", result)
|
28 |
+
return {
|
29 |
+
"status": "pipeline_executed",
|
30 |
+
"niche": niche,
|
31 |
+
"business_type": business_type,
|
32 |
+
"results": summary,
|
33 |
+
"timestamp": datetime.utcnow().isoformat()
|
34 |
+
}
|