Update app.py
Browse files
app.py
CHANGED
|
@@ -95,6 +95,19 @@ def upload_documents(request: EmbedRequest):
|
|
| 95 |
|
| 96 |
@app.get("/admin/database/download")
|
| 97 |
def download_database():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
# Save the FAISS index and documents list to a single file
|
| 99 |
data = {
|
| 100 |
"index": faiss.write_index_binary(index),
|
|
|
|
| 95 |
|
| 96 |
@app.get("/admin/database/download")
|
| 97 |
def download_database():
|
| 98 |
+
# Save the FAISS index to a file
|
| 99 |
+
faiss.write_index(index, "database.index")
|
| 100 |
+
|
| 101 |
+
# Create a response with the index file as the content
|
| 102 |
+
response = FileResponse("database.index")
|
| 103 |
+
|
| 104 |
+
# Set the content disposition header to trigger a download
|
| 105 |
+
response.headers["Content-Disposition"] = "attachment; filename=database.index"
|
| 106 |
+
|
| 107 |
+
return response
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
def download_database_0():
|
| 111 |
# Save the FAISS index and documents list to a single file
|
| 112 |
data = {
|
| 113 |
"index": faiss.write_index_binary(index),
|