Skip to main content
Pinecone is a vector database that helps power AI for some of the world’s best companies. This guide provides a quick overview for getting started with Pinecone vector stores. For detailed documentation of all PineconeStore features and configurations head to the API reference.

概述

集成详情

设置

To use Pinecone vector stores, you’ll need to create a Pinecone account, initialize an index, and install the @langchain/pinecone integration package. You’ll also want to install the official Pinecone SDK to initialize a client to pass into the PineconeStore instance. This guide will also use OpenAI embeddings, which require you to install the @langchain/openai integration package. You can also use other supported embeddings models if you wish.

凭证

Sign up for a Pinecone account and create an index. Make sure the dimensions match those of the embeddings you want to use (the default is 1536 for OpenAI’s text-embedding-3-small). Once you’ve done this set the PINECONE_INDEX, PINECONE_API_KEY, and (optionally) PINECONE_ENVIRONMENT environment variables:
If you are using OpenAI embeddings for this guide, you’ll need to set your OpenAI key as well:
如果你想要自动追踪模型调用,还可以设置你的 LangSmith API 密钥,取消注释以下内容:

实例化

Manage vector store

Add items to vector store

Note: After adding documents, there is a slight delay before they become queryable.

Delete items from vector store

Query vector store

Once your vector store has been created and the relevant documents have been added you will most likely wish to query it during the running of your chain or agent.

Query directly

Performing a simple similarity search can be done as follows:
If you want to execute a similarity search and receive the corresponding scores you can run:

Query by turning into retriever

You can also transform the vector store into a retriever for easier usage in your chains.

Usage for retrieval-augmented generation

For guides on how to use this vector store for retrieval-augmented generation (RAG), see the following sections:

API 参考

有关所有 PineconeStore 功能和配置的详细文档,请前往 API 参考