AttributeError: type object 'Pinecone' has no attribute 'from_documents' - python error

Code :

# import Libraries

import openai
import langchain
from langchain.document_loaders import PyPDFDirectoryLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.vectorstores import Pinecone
from langchain_community.document_loaders import JSONLoader
from langchain.llms import OpenAI
import os
import tiktoken
# from pinecone import Pinecone, ServerlessSpec

loader = JSONLoader(
    file_path='./flattened_data.json',
    jq_schema='{text: .[].text,subtopic: .[].subtopic}',
    text_content=False)

doc = loader.load()

def chunk_data(docs,chunk_size=800,chunk_overlap=50):
    text_splitter=RecursiveCharacterTextSplitter(chunk_size=chunk_size,chunk_overlap=chunk_overlap)
    doc=text_splitter.split_documents(docs)
    return docs

documents=chunk_data(docs=doc)
len(documents)

OPENAI_API_KEY = ""

## Embedding Technique Of OPENAI
embeddings = OpenAIEmbeddings(openai_api_key=OPENAI_API_KEY)
embeddings

vectors=embeddings.embed_query("How are you?")
len(vectors)

# from pinecone import Pinecone, ServerlessSpec
from pinecone import Pinecone

# Vector Search DB In Pinecone
pc = Pinecone(api_key="f64528b3-04f3-42bd-85ae-290f9ecda596")
index_name = "langchainvector"

index=Pinecone.from_documents(doc,embeddings,index_name=index_name)

Error :

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-15-4f0666e40ba9> in <cell line: 1>()
----> 1 index=Pinecone.from_documents(doc,embeddings,index_name=index_name)

AttributeError: type object 'Pinecone' has no attribute 'from_documents'

Hi @joshichiragbhai4444. Please make sure you’re using the latest versions of both Langchain and the Pinecone SDK. There have been some fixes lately to resolve this namespace collision. Specifically, Langchain renamed their Pinecone class to be PineconeVectorStore.

pip install -U pinecone-client langchain

Then you’ll update your import statements to use the latest versions:

from langchain import PineconeVectorStore
from pinecone import Pinecone

Can you please give me my code with new version changes?