nothingworry's picture
working the rag and web server
2f235a0
raw
history blame
1.36 kB
# =============================================================
# File: backend/api/routes/agent.py
# =============================================================
from fastapi import APIRouter
from pydantic import BaseModel
import os
import sys
from pathlib import Path
# Add backend to path for imports
backend_dir = Path(__file__).parent.parent.parent
sys.path.insert(0, str(backend_dir))
from api.services.agent_orchestrator import AgentOrchestrator
from api.models.agent import AgentRequest, AgentResponse
router = APIRouter()
orchestrator = AgentOrchestrator(
rag_mcp_url=os.getenv("RAG_MCP_URL", "http://localhost:8001"),
web_mcp_url=os.getenv("WEB_MCP_URL", "http://localhost:8002"),
admin_mcp_url=os.getenv("ADMIN_MCP_URL", "http://localhost:8003"),
llm_backend=os.getenv("LLM_BACKEND", "ollama")
)
class ChatRequest(BaseModel):
tenant_id: str
user_id: str | None = None
message: str
conversation_history: list[dict] = []
temperature: float = 0.0
@router.post("/message", response_model=AgentResponse)
async def agent_chat(req: ChatRequest):
agent_req = AgentRequest(
tenant_id=req.tenant_id,
user_id=req.user_id,
message=req.message,
conversation_history=req.conversation_history,
temperature=req.temperature
)
return await orchestrator.handle(agent_req)