Skip to content

Commit

Permalink
Add the check on data deletion and returns boolean value
Browse files Browse the repository at this point in the history
Fix formatting
  • Loading branch information
ranjan-stha committed Sep 16, 2024
1 parent c73756b commit a14e0ef
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions chatbot-core/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import uuid
from dataclasses import dataclass, field

import qdrant_client.http.models as q_models
from django.conf import settings
from qdrant_client import QdrantClient
from qdrant_client.http.exceptions import UnexpectedResponse
Expand Down Expand Up @@ -73,10 +74,12 @@ def data_search(
# Note the results shall contain score key; sort the results using score key and get top 5 among them.
return results

def delete_data_by_src_uuid(self, collection_name: str, doc_uuid: uuid.UUID, key: str = "doc_uuid") -> None:
def delete_data_by_src_uuid(self, collection_name: str, doc_uuid: uuid.UUID, key: str = "doc_uuid") -> bool:
"""
Delete data by source uuid
Note that the document source key should be doc_uuid
"""
points_selector = FilterSelector(filter=Filter(must=[FieldCondition(key=key, match=MatchValue(value=doc_uuid))]))
self.db_client.delete(collection_name=collection_name, points_selector=points_selector)
result = self.db_client.delete(collection_name=collection_name, points_selector=points_selector)

return result.status == q_models.UpdateStatus.COMPLETED

0 comments on commit a14e0ef

Please sign in to comment.