Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -86,15 +86,9 @@ def retrieve_document(query):
|
|
| 86 |
print(f"Error fetching metadata: {metadata_.status_code} - {metadata_.text}")
|
| 87 |
return None
|
| 88 |
|
| 89 |
-
# Save the FAISS file temporarily
|
| 90 |
-
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
|
| 91 |
-
for chunk in embeddings_.iter_content(chunk_size=8192):
|
| 92 |
-
temp_file.write(chunk)
|
| 93 |
-
temp_path = temp_file.name # Store file path
|
| 94 |
-
|
| 95 |
try:
|
| 96 |
-
# Load FAISS index from file
|
| 97 |
-
index = faiss.read_index(
|
| 98 |
print(f"Successfully loaded FAISS index with {index.ntotal} vectors.")
|
| 99 |
|
| 100 |
except Exception as e:
|
|
|
|
| 86 |
print(f"Error fetching metadata: {metadata_.status_code} - {metadata_.text}")
|
| 87 |
return None
|
| 88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
try:
|
| 90 |
+
# Load FAISS index from response content (treat as file-like object)
|
| 91 |
+
index = faiss.read_index(io.BytesIO(embeddings_.content))
|
| 92 |
print(f"Successfully loaded FAISS index with {index.ntotal} vectors.")
|
| 93 |
|
| 94 |
except Exception as e:
|