Skip to content

Commit

Permalink
fix: Qdrant's delete method (#73)
Browse files Browse the repository at this point in the history
* fix: qdrant delete method

* chore: update .env.example

* Fix formatting

---------

Co-authored-by: Ismail Pelaseyed <homanp@gmail.com>
  • Loading branch information
elisalimli and homanp authored Mar 2, 2024
1 parent c91900e commit db5c57a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ PINECONE_API_KEY=
PINECONE_HOST=
PINECONE_INDEX=

# Unstructured API
UNSTRUCTURED_IO_API_KEY=
UNSTRUCTURED_IO_SERVER_URL=
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ venv
.venv
.env
__pycache__/
.DS_Store
25 changes: 25 additions & 0 deletions vectordbs/qdrant.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from semantic_router.encoders import BaseEncoder
from tqdm import tqdm

from models.delete import DeleteResponse
from models.document import BaseDocumentChunk
from vectordbs.base import BaseVectorDatabase

Expand Down Expand Up @@ -89,6 +90,28 @@ async def query(self, input: str, top_k: int = MAX_QUERY_TOP_K) -> List:
]

async def delete(self, file_url: str) -> None:
# client.count(
# collection_name="{collection_name}",
# count_filter=models.Filter(
# must=[
# models.FieldCondition(key="color", match=models.MatchValue(value="red")),
# ]
# ),
# exact=True,
# )

deleted_chunks = self.client.count(
collection_name=self.index_name,
count_filter=rest.Filter(
must=[
rest.FieldCondition(
key="file_url", match=rest.MatchValue(value=file_url)
)
]
),
exact=True,
)

self.client.delete(
collection_name=self.index_name,
points_selector=rest.FilterSelector(
Expand All @@ -101,3 +124,5 @@ async def delete(self, file_url: str) -> None:
)
),
)

return DeleteResponse(num_of_deleted_chunks=deleted_chunks.count)

0 comments on commit db5c57a

Please sign in to comment.