feat: add AI Digital Employee agent orchestrator with pipeline tracking
- New AgentPipeline model with JSONB pipeline_data for stages/leads/summary
- AgentOrchestrator service chains DiscoveryService search→analyze→outreach→auto-save
- 3 new API endpoints: POST /agent/start, GET /agent/pipelines, GET /agent/{id}
- Full Agent dashboard Vue component with stats, pipeline grid, leads table, outreach preview
- Sidebar redesigned with AI Agent as primary entry point
- Updated PROGRESS.md, AGENTS.md, DATABASE_SCHEMA.md with latest state
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from pydantic import BaseModel
|
||||
|
||||
from app.database import get_db
|
||||
from app.api.v1.deps import get_current_user_id
|
||||
from app.services.agent_orchestrator import AgentOrchestrator
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
class StartPipelineRequest(BaseModel):
|
||||
product_name: str
|
||||
product_description: str = ""
|
||||
target_market: str
|
||||
|
||||
|
||||
@router.post("/start")
|
||||
async def start_pipeline(
|
||||
req: StartPipelineRequest,
|
||||
user_id: str = Depends(get_current_user_id),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
orchestrator = AgentOrchestrator(db)
|
||||
result = await orchestrator.start_pipeline(
|
||||
user_id=user_id,
|
||||
product_name=req.product_name,
|
||||
product_description=req.product_description,
|
||||
target_market=req.target_market,
|
||||
)
|
||||
return {"code": 0, "data": result}
|
||||
|
||||
|
||||
@router.get("/pipelines")
|
||||
async def list_pipelines(
|
||||
page: int = Query(1, ge=1),
|
||||
size: int = Query(20, ge=1, le=100),
|
||||
user_id: str = Depends(get_current_user_id),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
orchestrator = AgentOrchestrator(db)
|
||||
result = await orchestrator.list_pipelines(user_id, page=page, size=size)
|
||||
return {"code": 0, "data": result}
|
||||
|
||||
|
||||
@router.get("/{pipeline_id}")
|
||||
async def get_pipeline(
|
||||
pipeline_id: str,
|
||||
user_id: str = Depends(get_current_user_id),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
orchestrator = AgentOrchestrator(db)
|
||||
result = await orchestrator.get_pipeline(pipeline_id, user_id)
|
||||
if not result:
|
||||
raise HTTPException(status_code=404, detail="Pipeline not found")
|
||||
return {"code": 0, "data": result}
|
||||
Reference in New Issue
Block a user