-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
40 lines (35 loc) · 983 Bytes
/
Copy pathmain.py
File metadata and controls
40 lines (35 loc) · 983 Bytes
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
import os
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel
from core.agents import agent_network
from tracing.logger import execution_traces
app = FastAPI(title="Autonomous AI Agent Network API")
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
class QueryRequest(BaseModel):
query: str
@app.post("/api/run")
async def run_network(payload: QueryRequest):
execution_traces.clear()
initial_state = {
"query": payload.query,
"research_notes": "",
"data_analysis": "",
"final_report": "",
"logs": []
}
output = agent_network.invoke(initial_state)
return {
"status": "SUCCESS",
"final_report": output["final_report"],
"traces": execution_traces
}
@app.get("/api/traces")
async def get_traces():
return {"traces": execution_traces}