Skip to content
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

fix chroma only retrieving one source #132

Merged
merged 2 commits into from
Oct 29, 2023
Merged

fix chroma only retrieving one source #132

merged 2 commits into from
Oct 29, 2023

Conversation

pmeier
Copy link
Member

@pmeier pmeier commented Oct 29, 2023

Offline report from @dharhas.

@@ -96,19 +96,19 @@ def retrieve(
include=["distances", "metadatas", "documents"],
)

num_results = len(result["ids"])
num_results = len(result["ids"][0])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the actual fix. For some reason, result["ids"] is a list, which contains nothing but another list, which ultimately holds the IDs we are after here.

result = {
key: [None] * num_results if value is None else value[0] # type: ignore[index]
for key, value in result.items()
}
# dict of lists -> list of dicts
results = [
{key: value[idx] for key, value in result.items()}
{key[:-1]: value[idx] for key, value in result.items()}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignoring the last character here drops the "s" and thus makes the keys singular. Might sound nitpicky here, but I found myself confused when looking at the source again and having something like id=result["ids"] in the Source instantiation below.

@dharhas dharhas self-requested a review October 29, 2023 22:37
@dharhas dharhas merged commit 223aa4c into main Oct 29, 2023
10 checks passed
@dharhas dharhas deleted the fix-chroma branch October 29, 2023 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants