Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add docs for Upstash Vector built-in embeddings support #7485

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 43 additions & 3 deletions 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 @@ -115,18 +123,50 @@
" model: \"text-embedding-3-small\",\n",
"});\n",
"\n",
"const indexWithCredentials = new Index({\n",
"const index = 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(embeddings, {\n",
" index: indexWithCredentials,\n",
" index: index,\n",
" // You can use namespaces to partition your data in an index\n",
" // namespace: \"test-namespace\",\n",
"});"
]
},
{
"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 index = 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: index,\n",
"});"
]
},
{
"cell_type": "markdown",
"id": "ac6071d4",
Expand Down Expand Up @@ -360,4 +400,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}