pinecone[patch], docs: PineconeVectorStore, release 0.0.3 (#17896)

This commit is contained in:
Erick Friis
2024-02-22 08:24:08 -08:00
committed by GitHub
parent e5e38e89ce
commit a53370a060
22 changed files with 130 additions and 128 deletions

View File

@@ -18,7 +18,7 @@ There exists a wrapper around Pinecone indexes, allowing you to use it as a vect
whether for semantic search or example selection.
```python
from langchain_community.vectorstores import Pinecone
from langchain_pinecone import PineconeVectorStore
```
For a more detailed walkthrough of the Pinecone vectorstore, see [this notebook](/docs/integrations/vectorstores/pinecone)

View File

@@ -119,13 +119,8 @@
"import pinecone\n",
"\n",
"api_key = os.getenv(\"PINECONE_API_KEY\") or \"PINECONE_API_KEY\"\n",
"# find environment next to your API key in the Pinecone console\n",
"env = os.getenv(\"PINECONE_ENVIRONMENT\") or \"PINECONE_ENVIRONMENT\"\n",
"\n",
"index_name = \"langchain-pinecone-hybrid-search\"\n",
"\n",
"pinecone.init(api_key=api_key, environment=env)\n",
"pinecone.whoami()"
"index_name = \"langchain-pinecone-hybrid-search\""
]
},
{

View File

@@ -78,8 +78,8 @@
"outputs": [],
"source": [
"from langchain.schema import Document\n",
"from langchain_community.vectorstores import Pinecone\n",
"from langchain_openai import OpenAIEmbeddings\n",
"from langchain_pinecone import PineconeVectorStore\n",
"\n",
"embeddings = OpenAIEmbeddings()\n",
"# create new index\n",
@@ -124,7 +124,7 @@
" },\n",
" ),\n",
"]\n",
"vectorstore = Pinecone.from_documents(\n",
"vectorstore = PineconeVectorStore.from_documents(\n",
" docs, embeddings, index_name=\"langchain-self-retriever-demo\"\n",
")"
]

View File

@@ -71,7 +71,7 @@
"source": [
"Now let's assume you have your Pinecone index set up with `dimension=1536`.\n",
"\n",
"We can connect to our Pinecone index and insert those chunked docs as contents with `Pinecone.from_documents`."
"We can connect to our Pinecone index and insert those chunked docs as contents with `PineconeVectorStore.from_documents`."
]
},
{
@@ -81,11 +81,11 @@
"metadata": {},
"outputs": [],
"source": [
"from langchain_pinecone import Pinecone\n",
"from langchain_pinecone import PineconeVectorStore\n",
"\n",
"index_name = \"langchain-test-index\"\n",
"\n",
"docsearch = Pinecone.from_documents(docs, embeddings, index_name=index_name)"
"docsearch = PineconeVectorStore.from_documents(docs, embeddings, index_name=index_name)"
]
},
{
@@ -143,7 +143,7 @@
}
],
"source": [
"vectorstore = Pinecone(index_name=index_name, embedding=embeddings)\n",
"vectorstore = PineconeVectorStore(index_name=index_name, embedding=embeddings)\n",
"\n",
"vectorstore.add_texts([\"More text!\"])"
]

View File

@@ -35,28 +35,22 @@
"\n",
"## Code Example\n",
"\n",
"Let's see a concrete example of what this looks like in code. We will use Pinecone for this example."
"Let's see a concrete example of what this looks like in code. We will use Pinecone for this example.\n",
"\n",
"To configure Pinecone, set the following environment variable:\n",
"\n",
"- `PINECONE_API_KEY`: Your Pinecone API key"
]
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "75823b2d",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/harrisonchase/.pyenv/versions/3.10.1/envs/langchain/lib/python3.10/site-packages/pinecone/index.py:4: TqdmExperimentalWarning: Using `tqdm.autonotebook.tqdm` in notebook mode. Use `tqdm.tqdm` instead to force console mode (e.g. in jupyter console)\n",
" from tqdm.autonotebook import tqdm\n"
]
}
],
"outputs": [],
"source": [
"import pinecone\n",
"from langchain_community.vectorstores import Pinecone\n",
"from langchain_openai import OpenAIEmbeddings"
"from langchain_openai import OpenAIEmbeddings\n",
"from langchain_pinecone import PineconeVectorStore"
]
},
{
@@ -77,12 +71,8 @@
}
],
"source": [
"# The environment should be the one specified next to the API key\n",
"# in your Pinecone console\n",
"pinecone.init(api_key=\"...\", environment=\"...\")\n",
"index = pinecone.Index(\"test-example\")\n",
"embeddings = OpenAIEmbeddings()\n",
"vectorstore = Pinecone(index, embeddings, \"text\")\n",
"vectorstore = PineconeVectorStore(index_name=\"test-example\", embedding=embeddings)\n",
"\n",
"vectorstore.add_texts([\"i worked at kensho\"], namespace=\"harrison\")\n",
"vectorstore.add_texts([\"i worked at facebook\"], namespace=\"ankush\")"
@@ -301,15 +291,16 @@
},
{
"cell_type": "markdown",
"source": [
"For more vectorstore implementations for multi-user, please refer to specific pages, such as [Milvus](/docs/integrations/vectorstores/milvus)."
],
"id": "7fb27b941602401d91542211134fc71a",
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
}
},
"source": [
"For more vectorstore implementations for multi-user, please refer to specific pages, such as [Milvus](/docs/integrations/vectorstores/milvus)."
]
}
],
"metadata": {
@@ -333,4 +324,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}