vikramvasudevan commited on
Commit
ceb171d
·
verified ·
1 Parent(s): 17f2f08

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. server.py +19 -6
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
- results = db.fetch_all_matches(
331
- collection_name=config["collection_name"],
332
- metadata_where_clause=filter_obj,
333
- page=None, # Fetch all to apply audio filter
334
- page_size=None,
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"])):