-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathapp.py
More file actions
28 lines (23 loc) · 845 Bytes
/
app.py
File metadata and controls
28 lines (23 loc) · 845 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
# app.py
from fastapi import FastAPI, UploadFile, Form
from orchestrator import (
initialize_rag,
handle_insert,
handle_query
)
app = FastAPI()
@app.on_event("startup")
async def startup_event():
await initialize_rag()
print("Server started successfully!")
@app.post("/insert")
async def insert(query: str = Form(...), video: UploadFile = None, audio: UploadFile = None, image: UploadFile = None):
try:
entry = await handle_insert(query, video, audio, image)
return {"status": "ok", "entry": entry}
except Exception as e:
return {"status": "error", "message": str(e)}
@app.post("/query")
async def query_api(query: str = Form(...), mode: str = Form("hybrid"), use_pm: bool = Form(False)):
result = await handle_query(query, mode, use_pm)
return {"status": "ok", **result}