Skip to content

Commit

Permalink
Merge pull request #577 from shivanandmn/faiss_delete_index
Browse files Browse the repository at this point in the history
added delete index of vector store in faiss
  • Loading branch information
dartpain authored Oct 22, 2023
2 parents 641e75b + 21ba1e3 commit 6490027
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 13 additions & 0 deletions application/api/user/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ def api_feedback():
)
return {"status": http.client.responses.get(response.status_code, "ok")}

@user.route("/api/delete_by_ids", methods=["get"])
def delete_by_ids():
"""Delete by ID. These are the IDs in the vectorstore"""

ids = request.args.get("path")
if not ids:
return {"status": "error"}

if settings.VECTOR_STORE == "faiss":
result = vectors_collection.delete_index(ids=ids)
if result:
return {"status": "ok"}
return {"status": "error"}

@user.route("/api/delete_old", methods=["get"])
def delete_old():
Expand Down
6 changes: 4 additions & 2 deletions application/vectorstore/faiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def add_texts(self, *args, **kwargs):
def save_local(self, *args, **kwargs):
return self.docsearch.save_local(*args, **kwargs)

def delete_index(self, *args, **kwargs):
return self.docsearch.delete(*args, **kwargs)

def assert_embedding_dimensions(self, embeddings):
"""
Check that the word embedding dimension of the docsearch index matches
Expand All @@ -40,5 +43,4 @@ def assert_embedding_dimensions(self, embeddings):
docsearch_index_dimension = self.docsearch.index.d
if word_embedding_dimension != docsearch_index_dimension:
raise ValueError(f"word_embedding_dimension ({word_embedding_dimension}) " +
f"!= docsearch_index_word_embedding_dimension ({docsearch_index_dimension})")

f"!= docsearch_index_word_embedding_dimension ({docsearch_index_dimension})")

2 comments on commit 6490027

@vercel
Copy link

@vercel vercel bot commented on 6490027 Oct 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs-gpt – ./frontend

docs-gpt-git-main-arc53.vercel.app
docs-gpt-arc53.vercel.app
docs-gpt-brown.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 6490027 Oct 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nextra-docsgpt – ./docs

nextra-docsgpt-arc53.vercel.app
nextra-docsgpt-git-main-arc53.vercel.app
nextra-docsgpt.vercel.app
docs.docsgpt.co.uk

Please sign in to comment.