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
No known key found for this signature in database
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): def get_documents_ids_distances(self, search_strings: list[str], n_results: int):
n_results = min(len(self.ids), n_results) n_results = min(len(self.ids), n_results)
if n_results == 0: if n_results == 0:
return [], [] return [], [], []
result = self.collection.query(query_texts=search_strings, n_results=n_results, include=['documents', 'distances']) result = self.collection.query(query_texts=search_strings, n_results=n_results, include=['documents', 'distances'])
documents = result['documents'][0] documents = result['documents'][0]