#Creating Embeddings for Each of The Text Chunks & storing
docsearch=Pinecone.from_texts([t.page_content for t in text_chunks], embeddings, index_name=index_name)
KINDLY HELP ME OVERCOME THIS ERROR AND WHAT CAN I USE INSTEAD FROM_TEXTS
#Creating Embeddings for Each of The Text Chunks & storing
docsearch=Pinecone.from_texts([t.page_content for t in text_chunks], embeddings, index_name=index_name)
KINDLY HELP ME OVERCOME THIS ERROR AND WHAT CAN I USE INSTEAD FROM_TEXTS
from tqdm.auto import tqdm
from uuid import uuid4
batch_limit = 100
texts =
metadatas =
for i, document in enumerate(tqdm(extracted_data)):
# Extract metadata from the document
metadata = {
‘source’: document.metadata[‘source’],
‘page no’: document.metadata[‘page’]
}
# Extract text content from the document
text = document.page_content # Assuming ‘page_content’ contains the text content
# Now we create chunks from the text content
record_texts = text_splitter.split_text(text)
# Create individual metadata dicts for each chunk
record_metadatas = [{
“chunk”: j, “text”: text, **metadata
} for j, text in enumerate(record_texts)]
# Append these to current batches
texts.extend(record_texts)
metadatas.extend(record_metadatas)
# If we have reached the batch_limit we can add texts
if len(texts) >= batch_limit:
ids = [str(uuid4()) for _ in range(len(texts))]
embeds = embeddings.embed_documents(texts)
index.upsert(vectors=zip(ids, embeds, metadatas))
texts =
metadatas =
if len(texts) > 0:
ids = [str(uuid4()) for _ in range(len(texts))]
embeds = embeddings.embed_documents(texts)
index.upsert(vectors=zip(ids, embeds, metadatas))
Take this as reference .Worked for me.
This error occurs when using Langchain due to a namespace collision. The Python classes for both Langchain and Pinecone have classes named Pinecone.
To fix this, change the import statement:
from langchain.vectorstores import Pinecone as PineconeStore
When referencing the class, use PineconeStore, e.g.
docsearch=PineconeStore.from_texts(
[t.page_content for t in text_chunks],
embeddings,
index_name=index_name
)
Source: Pinecone has no attribute 'from_texts' when using Langchain – Pinecone Support
@manmeetroorkee Can you please share where you saw this instruction so that we can help address the root of the issue? If you can share a link to the video/tutorial/documentation, that would be most helpful. Thanks!
dear zeke using pineconestore also it is still giving error..not able to run properly
@manmeetroorkee Please share the complete code you are trying to run, including the import statements, and the full stack trace of the error message you encounter.
Hey @zeke
I am experiencing the same issue.
After following the instructions, I am faced with a different error:
PineconeConfigurationError: You haven’t specified an Api-Key.
I am having a hard time finding the method to initialize Pinecone imported from langchain.vectorstores. Could You help me out?