mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-13 12:55:19 +00:00
refactor: Removed more swallows
Signed-off-by: Anush008 <anushshetty90@gmail.com>
This commit is contained in:
parent
0ac57a088f
commit
c8a49d373a
1 changed files with 18 additions and 30 deletions
|
|
@ -225,16 +225,12 @@ class QdrantClient(VectorDBBase):
|
||||||
elif filter:
|
elif filter:
|
||||||
must_conditions += [_metadata_filter(k, v) for k, v in filter.items()]
|
must_conditions += [_metadata_filter(k, v) for k, v in filter.items()]
|
||||||
|
|
||||||
try:
|
return self.client.delete(
|
||||||
return self.client.delete(
|
collection_name=mt_collection,
|
||||||
collection_name=mt_collection,
|
points_selector=models.FilterSelector(
|
||||||
points_selector=models.FilterSelector(
|
filter=models.Filter(must=must_conditions, should=should_conditions)
|
||||||
filter=models.Filter(must=must_conditions, should=should_conditions)
|
),
|
||||||
),
|
)
|
||||||
)
|
|
||||||
except Exception as e:
|
|
||||||
log.warning(f"Error deleting from collection {mt_collection}: {e}")
|
|
||||||
return None
|
|
||||||
|
|
||||||
def search(
|
def search(
|
||||||
self, collection_name: str, vectors: List[List[float | int]], limit: int
|
self, collection_name: str, vectors: List[List[float | int]], limit: int
|
||||||
|
|
@ -281,16 +277,12 @@ class QdrantClient(VectorDBBase):
|
||||||
tenant_filter = _tenant_filter(tenant_id)
|
tenant_filter = _tenant_filter(tenant_id)
|
||||||
field_conditions = [_metadata_filter(k, v) for k, v in filter.items()]
|
field_conditions = [_metadata_filter(k, v) for k, v in filter.items()]
|
||||||
combined_filter = models.Filter(must=[tenant_filter, *field_conditions])
|
combined_filter = models.Filter(must=[tenant_filter, *field_conditions])
|
||||||
try:
|
points = self.client.query_points(
|
||||||
points = self.client.query_points(
|
collection_name=mt_collection,
|
||||||
collection_name=mt_collection,
|
query_filter=combined_filter,
|
||||||
query_filter=combined_filter,
|
limit=limit,
|
||||||
limit=limit,
|
)
|
||||||
)
|
return self._result_to_get_result(points.points)
|
||||||
return self._result_to_get_result(points.points)
|
|
||||||
except Exception as e:
|
|
||||||
log.exception(f"Error querying collection '{collection_name}': {e}")
|
|
||||||
return None
|
|
||||||
|
|
||||||
def get(self, collection_name: str) -> Optional[GetResult]:
|
def get(self, collection_name: str) -> Optional[GetResult]:
|
||||||
"""
|
"""
|
||||||
|
|
@ -303,16 +295,12 @@ class QdrantClient(VectorDBBase):
|
||||||
log.debug(f"Collection {mt_collection} doesn't exist, get returns None")
|
log.debug(f"Collection {mt_collection} doesn't exist, get returns None")
|
||||||
return None
|
return None
|
||||||
tenant_filter = _tenant_filter(tenant_id)
|
tenant_filter = _tenant_filter(tenant_id)
|
||||||
try:
|
points = self.client.query_points(
|
||||||
points = self.client.query_points(
|
collection_name=mt_collection,
|
||||||
collection_name=mt_collection,
|
query_filter=models.Filter(must=[tenant_filter]),
|
||||||
query_filter=models.Filter(must=[tenant_filter]),
|
limit=NO_LIMIT,
|
||||||
limit=NO_LIMIT,
|
)
|
||||||
)
|
return self._result_to_get_result(points.points)
|
||||||
return self._result_to_get_result(points.points)
|
|
||||||
except Exception as e:
|
|
||||||
log.exception(f"Error getting collection '{collection_name}': {e}")
|
|
||||||
return None
|
|
||||||
|
|
||||||
def upsert(self, collection_name: str, items: List[VectorItem]):
|
def upsert(self, collection_name: str, items: List[VectorItem]):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue