Skip to content

Commit

Permalink
docs: Add docs for Upstash Vector built-in embeddings support (#7485)
Browse files Browse the repository at this point in the history
Co-authored-by: Jacob Lee <[email protected]>
  • Loading branch information
ytkimirti and jacoblee93 authored Jan 9, 2025
1 parent 06b45d1 commit 60335e0
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion docs/core_docs/docs/integrations/vectorstores/upstash.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@
"\n",
"You can create an index from the [Upstash Console](https://console.upstash.com/login). For further reference, see [the official docs](https://upstash.com/docs/vector/overall/getstarted).\n",
"\n",
"Upstash vector also has built in embedding support. Which means you can use it directly without the need for an additional embedding model. Check the [embedding models documentation](https://upstash.com/docs/vector/features/embeddingmodels) for more details.\n",
"\n",
"```{=mdx}\n",
":::note\n",
"To use the built-in Upstash embeddings, you'll need to select an embedding model when creating the index.\n",
":::\n",
"```\n",
"\n",
"### Credentials\n",
"\n",
"Once you've set up an index, set the following environment variables:\n",
Expand Down Expand Up @@ -127,6 +135,38 @@
"});"
]
},
{
"cell_type": "markdown",
"id": "afa53a9c",
"metadata": {},
"source": [
"## Usage with built-in embeddings\n",
"\n",
"To use the built-in Upstash embeddings, you can pass a `FakeEmbeddings` instance to the `UpstashVectorStore` constructor. This will make the `UpstashVectorStore` use the built-in embeddings, which you selected when creating the index."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cbabe6f7",
"metadata": {},
"outputs": [],
"source": [
"import { UpstashVectorStore } from \"@langchain/community/vectorstores/upstash\";\n",
"import { FakeEmbeddings } from \"@langchain/core/utils/testing\";\n",
"\n",
"import { Index } from \"@upstash/vector\";\n",
"\n",
"const indexWithEmbeddings = new Index({\n",
" url: process.env.UPSTASH_VECTOR_REST_URL,\n",
" token: process.env.UPSTASH_VECTOR_REST_TOKEN,\n",
"});\n",
"\n",
"const vectorStore = new UpstashVectorStore(new FakeEmbeddings(), {\n",
" index: indexWithEmbeddings,\n",
"});"
]
},
{
"cell_type": "markdown",
"id": "ac6071d4",
Expand Down Expand Up @@ -360,4 +400,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}

0 comments on commit 60335e0

Please sign in to comment.