File size: 1,266 Bytes
26b566a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# app/routes/pipeline.py
import os
import requests
from fastapi import APIRouter, Depends, Query
from datetime import datetime
from agent_manager import AgentManager
from memory.database import init_db, log_action
from app.dependencies import require_api_key
router = APIRouter(
prefix="/pipeline",
tags=["Pipeline"],
dependencies=[Depends(require_api_key)]
)
WEBHOOK_URL = os.getenv("ZAPIER_WEBHOOK") # Set this in HF Secrets
@router.on_event("startup")
def startup_db():
init_db()
@router.get("/run", summary="Run full multi‑agent pipeline")
def run_pipeline(
niche: str = Query("fitness"),
business_type: str = Query("dropshipping")
):
manager = AgentManager(niche, business_type)
summary = manager.run_all()
# Log each step
for agent_name, result in summary.items():
log_action(agent_name, "pipeline_run", result)
payload = {
"niche": niche,
"business_type": business_type,
"results": summary,
"timestamp": datetime.utcnow().isoformat()
}
# Fire the Zapier webhook (non‑blocking)
try:
requests.post(WEBHOOK_URL, json=payload, timeout=2)
except Exception:
pass
return {
"status": "pipeline_executed",
**payload
}
|