Here are the installation instructions.pip install pinecone-client openai tiktoken langchainimport osimport getpassos.environ["PINECONE_API_KEY"] = getpass.getpass("Pinecone API Key:")os.environ["PINECONE_ENV"] = getpass.getpass("Pinecone Environment:")We want to use OpenAIEmbeddings so we have to get the OpenAI API Key.os.environ["OPENAI_API_KEY"] = getpass.getpass("OpenAI API Key:")from langchain.embeddings.openai import OpenAIEmbeddingsfrom langchain.text_splitter import CharacterTextSplitterfrom langchain.vectorstores import Pineconefrom langchain.document_loaders import TextLoaderfrom langchain.document_loaders import TextLoaderloader = TextLoader("../../modules/state_of_the_union.txt")documents = loader.load()text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)docs = text_splitter.split_documents(documents)embeddings = OpenAIEmbeddings()import pinecone# initialize pineconepinecone.init(    api_key=os.getenv("PINECONE_API_KEY"),  # find at app.pinecone.io    environment=os.getenv("PINECONE_ENV"),  # next to api key in console)index_name = "langchain-demo"# First, check if our index already exists. If it doesn't, we create itif index_name not in pinecone.list_indexes():    # we create a new index    pinecone.create_index(      name=index_name,      metric='cosine',      dimension=1536  )# The OpenAI embedding model `text-embedding-ada-002 uses 1536 dimensions`docsearch = Pinecone.from_documents(docs, embeddings, index_name=index_name)# if you already have an index, you can load it like this# docsearch = Pinecone.from_existing_index(index_name, embeddings)query = "What did the president say about Ketanji Brown Jackson"docs = docsearch.similarity_search(query)print(docs[0].page_content)Adding More Text to an Existing Index‚ÄãMore text can embedded and upserted to an existing Pinecone index using the add_texts functionindex = pinecone.Index("langchain-demo")vectorstore = Pinecone(index, embeddings.embed_query, "text")vectorstore.add_texts("More
Pinecone is a vector database with broad functionality.
Pinecone is a vector database with broad functionality. ->: Here are the installation instructions.pip install pinecone-client openai tiktoken langchainimport osimport getpassos.environ["PINECONE_API_KEY"] = getpass.getpass("Pinecone API Key:")os.environ["PINECONE_ENV"] = getpass.getpass("Pinecone Environment:")We want to use OpenAIEmbeddings so we have to get the OpenAI API Key.os.environ["OPENAI_API_KEY"] = getpass.getpass("OpenAI API Key:")from langchain.embeddings.openai import OpenAIEmbeddingsfrom langchain.text_splitter import CharacterTextSplitterfrom langchain.vectorstores import Pineconefrom langchain.document_loaders import TextLoaderfrom langchain.document_loaders import TextLoaderloader = TextLoader("../../modules/state_of_the_union.txt")documents = loader.load()text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)docs = text_splitter.split_documents(documents)embeddings = OpenAIEmbeddings()import pinecone# initialize pineconepinecone.init(    api_key=os.getenv("PINECONE_API_KEY"),  # find at app.pinecone.io    environment=os.getenv("PINECONE_ENV"),  # next to api key in console)index_name = "langchain-demo"# First, check if our index already exists. If it doesn't, we create itif index_name not in pinecone.list_indexes():    # we create a new index    pinecone.create_index(      name=index_name,      metric='cosine',      dimension=1536  )# The OpenAI embedding model `text-embedding-ada-002 uses 1536 dimensions`docsearch = Pinecone.from_documents(docs, embeddings, index_name=index_name)# if you already have an index, you can load it like this# docsearch = Pinecone.from_existing_index(index_name, embeddings)query = "What did the president say about Ketanji Brown Jackson"docs = docsearch.similarity_search(query)print(docs[0].page_content)Adding More Text to an Existing Index‚ÄãMore text can embedded and upserted to an existing Pinecone index using the add_texts functionindex = pinecone.Index("langchain-demo")vectorstore = Pinecone(index, embeddings.embed_query, "text")vectorstore.add_texts("More