Skip to content

Commit

Permalink
Use any key value pair for filtering and deletion;
Browse files Browse the repository at this point in the history
  • Loading branch information
ranjan-stha committed Sep 17, 2024
1 parent a14e0ef commit f6fed13
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions chatbot-core/database.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
import uuid
from dataclasses import dataclass, field
from typing import Any

import qdrant_client.http.models as q_models
from django.conf import settings
Expand Down Expand Up @@ -74,12 +75,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") -> bool:
def delete_data_by_src_uuid(self, collection_name: str, key: str, value: Any) -> 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))]))
points_selector = FilterSelector(filter=Filter(must=[FieldCondition(key=key, match=MatchValue(value=value))]))
result = self.db_client.delete(collection_name=collection_name, points_selector=points_selector)

return result.status == q_models.UpdateStatus.COMPLETED

0 comments on commit f6fed13

Please sign in to comment.