From b142f6244186bb8d3c1a9d4c742eab7e14f0755c Mon Sep 17 00:00:00 2001 From: Mohammad Amin Dadgar <48308230+amindadgar@users.noreply.github.com> Date: Thu, 11 Apr 2024 10:53:28 +0330 Subject: [PATCH] Update bot/retrievers/retrieve_similar_nodes.py Add group_by_metadata validation Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- bot/retrievers/retrieve_similar_nodes.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/bot/retrievers/retrieve_similar_nodes.py b/bot/retrievers/retrieve_similar_nodes.py index 678b502..ddd80c5 100644 --- a/bot/retrievers/retrieve_similar_nodes.py +++ b/bot/retrievers/retrieve_similar_nodes.py @@ -57,14 +57,11 @@ def query_db( Note: This would completely disable the similarity search and it would just return the results with no ordering. default is `False`. If `True` the query will be ignored and no embedding of it would be fetched - aggregate_records : bool - aggregate records and group by a given term in `group_by_metadata` - group_by_metadata : list[str] - do grouping by some property of `metadata_` - """ ignore_sort = kwargs.get("ignore_sort", False) aggregate_records = kwargs.get("aggregate_records", False) group_by_metadata = kwargs.get("group_by_metadata", []) + if not isinstance(group_by_metadata, list): + raise ValueError("Expected 'group_by_metadata' to be a list.") self._vector_store._initialize() if not aggregate_records: