Merge pull request #9 from Introspect-AI/main

Fix: Fix broken indexing – only first two text chunks are indexed
pull/11/head
namuan 1 year ago committed by GitHub
commit 23696e9961
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -168,8 +168,8 @@ class CreateIndex(WorkflowBase):
embedding: str
@retry(exceptions=openai.error.RateLimitError, tries=2, delay=60, back_off=2)
def append_to_index(self, docsearch: FAISS, text: str, embeddings: Embeddings) -> None:
docsearch.from_texts([text], embeddings)
def append_to_index(self, docsearch: FAISS, text: str) -> None:
docsearch.add_texts([text])
def embedding_from_selection(self) -> Embeddings:
if self.embedding == "huggingface":
@ -199,7 +199,7 @@ class CreateIndex(WorkflowBase):
embeddings = self.embedding_from_selection()
docsearch: FAISS = FAISS.from_texts(self.chunked_text_list[:2], embeddings)
for text in self.chunked_text_list[2:]:
self.append_to_index(docsearch, text, embeddings)
self.append_to_index(docsearch, text)
faiss.write_index(docsearch.index, index_path.as_posix())
with open(faiss_db, "wb") as f:

Loading…
Cancel
Save