community[patch]: fix a bug that mistakenly handle zip iterator in FAISS.from_embeddings (#16020)

**Description**: `zip` is iterator that will only produce result once,
so the previous code will cause the `embeddings` to be an empty list.

**Issue**: I could not find a related issue.

**Dependencies**: this PR does not introduce or affect dependencies.

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
pull/16049/head
Neo Zhao 6 months ago committed by GitHub
parent 15c2b4a47e
commit 21e0df937f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -986,11 +986,10 @@ class FAISS(VectorStore):
text_embedding_pairs = zip(texts, text_embeddings)
faiss = FAISS.from_embeddings(text_embedding_pairs, embeddings)
"""
texts = [t[0] for t in text_embeddings]
embeddings = [t[1] for t in text_embeddings]
texts, embeddings = zip(*text_embeddings)
return cls.__from(
texts,
embeddings,
list(texts),
list(embeddings),
embedding,
metadatas=metadatas,
ids=ids,

Loading…
Cancel
Save