Spaces:
Running
on
L4
Running
on
L4
Upload folder using huggingface_hub
Browse files
main.py
CHANGED
|
@@ -189,8 +189,6 @@ async def get(request, query: str, nn: bool = True):
|
|
| 189 |
print(
|
| 190 |
f"Search results fetched in {end - start:.2f} seconds, Vespa says searchtime was {result['timing']['searchtime']} seconds"
|
| 191 |
)
|
| 192 |
-
# Add result to cache
|
| 193 |
-
result_cache.set(query_id, result)
|
| 194 |
# Start generating the similarity map in the background
|
| 195 |
asyncio.create_task(
|
| 196 |
generate_similarity_map(
|
|
@@ -272,10 +270,15 @@ async def get_sim_map(query_id: str, idx: int, token: str):
|
|
| 272 |
|
| 273 |
async def update_full_image_cache(docid: str, query_id: str, idx: int, image_data: str):
|
| 274 |
result = result_cache.get(query_id)
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 279 |
result_cache.set(query_id, result)
|
| 280 |
return
|
| 281 |
|
|
|
|
| 189 |
print(
|
| 190 |
f"Search results fetched in {end - start:.2f} seconds, Vespa says searchtime was {result['timing']['searchtime']} seconds"
|
| 191 |
)
|
|
|
|
|
|
|
| 192 |
# Start generating the similarity map in the background
|
| 193 |
asyncio.create_task(
|
| 194 |
generate_similarity_map(
|
|
|
|
| 270 |
|
| 271 |
async def update_full_image_cache(docid: str, query_id: str, idx: int, image_data: str):
|
| 272 |
result = result_cache.get(query_id)
|
| 273 |
+
if result is None:
|
| 274 |
+
await asyncio.sleep(0.5)
|
| 275 |
+
return
|
| 276 |
+
search_results = get_results_children(result)
|
| 277 |
+
# Check if idx exists in list of children
|
| 278 |
+
if idx >= len(search_results):
|
| 279 |
+
await asyncio.sleep(0.5)
|
| 280 |
+
return
|
| 281 |
+
search_results[idx]["fields"]["full_image"] = image_data
|
| 282 |
result_cache.set(query_id, result)
|
| 283 |
return
|
| 284 |
|