Almaatla commited on
Commit
f621dca
·
verified ·
1 Parent(s): dbfd408

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -64,13 +64,14 @@ def get_database_length():
64
 
65
  @app.post("/admin/database/reset")
66
  def reset_database():
67
- index.reset()
 
68
  return {"message": "Database reset"}
69
 
70
  @app.get("/admin/documents/download")
71
  def download_documents():
72
  # Convert the documents list to a JSON string
73
- documents_json = json.dumps(documents)
74
 
75
  # Create a response with the JSON string as the content
76
  response = Response(content=documents_json, media_type="application/json")
@@ -99,7 +100,7 @@ def upload_database(file: UploadFile = File(...)):
99
  contents = file.file.read()
100
 
101
  # Load the FAISS index from the file contents
102
- index = faiss.read_index_binary(contents)
103
 
104
  # Clear the existing documents and add the new ones
105
  documents.clear()
 
64
 
65
  @app.post("/admin/database/reset")
66
  def reset_database():
67
+ index = faiss.IndexFlatL2(384)
68
+ documents = []
69
  return {"message": "Database reset"}
70
 
71
  @app.get("/admin/documents/download")
72
  def download_documents():
73
  # Convert the documents list to a JSON string
74
+ documents_json = json.dumps([{text: doc} for doc in documents])
75
 
76
  # Create a response with the JSON string as the content
77
  response = Response(content=documents_json, media_type="application/json")
 
100
  contents = file.file.read()
101
 
102
  # Load the FAISS index from the file contents
103
+ index = faiss.read_index_binary(contents.encode())
104
 
105
  # Clear the existing documents and add the new ones
106
  documents.clear()