From 30c09c4035c6ba32bc533b9fd87b1bc2829aed7f Mon Sep 17 00:00:00 2001 From: Averi Kitsch Date: Tue, 20 Feb 2024 18:30:22 -0800 Subject: [PATCH] docs: update vector store doc --- docs/vector_store.ipynb | 94 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 83 insertions(+), 11 deletions(-) diff --git a/docs/vector_store.ipynb b/docs/vector_store.ipynb index df6a9b6..6031031 100644 --- a/docs/vector_store.ipynb +++ b/docs/vector_store.ipynb @@ -5,9 +5,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Google Database\n", + "# Google Memorystore for Redis\n", "\n", - "Use [Google Memorystore for Redis](https://cloud.google.com/memorystore/docs/redis/memorystore-for-redis-overview) as a vector store for LangChain." + "> [Google Memorystore for Redis](https://cloud.google.com/memorystore/docs/redis/memorystore-for-redis-overview) is a fully-managed service that is powered by the Redis in-memory data store to build application caches that provide sub-millisecond data access. Extend your database application to build AI-powered experiences leveraging Memorystore for Redis's Langchain integrations.\n", + "\n", + "This notebook goes over how to use [Memorystore for Redis](https://cloud.google.com/memorystore/docs/redis/memorystore-for-redis-overview) to store vector embeddings with the `MemorystoreVectorStore` class.\n", + "\n", + "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/googleapis/langchain-google-memorystore-redis-python/blob/main/docs/vector_store.ipynb)" ] }, { @@ -22,12 +26,11 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Setting Up a Memorystore for Redis Instance\n", + "## Before You Begin\n", "\n", - "Before proceeding, an active Memorystore for Redis instance is needed to store vectors:\n", - "\n", - "* Create a Memorystore for Redis Instance (v7.2): If an instance doesn't exist, follow the instructions at https://cloud.google.com/memorystore/docs/redis/create-instance-console to create a new one. Ensure version 7.2 is selected.\n", - "* Obtain Endpoint: Note the endpoint associated with the instance." + "To run this notebook, you will need to do the following:\n", + "* [Create a Google Cloud Project](https://developers.google.com/workspace/guides/create-project)\n", + "* [Create a Memorystore for Redis instance](https://cloud.google.com/memorystore/docs/redis/create-instance-console). Ensure that the version is greater than or equal to 7.2." ] }, { @@ -35,9 +38,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Installing the LangChain Memorystore for Redis Module\n", + "### 🦜🔗 Library Installation\n", "\n", - "Interaction with the Memorystore for Redis instance from LangChain requires installing the necessary module:" + "The integration lives in its own `langchain-google-memorystore-redis` package, so we need to install it." ] }, { @@ -48,8 +51,77 @@ }, "outputs": [], "source": [ - "# Install Memorystore for Redis for LangChain module\n", - "%pip install langchainlangchain_google_memorystore_redis" + "%pip install -upgrade --quiet langchain-google-memorystore-redis" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Colab only:** Uncomment the following cell to restart the kernel or use the button to restart the kernel. For Vertex AI Workbench you can restart the terminal using the button on top." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# # Automatically restart kernel after installs so that your environment can access the new packages\n", + "# import IPython\n", + "\n", + "# app = IPython.Application.instance()\n", + "# app.kernel.do_shutdown(True)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### ☁ Set Your Google Cloud Project\n", + "Set your Google Cloud project so that you can leverage Google Cloud resources within this notebook.\n", + "\n", + "If you don't know your project ID, try the following:\n", + "\n", + "* Run `gcloud config list`.\n", + "* Run `gcloud projects list`.\n", + "* See the support page: [Locate the project ID](https://support.google.com/googleapi/answer/7014113)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# @markdown Please fill in the value below with your Google Cloud project ID and then run the cell.\n", + "\n", + "PROJECT_ID = \"my-project-id\" # @param {type:\"string\"}\n", + "\n", + "# Set the project id\n", + "!gcloud config set project {PROJECT_ID}" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 🔐 Authentication\n", + "Authenticate to Google Cloud as the IAM user logged into this notebook in order to access your Google Cloud Project.\n", + "\n", + "* If you are using Colab to run this notebook, use the cell below and continue.\n", + "* If you are using Vertex AI Workbench, check out the setup instructions [here](https://github.com/GoogleCloudPlatform/generative-ai/tree/main/setup-env)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from google.colab import auth\n", + "\n", + "auth.authenticate_user()" ] }, {