mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-25 08:03:39 +00:00
added i_end in batch extraction (#907)
Fix for issue #906 Switches `[i : i + batch_size]` to `[i : i_end]` in Pinecone `from_texts` method
This commit is contained in:
parent
82c080c6e6
commit
3aa53b44dd
@ -198,17 +198,17 @@ class Pinecone(VectorStore):
|
|||||||
# set end position of batch
|
# set end position of batch
|
||||||
i_end = min(i + batch_size, len(texts))
|
i_end = min(i + batch_size, len(texts))
|
||||||
# get batch of texts and ids
|
# get batch of texts and ids
|
||||||
lines_batch = texts[i : i + batch_size]
|
lines_batch = texts[i:i_end]
|
||||||
# create ids if not provided
|
# create ids if not provided
|
||||||
if ids:
|
if ids:
|
||||||
ids_batch = ids[i : i + batch_size]
|
ids_batch = ids[i:i_end]
|
||||||
else:
|
else:
|
||||||
ids_batch = [str(uuid.uuid4()) for n in range(i, i_end)]
|
ids_batch = [str(uuid.uuid4()) for n in range(i, i_end)]
|
||||||
# create embeddings
|
# create embeddings
|
||||||
embeds = embedding.embed_documents(lines_batch)
|
embeds = embedding.embed_documents(lines_batch)
|
||||||
# prep metadata and upsert batch
|
# prep metadata and upsert batch
|
||||||
if metadatas:
|
if metadatas:
|
||||||
metadata = metadatas[i : i + batch_size]
|
metadata = metadatas[i:i_end]
|
||||||
else:
|
else:
|
||||||
metadata = [{} for _ in range(i, i_end)]
|
metadata = [{} for _ in range(i, i_end)]
|
||||||
for j, line in enumerate(lines_batch):
|
for j, line in enumerate(lines_batch):
|
||||||
|
Loading…
Reference in New Issue
Block a user