minor fixes on deleting

This commit is contained in:
Alex 2023-10-04 13:57:40 +01:00
parent 94f3533c29
commit 8320cca5cd
2 changed files with 7 additions and 7 deletions

View File

@ -1,8 +1,7 @@
OPENAI_API_KEY=<LLM api key (for example, open ai key)>
SELF_HOSTED_MODEL=false
API_KEY=<LLM api key (for example, open ai key)>
VITE_API_STREAMING=true
#For Azure
#For Azure (you can delete it if you don't use Azure)
OPENAI_API_BASE=
OPENAI_API_VERSION=
AZURE_DEPLOYMENT_NAME=

View File

@ -84,13 +84,14 @@ def delete_old():
path = request.args.get("path")
dirs = path.split("/")
dirs_clean = []
for i in range(1, len(dirs)):
for i in range(0, len(dirs)):
dirs_clean.append(secure_filename(dirs[i]))
# check that path strats with indexes or vectors
if dirs[0] not in ["indexes", "vectors"]:
if dirs_clean[0] not in ["indexes", "vectors"]:
return {"status": "error"}
path_clean = "/".join(dirs)
vectors_collection.delete_one({"location": path})
path_clean = "/".join(dirs_clean)
vectors_collection.delete_one({"name": dirs_clean[-1], 'user': dirs_clean[-2]})
if settings.VECTOR_STORE == "faiss":
try:
shutil.rmtree(os.path.join(current_dir, path_clean))