Pinecone Error in Python

I have installed pinecone-client in my python virtual environment. I do a pip list in that folder and I find pinecone-client 2.2.1. In VS Code I have created code in which I want to use langchain and PGT to query a pdf file. I am using code I found on github.

The code fails with the following error: “AttributeError: module ‘pinecone’ has no attribute ‘from_texts’”

Here is the code: Any ideas would be much appreciated:

import langchain
import pypdf
import os
import pinecone

from langchain.document_loaders import UnstructuredPDFLoader, OnlinePDFLoader, PyPDFLoader

from langchain.text_splitter import RecursiveCharacterTextSplitter

loader = PyPDFLoader(“C:/venv/input_file.pdf”)
data = loader.load()
print (f’You have {len(data)} document(s) in your data’)
print (f’There are {len(data[30].page_content)} characters in your document’)

text_splitter = RecursiveCharacterTextSplitter(chunk_size=2000, chunk_overlap=0)
texts = text_splitter.split_documents(data)

print (f’Now you have {len(texts)} documents’)
from langchain.vectorstores import chroma, pinecone

from langchain.embeddings.openai import OpenAIEmbeddings

OPENAI_API_KEY = os.environ.get(‘OPENAI_API_KEY’, ‘YourAPIKey’)

OPENAI_API_KEY = os.environ.get(‘OPENAI_API_KEY’, ‘YourAPIKey’)

PINECONE_API_KEY = os.environ.get(‘PINECONE_API_KEY’, ‘YourAPIKey’)

pinecone.init(
api_key=PINECONE_API_KEY, # find at app.pinecone.io

)

index_name = “langchaintest” # put in the name of your pinecone index here

docsearch =pinecone.from_texts([t.page_content for t in texts], embeddings, index_name=index_name)

query = “What illnesses does the patient suffer from?”
docs = docsearch.similarity_search(query)

try by adding the following import and:
from langchain.vectorstores import Pinecone

then change …pinecone.from_texts… to:
docsearch = Pinecone.from_texts([t.page_content for t in texts], embeddings, index_name=index_name)