Fix get_documents_ids_distances return error when n_results = 0 (#2347)

This commit is contained in:
Luis Lopez 2023-05-26 10:25:36 +08:00 committed by GitHub
parent 07a4f0569f
commit 0dbc3d9b2c
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 4AEE18F83AFDEB23

View file

@ -50,7 +50,7 @@ class ChromaCollector(Collecter):
def get_documents_ids_distances(self, search_strings: list[str], n_results: int):
n_results = min(len(self.ids), n_results)
if n_results == 0:
return [], []
return [], [], []
result = self.collection.query(query_texts=search_strings, n_results=n_results, include=['documents', 'distances'])
documents = result['documents'][0]