-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
39 lines (34 loc) · 978 Bytes
/
app.py
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
from fastapi import FastAPI, Request
import uvicorn
from dotenv import load_dotenv
from pydantic import BaseModel
from supervisor_workflow import SupervisorWorkflow
from crag_agent import process_request_crag
load_dotenv()
app = FastAPI()
supervised_workflow = SupervisorWorkflow()
supervised_chain = supervised_workflow.gen_chain()
# TODO manage request body
class SupervisorData(BaseModel):
message: str
user_id: str
thread_id: str
# TODO provide the thread_id and the user_id
@app.post("/supervisor")
async def supervisor(supervisor_request: SupervisorData):
request_body = supervisor_request.model_dump()
message = request_body["message"]
reply = supervised_chain.invoke(
message,
{
"recursion_limit": 150,
"user_id": "[email protected]",
"thread_id": "16"
},
)
print(reply['response'])
return {
"data": {
"message": reply['response']
}
}