Closed Mukku27 closed 2 months ago
@Mukku27 Thank you for raising this issue.
The Python Pinecone SDK does not have the function from_text()
that's usually provided by Langchain. There was an issue when using an older version of Langchain where there could be a Python namespace name collision, so I would ensure that it is up to date and you have made the code changes,
If you can share the code or the Colab, we can help you further.
You might also find our Langchain guide. useful too
This is one cell of the whole notebook
Thank you for the code. Unfortunately, it's incorrect. As I mentioned previously, Pinecone does not have a from_text
function. It comes from Langchain.
Here is the correct way to use from_texts()
from Langchain.
import os
from langchain_pinecone import PineconeVectorStore
from langchain_openai import OpenAIEmbeddings
from langchain_community.document_loaders import TextLoader
from langchain_text_splitters import CharacterTextSplitter
os.environ['OPENAI_API_KEY'] = '<YOUR_OPENAI_API_KEY>'
os.environ['PINECONE_API_KEY'] = '<YOUR_PINECONE_API_KEY>'
index_name = "<YOUR_PINECONE_INDEX_NAME>"
embeddings = OpenAIEmbeddings()
texts = ["Tonight, I call on the Senate to: Pass the Freedom to Vote Act.", "ne of the most serious constitutional responsibilities a President has is nominating someone to serve on the United States Supreme Court.", "One of our nation’s top legal minds, who will continue Justice Breyer’s legacy of excellence."]
vectorstore_from_texts = PineconeVectorStore.from_texts(
texts,
index_name=index_name,
embedding=embeddings
)
There are examples in our Langchain guide.
Thank you @mcpaddy
Describe the bug When attempting to create an embedding using Pinecone in a Google Colab notebook, an
AttributeError
is raised. The functionality that was working previously to generate embeddings from text chunks is now broken.Error information The full stack trace of the error is as follows:
Steps to reproduce the issue locally
Environment
pinecone-io/pinecone-python-client
(latest version installed via pip)Additional context The issue seems to be related to a name collision between Pinecone's
from_texts
method and another dependency that might be wrapping Pinecone functionality. I am using the notebook environment in Google Colab, and a screenshot of the error is attached for reference.