File size: 703 Bytes
1f0fa9b | 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 | import sys
from pathlib import Path
# Ensure Backend directory is in sys.path and load root .env
BACKEND_DIR = Path(__file__).resolve().parent.parent
if str(BACKEND_DIR) not in sys.path:
sys.path.insert(0, str(BACKEND_DIR))
import config
from fastapi import FastAPI, HTTPException
from schemas.agent_spec import AgentSpec
from executor.executor import execute_spec
app = FastAPI(title="Agent Execution API")
@app.post("/execute")
def execute(spec: AgentSpec):
try:
result = execute_spec(spec)
return {"result": result}
except Exception as e:
raise HTTPException(
status_code=500,
detail=f"Error executing agent spec: {str(e)}"
)
|