Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -110,17 +110,22 @@ def retrieve_document(query):
|
|
| 110 |
return None
|
| 111 |
|
| 112 |
try:
|
| 113 |
-
|
| 114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
byte_stream = io.BytesIO(embeddings_.content)
|
| 116 |
-
|
| 117 |
-
#
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
|
|
|
| 124 |
|
| 125 |
except Exception as e:
|
| 126 |
print(f"Error loading FAISS index: {e}")
|
|
|
|
| 110 |
return None
|
| 111 |
|
| 112 |
try:
|
| 113 |
+
print("Response content length:", len(embeddings_.content)) # Debugging
|
| 114 |
+
|
| 115 |
+
if len(embeddings_.content) == 0:
|
| 116 |
+
raise ValueError("Received empty FAISS index file")
|
| 117 |
+
|
| 118 |
+
# Convert response content to a byte stream
|
| 119 |
byte_stream = io.BytesIO(embeddings_.content)
|
| 120 |
+
|
| 121 |
+
# Write the received binary content to a temporary file
|
| 122 |
+
with open("downloaded_index.bin", "wb") as f:
|
| 123 |
+
f.write(byte_stream.read())
|
| 124 |
+
|
| 125 |
+
# Load FAISS index from file
|
| 126 |
+
index = faiss.read_index("downloaded_index.bin")
|
| 127 |
+
|
| 128 |
+
print(f"✅ Successfully loaded FAISS index with {index.ntotal} vectors.")
|
| 129 |
|
| 130 |
except Exception as e:
|
| 131 |
print(f"Error loading FAISS index: {e}")
|