mem0
mem0 copied to clipboard
Fix: Solve IndexError when no relevant documents are found in the vector db.
This PR will solve the following problem. When no similar document is found in the vector database or the vector database is empty,result_formatted[0][0].page_content will be triggered and IndexError will be triggered.
eg:
result = self.collection.query(
query_texts=[input_query,],
n_results=1,
)
# the result will be:
# {'ids': [[]], 'embeddings': None, 'documents': [[]], 'metadatas': [[]], 'distances': [[]]}
# and then, result_formatted = self._format_result(result) will return empty list.
# []