diff --git a/document_qa/document_qa_engine.py b/document_qa/document_qa_engine.py index c9d8fc4..3e0e070 100644 --- a/document_qa/document_qa_engine.py +++ b/document_qa/document_qa_engine.py @@ -251,14 +251,14 @@ def create_memory_embeddings(self, pdf_path, doc_id=None, chunk_size=500, perc_o else: hash = metadata[0]['hash'] - if hash not in self.embeddings_dict.keys() and ( - 'documents' in self.embeddings_dict[hash].get() and len(self.embeddings_dict[hash].get()['documents']) == 0): + if hash not in self.embeddings_dict.keys(): self.embeddings_dict[hash] = Chroma.from_texts(texts, embedding=self.embedding_function, metadatas=metadata, collection_name=hash) else: - self.embeddings_dict[hash].delete(ids=self.embeddings_dict[hash].get()['ids']) + if 'documents' in self.embeddings_dict[hash].get() and len(self.embeddings_dict[hash].get()['documents']) == 0: + self.embeddings_dict[hash].delete(ids=self.embeddings_dict[hash].get()['ids']) self.embeddings_dict[hash] = Chroma.from_texts(texts, embedding=self.embedding_function, metadatas=metadata,