Spaces:
Running
Running
fix chroma embeddings when an already seen file is uplaoded
Browse files
document_qa/document_qa_engine.py
CHANGED
@@ -205,11 +205,16 @@ class DocumentQAEngine:
|
|
205 |
if doc_id:
|
206 |
hash = doc_id
|
207 |
else:
|
208 |
-
|
209 |
hash = metadata[0]['hash']
|
210 |
|
211 |
if hash not in self.embeddings_dict.keys():
|
212 |
-
self.embeddings_dict[hash] = Chroma.from_texts(texts, embedding=self.embedding_function, metadatas=metadata,
|
|
|
|
|
|
|
|
|
|
|
|
|
213 |
|
214 |
self.embeddings_root_path = None
|
215 |
|
|
|
205 |
if doc_id:
|
206 |
hash = doc_id
|
207 |
else:
|
|
|
208 |
hash = metadata[0]['hash']
|
209 |
|
210 |
if hash not in self.embeddings_dict.keys():
|
211 |
+
self.embeddings_dict[hash] = Chroma.from_texts(texts, embedding=self.embedding_function, metadatas=metadata,
|
212 |
+
collection_name=hash)
|
213 |
+
else:
|
214 |
+
self.embeddings_dict[hash].delete(ids=self.embeddings_dict[hash].get()['ids'])
|
215 |
+
self.embeddings_dict[hash] = Chroma.from_texts(texts, embedding=self.embedding_function, metadatas=metadata,
|
216 |
+
collection_name=hash)
|
217 |
+
|
218 |
|
219 |
self.embeddings_root_path = None
|
220 |
|