Spaces:
Runtime error
Runtime error
Update app/main.py
Browse files- app/main.py +20 -36
app/main.py
CHANGED
|
@@ -1,36 +1,20 @@
|
|
| 1 |
-
from fastapi import FastAPI
|
| 2 |
-
from app.rag import find_top_5_ayahs_qdrant
|
| 3 |
-
from app.models.schemas import QuestionRequest, AnswerListResponse
|
| 4 |
-
import psutil, os, asyncio
|
| 5 |
-
|
| 6 |
-
app = FastAPI()
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
asyncio.create_task(monitor())
|
| 22 |
-
|
| 23 |
-
@app.post("/ask/", response_model=AnswerListResponse)
|
| 24 |
-
def ask(payload: QuestionRequest):
|
| 25 |
-
results = find_top_5_ayahs_qdrant(payload.question)
|
| 26 |
-
return {"results": results}
|
| 27 |
-
|
| 28 |
-
@app.get("/")
|
| 29 |
-
def read_root():
|
| 30 |
-
return {"message": "Hello, Mustafa! FastAPI is running 🚀"}
|
| 31 |
-
|
| 32 |
-
@app.get("/memory")
|
| 33 |
-
def memory_endpoint():
|
| 34 |
-
"""Check memory usage manually via /memory"""
|
| 35 |
-
mem = get_memory_usage_mb()
|
| 36 |
-
return {"memory_MB": round(mem, 2)}
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from app.rag import find_top_5_ayahs_qdrant
|
| 3 |
+
from app.models.schemas import QuestionRequest, AnswerListResponse
|
| 4 |
+
import psutil, os, asyncio
|
| 5 |
+
|
| 6 |
+
app = FastAPI()
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
@app.post("/ask/", response_model=AnswerListResponse)
|
| 12 |
+
def ask(payload: QuestionRequest):
|
| 13 |
+
results = find_top_5_ayahs_qdrant(payload.question)
|
| 14 |
+
return {"results": results}
|
| 15 |
+
|
| 16 |
+
@app.get("/")
|
| 17 |
+
def read_root():
|
| 18 |
+
return {"message": "Hello, Mustafa! FastAPI is running 🚀"}
|
| 19 |
+
|
| 20 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|