Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Upload folder using huggingface_hub
Browse files
server.py
CHANGED
|
@@ -327,12 +327,25 @@ async def search_scripture_find_first_match(
|
|
| 327 |
return {"error": f"Scripture '{scripture_name}' not found"}
|
| 328 |
|
| 329 |
# 1️⃣ Fetch all matches
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 336 |
|
| 337 |
formatted_results = []
|
| 338 |
for i in range(len(results["metadatas"])):
|
|
|
|
| 327 |
return {"error": f"Scripture '{scripture_name}' not found"}
|
| 328 |
|
| 329 |
# 1️⃣ Fetch all matches
|
| 330 |
+
if has_audio:
|
| 331 |
+
results = db.fetch_all_matches(
|
| 332 |
+
collection_name=config["collection_name"],
|
| 333 |
+
metadata_where_clause=filter_obj,
|
| 334 |
+
page=None, # Fetch all to apply audio filter
|
| 335 |
+
page_size=None,
|
| 336 |
+
)
|
| 337 |
+
else:
|
| 338 |
+
# optimization. get only first match if no has_audio parameter is provided.
|
| 339 |
+
result = db.fetch_first_match(
|
| 340 |
+
collection_name=config["collection_name"],
|
| 341 |
+
metadata_where_clause=filter_obj,
|
| 342 |
+
)
|
| 343 |
+
results = {
|
| 344 |
+
"ids": list(result["ids"]),
|
| 345 |
+
"documents": list(result["documents"]),
|
| 346 |
+
"metadatas": list(result["metadatas"]),
|
| 347 |
+
"total_matches": 1,
|
| 348 |
+
}
|
| 349 |
|
| 350 |
formatted_results = []
|
| 351 |
for i in range(len(results["metadatas"])):
|