Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Upload folder using huggingface_hub
Browse files
server.py
CHANGED
|
@@ -280,7 +280,7 @@ async def get_scripture_configs():
|
|
| 280 |
"credits", {"art": [], "data": [], "audio": [], "video": []}
|
| 281 |
),
|
| 282 |
"metadata_fields": metadata_fields,
|
| 283 |
-
"field_mapping"
|
| 284 |
}
|
| 285 |
)
|
| 286 |
|
|
@@ -332,7 +332,9 @@ async def search_scripture_find_first_match(
|
|
| 332 |
metadata_doc = results["metadatas"][i]
|
| 333 |
metadata_doc["id"] = doc_id
|
| 334 |
|
| 335 |
-
document_text =
|
|
|
|
|
|
|
| 336 |
canonical_doc = SanatanConfig().canonicalize_document(
|
| 337 |
scripture_name, document_text, metadata_doc
|
| 338 |
)
|
|
@@ -352,7 +354,9 @@ async def search_scripture_find_first_match(
|
|
| 352 |
all_audio_indices.update(indices)
|
| 353 |
|
| 354 |
formatted_results = [
|
| 355 |
-
r
|
|
|
|
|
|
|
| 356 |
]
|
| 357 |
else:
|
| 358 |
audio_indices = set()
|
|
@@ -363,10 +367,14 @@ async def search_scripture_find_first_match(
|
|
| 363 |
AudioType.upanyasam,
|
| 364 |
AudioType.santhai,
|
| 365 |
]:
|
| 366 |
-
indices = await svc_get_indices_with_audio(
|
|
|
|
|
|
|
| 367 |
audio_indices.update(indices)
|
| 368 |
else:
|
| 369 |
-
audio_indices.update(
|
|
|
|
|
|
|
| 370 |
|
| 371 |
formatted_results = [
|
| 372 |
r for r in formatted_results if r["_global_index"] in audio_indices
|
|
@@ -383,7 +391,6 @@ async def search_scripture_find_first_match(
|
|
| 383 |
return {"error": str(e)}
|
| 384 |
|
| 385 |
|
| 386 |
-
|
| 387 |
class ScriptureMultiSearchRequest(BaseModel):
|
| 388 |
filter_obj: Optional[MetadataWhereClause] = None
|
| 389 |
page: int = 1
|
|
@@ -528,3 +535,14 @@ async def generate_audio_urls(req: VideoRequest):
|
|
| 528 |
@router.get("/scripture_categories")
|
| 529 |
def route_get_scripture_categories():
|
| 530 |
return get_scripture_categories()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 280 |
"credits", {"art": [], "data": [], "audio": [], "video": []}
|
| 281 |
),
|
| 282 |
"metadata_fields": metadata_fields,
|
| 283 |
+
"field_mapping": config.remove_callables(s.get("field_mapping", {})),
|
| 284 |
}
|
| 285 |
)
|
| 286 |
|
|
|
|
| 332 |
metadata_doc = results["metadatas"][i]
|
| 333 |
metadata_doc["id"] = doc_id
|
| 334 |
|
| 335 |
+
document_text = (
|
| 336 |
+
results["documents"][i] if results.get("documents") else None
|
| 337 |
+
)
|
| 338 |
canonical_doc = SanatanConfig().canonicalize_document(
|
| 339 |
scripture_name, document_text, metadata_doc
|
| 340 |
)
|
|
|
|
| 354 |
all_audio_indices.update(indices)
|
| 355 |
|
| 356 |
formatted_results = [
|
| 357 |
+
r
|
| 358 |
+
for r in formatted_results
|
| 359 |
+
if r["_global_index"] not in all_audio_indices
|
| 360 |
]
|
| 361 |
else:
|
| 362 |
audio_indices = set()
|
|
|
|
| 367 |
AudioType.upanyasam,
|
| 368 |
AudioType.santhai,
|
| 369 |
]:
|
| 370 |
+
indices = await svc_get_indices_with_audio(
|
| 371 |
+
scripture_name, atype
|
| 372 |
+
)
|
| 373 |
audio_indices.update(indices)
|
| 374 |
else:
|
| 375 |
+
audio_indices.update(
|
| 376 |
+
await svc_get_indices_with_audio(scripture_name, has_audio)
|
| 377 |
+
)
|
| 378 |
|
| 379 |
formatted_results = [
|
| 380 |
r for r in formatted_results if r["_global_index"] in audio_indices
|
|
|
|
| 391 |
return {"error": str(e)}
|
| 392 |
|
| 393 |
|
|
|
|
| 394 |
class ScriptureMultiSearchRequest(BaseModel):
|
| 395 |
filter_obj: Optional[MetadataWhereClause] = None
|
| 396 |
page: int = 1
|
|
|
|
| 535 |
@router.get("/scripture_categories")
|
| 536 |
def route_get_scripture_categories():
|
| 537 |
return get_scripture_categories()
|
| 538 |
+
|
| 539 |
+
|
| 540 |
+
@router.get("/donation/products")
|
| 541 |
+
def route_get_donation_product_ids():
|
| 542 |
+
return [
|
| 543 |
+
{"id": "donation_unit_100"},
|
| 544 |
+
{"id": "donation_unit_500"},
|
| 545 |
+
{"id": "donation_unit_1000"},
|
| 546 |
+
{"id": "donation_unit_2500"},
|
| 547 |
+
{"id": "donation_unit_5000"},
|
| 548 |
+
]
|