Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -46,11 +46,18 @@ class QueryResponse(BaseModel):
|
|
| 46 |
|
| 47 |
@app.post("/query", response_model=QueryResponse)
|
| 48 |
async def query(req: QueryRequest):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
if not _indexes_loaded():
|
| 50 |
raise HTTPException(
|
| 51 |
status_code=503,
|
| 52 |
detail="Indexes not ready. Upload and index documents first."
|
| 53 |
)
|
|
|
|
|
|
|
| 54 |
|
| 55 |
results = hybrid_retrieve(req.question, top_k=req.top_k)
|
| 56 |
if not results:
|
|
|
|
| 46 |
|
| 47 |
@app.post("/query", response_model=QueryResponse)
|
| 48 |
async def query(req: QueryRequest):
|
| 49 |
+
if not _indexes_loaded():
|
| 50 |
+
try:
|
| 51 |
+
load_indexes()
|
| 52 |
+
except Exception:
|
| 53 |
+
pass
|
| 54 |
if not _indexes_loaded():
|
| 55 |
raise HTTPException(
|
| 56 |
status_code=503,
|
| 57 |
detail="Indexes not ready. Upload and index documents first."
|
| 58 |
)
|
| 59 |
+
results = hybrid_retrieve(req.question, top_k=req.top_k)
|
| 60 |
+
)
|
| 61 |
|
| 62 |
results = hybrid_retrieve(req.question, top_k=req.top_k)
|
| 63 |
if not results:
|