Issue: Pinecone Embeddings - Error
Labels: name: area: vector store, name: auto:bug, name: integration: pinecone

### Issue you'd like to raise.

Hi there, 

I am creating a simple PDF reading application where I want to push my embeddings into Pinecone. 

Here is my code:
## Imports
import streamlit as st
import os
from apikey import apikey
import pickle
from PyPDF2 import PdfReader

# Streamlit - user interface
from streamlit_extras.add_vertical_space import add_vertical_space

# Langchain
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.vectorstores import FAISS
from langchain.llms import OpenAI
from langchain.chains.question_answering import load_qa_chain
from langchain.callbacks import get_openai_callback
from langchain.chat_models.openai import ChatOpenAI
from langchain.schema import (SystemMessage, HumanMessage, AIMessage)
from langchain.document_loaders import UnstructuredPDFLoader

# Pinecone
from langchain.vectorstores import Pinecone
import pinecone
from apikey import pinecone_api_key
import uuid


os.environ['OPENAI_API_KEY'] = apikey

## User Interface
# Side Bar
with st.sidebar:
    st.title('🚀 Zi-GPT Version 2.0')
    st.markdown('''
    ## About
    This app is an LLM-powered chatbot built using:
    - [Streamlit](https://streamlit.io/)
    - [LangChain](https://python.langchain.com/)
    - [OpenAI](https://platform.openai.com/docs/models) LLM model
 
    ''')
    add_vertical_space(5)
    st.write('Made with ❤️ by Zi')

# Main Page
def main():
    st.header("Zi's PDF Helper: Chat with PDF")

    # upload a PDF file
    pdf = st.file_uploader("Please upload your PDF here", type='pdf')
    # st.write(pdf)

    # read PDF
    if pdf is not None: 
        pdf_reader = PdfReader(pdf)
        # data = pdf_reader.load()
        
        # split document into chunks
        # also can use text split: good for PDFs that do not contains charts and visuals
        sections = []
        for page in pdf_reader.pages:
            # Split the page text by paragraphs (assuming two newlines indicate a new paragraph)
            page_sections = page.extract_text().split('\n\n')
            sections.extend(page_sections)

        chunks = sections
        # st.write(chunks)
        
        # text_splitter = RecursiveCharacterTextSplitter(
            # chunk_size = 500,
            # chunk_overlap = 20
        # )
        
        # chunks = text_splitter.split_documents(data)

        ## embeddings
        # Set up embeddings
        embeddings = OpenAIEmbeddings( model="text-embedding-ada-002")

        # Set up Pinecone
        pinecone.init(api_key=pinecone_api_key, environment='gcp-starter')
        index_name = 'langchainresearch'
        if index_name not in pinecone.list_indexes():
            pinecone.create_index(index_name, dimension=1536, metric="cosine")  # Adjust the dimension as per your embeddings
        index = pinecone.Index(index_name)
        
        docsearch = Pinecone.from_documents(chunks, embeddings, index_name = index_name)
        
        # Create or Load Chat History
        if pdf:
            # generate chat history
            chat_history_file = f"{pdf.name}_chat_history.pkl"

            # load history if exist
            if os.path.exists(chat_history_file):
                with open(chat_history_file, "rb") as f:
                    chat_history  = pickle.load(f)
            else:
                chat_history = []
             
        # Initialize chat_history in session_state if not present
        if 'chat_history' not in st.session_state:
            st.session_state.chat_history = []
        
        # Check if 'prompt' is in session state
        if 'last_input' not in st.session_state:
            st.session_state.last_input = ''
        
        # User Input
        current_prompt = st.session_state.get('user_input', '')

        prompt_placeholder = st.empty()
        prompt = prompt_placeholder.text_area("Ask questions about your PDF:", value=current_prompt, placeholder="Send a message", key="user_input")
        submit_button = st.button("Submit")

        if submit_button and prompt:
            # Update the last input in session state
            st.session_state.last_input = prompt

            docs = docsearch.similarity_search(query=prompt, k=3)

            #llm = OpenAI(temperature=0.9, model_name='gpt-3.5-turbo')
            chat = ChatOpenAI(model='gpt-4', temperature=0.7, max_tokens=3000)

            message = [
                SystemMessage(content="You are a helpful assistant"),
                HumanMessage(content=prompt)
            ]
            chain = load_qa_chain(llm=chat, chain_type="stuff")
            with get_openai_callback() as cb:
                response = chain.run(input_documents=docs, question=message)
                print(cb)
            # st.write(response)
            # st.write(docs)

            # Process the response using AIMessage schema
            # ai_message = AIMessage(content="AI message content")
            # ai_message.content = response.generations[0].message.content

            # Add to chat history
            st.session_state.chat_history.append((prompt, response))

            # Save chat history
            with open(chat_history_file, "wb") as f:
                pickle.dump(st.session_state.chat_history, f)
            
            # Clear the input after processing
            prompt_placeholder.text_area("Ask questions about your PDF:", value='', placeholder="Send a message", key="pdf_prompt") 
            
        # Display the entire chat 
        chat_content = ""
        for user_msg, bot_resp in st.session_state.chat_history:
            chat_content += f"<div style='background-color: #222222; color: white; padding: 10px;'>**You:** {user_msg}</div>"
            chat_content += f"<div style='background-color: #333333; color: white; padding: 10px;'>**Zi GPT:** {bot_resp}</div>"
        st.markdown(chat_content, unsafe_allow_html=True)

if __name__ == '__main__':
    main()

After running the code I got this error message that I cannot find a solution. 
AttributeError: 'str' object has no attribute 'page_content'
Traceback:
File "C:\Users\zy73\AppData\Roaming\Python\Python311\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 552, in _run_script
    exec(code, module.__dict__)
File "C:\Users\zy73\OneDrive\Desktop\AI Research\langchain\pdf.py", line 159, in <module>
    main()
File "C:\Users\zy73\OneDrive\Desktop\AI Research\langchain\pdf.py", line 88, in main
    docsearch = Pinecone.from_documents(chunks, embeddings, index_name = index_name)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\zy73\AppData\Roaming\Python\Python311\site-packages\langchain\schema\vectorstore.py", line 508, in from_documents
    texts = [d.page_content for d in documents]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\zy73\AppData\Roaming\Python\Python311\site-packages\langchain\schema\vectorstore.py", line 508, in <listcomp>
    texts = [d.page_content for d in documents]

Please help me debug this. Thank you

### Suggestion:

_No response_