Skip to content

Fix #2960 by checking if the values are a list of lists. #2971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions autogen/agentchat/contrib/vectordb/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,20 @@ def chroma_results_to_query_results(data_dict: Dict[str, List[List[Any]]], speci
]
"""

keys = [key for key in data_dict if key != special_key]
keys = [
key
for key in data_dict
if key != special_key and data_dict[key] is not None and isinstance(data_dict[key][0], list)
]
result = []
data_special_key = data_dict[special_key]

for i in range(len(data_dict[special_key])):
for i in range(len(data_special_key)):
sub_result = []
for j, distance in enumerate(data_dict[special_key][i]):
for j, distance in enumerate(data_special_key[i]):
sub_dict = {}
for key in keys:
if data_dict[key] is not None and len(data_dict[key]) > i:
if len(data_dict[key]) > i:
sub_dict[key[:-1]] = data_dict[key][i][j] # remove 's' in the end from key
sub_result.append((sub_dict, distance))
result.append(sub_result)
Expand Down
Loading