|
5 | 5 | "cell_type": "markdown", |
6 | 6 | "metadata": {}, |
7 | 7 | "source": [ |
8 | | - "Google Database\n", |
| 8 | + "# Google Memorystore for Redis\n", |
9 | 9 | "\n", |
10 | | - "Use [Google Memorystore for Redis](https://cloud.google.com/memorystore/docs/redis/memorystore-for-redis-overview) as a vector store for LangChain." |
| 10 | + "> [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", |
| 11 | + "\n", |
| 12 | + "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", |
| 13 | + "\n", |
| 14 | + "[](https://colab.research.google.com/github/googleapis/langchain-google-memorystore-redis-python/blob/main/docs/vector_store.ipynb)" |
11 | 15 | ] |
12 | 16 | }, |
13 | 17 | { |
|
22 | 26 | "cell_type": "markdown", |
23 | 27 | "metadata": {}, |
24 | 28 | "source": [ |
25 | | - "### Setting Up a Memorystore for Redis Instance\n", |
| 29 | + "## Before You Begin\n", |
26 | 30 | "\n", |
27 | | - "Before proceeding, an active Memorystore for Redis instance is needed to store vectors:\n", |
28 | | - "\n", |
29 | | - "* 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", |
30 | | - "* Obtain Endpoint: Note the endpoint associated with the instance." |
| 31 | + "To run this notebook, you will need to do the following:\n", |
| 32 | + "* [Create a Google Cloud Project](https://developers.google.com/workspace/guides/create-project)\n", |
| 33 | + "* [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." |
31 | 34 | ] |
32 | 35 | }, |
33 | 36 | { |
34 | 37 | "attachments": {}, |
35 | 38 | "cell_type": "markdown", |
36 | 39 | "metadata": {}, |
37 | 40 | "source": [ |
38 | | - "### Installing the LangChain Memorystore for Redis Module\n", |
| 41 | + "### 🦜🔗 Library Installation\n", |
39 | 42 | "\n", |
40 | | - "Interaction with the Memorystore for Redis instance from LangChain requires installing the necessary module:" |
| 43 | + "The integration lives in its own `langchain-google-memorystore-redis` package, so we need to install it." |
41 | 44 | ] |
42 | 45 | }, |
43 | 46 | { |
|
48 | 51 | }, |
49 | 52 | "outputs": [], |
50 | 53 | "source": [ |
51 | | - "# Install Memorystore for Redis for LangChain module\n", |
52 | | - "%pip install langchainlangchain_google_memorystore_redis" |
| 54 | + "%pip install -upgrade --quiet langchain-google-memorystore-redis" |
| 55 | + ] |
| 56 | + }, |
| 57 | + { |
| 58 | + "cell_type": "markdown", |
| 59 | + "metadata": {}, |
| 60 | + "source": [ |
| 61 | + "**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." |
| 62 | + ] |
| 63 | + }, |
| 64 | + { |
| 65 | + "cell_type": "code", |
| 66 | + "execution_count": null, |
| 67 | + "metadata": {}, |
| 68 | + "outputs": [], |
| 69 | + "source": [ |
| 70 | + "# # Automatically restart kernel after installs so that your environment can access the new packages\n", |
| 71 | + "# import IPython\n", |
| 72 | + "\n", |
| 73 | + "# app = IPython.Application.instance()\n", |
| 74 | + "# app.kernel.do_shutdown(True)" |
| 75 | + ] |
| 76 | + }, |
| 77 | + { |
| 78 | + "cell_type": "markdown", |
| 79 | + "metadata": {}, |
| 80 | + "source": [ |
| 81 | + "### ☁ Set Your Google Cloud Project\n", |
| 82 | + "Set your Google Cloud project so that you can leverage Google Cloud resources within this notebook.\n", |
| 83 | + "\n", |
| 84 | + "If you don't know your project ID, try the following:\n", |
| 85 | + "\n", |
| 86 | + "* Run `gcloud config list`.\n", |
| 87 | + "* Run `gcloud projects list`.\n", |
| 88 | + "* See the support page: [Locate the project ID](https://support.google.com/googleapi/answer/7014113)." |
| 89 | + ] |
| 90 | + }, |
| 91 | + { |
| 92 | + "cell_type": "code", |
| 93 | + "execution_count": null, |
| 94 | + "metadata": {}, |
| 95 | + "outputs": [], |
| 96 | + "source": [ |
| 97 | + "# @markdown Please fill in the value below with your Google Cloud project ID and then run the cell.\n", |
| 98 | + "\n", |
| 99 | + "PROJECT_ID = \"my-project-id\" # @param {type:\"string\"}\n", |
| 100 | + "\n", |
| 101 | + "# Set the project id\n", |
| 102 | + "!gcloud config set project {PROJECT_ID}" |
| 103 | + ] |
| 104 | + }, |
| 105 | + { |
| 106 | + "cell_type": "markdown", |
| 107 | + "metadata": {}, |
| 108 | + "source": [ |
| 109 | + "### 🔐 Authentication\n", |
| 110 | + "Authenticate to Google Cloud as the IAM user logged into this notebook in order to access your Google Cloud Project.\n", |
| 111 | + "\n", |
| 112 | + "* If you are using Colab to run this notebook, use the cell below and continue.\n", |
| 113 | + "* If you are using Vertex AI Workbench, check out the setup instructions [here](https://github.com/GoogleCloudPlatform/generative-ai/tree/main/setup-env)." |
| 114 | + ] |
| 115 | + }, |
| 116 | + { |
| 117 | + "cell_type": "code", |
| 118 | + "execution_count": null, |
| 119 | + "metadata": {}, |
| 120 | + "outputs": [], |
| 121 | + "source": [ |
| 122 | + "from google.colab import auth\n", |
| 123 | + "\n", |
| 124 | + "auth.authenticate_user()" |
53 | 125 | ] |
54 | 126 | }, |
55 | 127 | { |
|
0 commit comments