Skip to content

Commit

Permalink
Update module
Browse files Browse the repository at this point in the history
  • Loading branch information
caetano-colin committed Jun 6, 2024
1 parent 29d3634 commit e0a50f2
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 53 deletions.
12 changes: 12 additions & 0 deletions examples/genai-rag-multimodal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ Once all the requirements are set up, you can begin by running and adjusting the

To run the notebook, open the Google Cloud Console on Vertex AI Workbench, open jupyterlab and upload the notebook (`multimodal_rag_langchain.ipynb`) to it.

### Optional: Use `terraform output` and bash command to fill in fields in the notebook

You can save some time adjusting the notebook by running the commands below:

```bash
sed -i "s/<INSERT_PRIVATE_IP_VALUE_HERE>/$(terraform output -raw private_endpoint_ip_address)/g" multimodal_rag_langchain.ipynb
sed -i "s/<INSERT_HOST_VPC_PROJECT_ID>/$(terraform output -raw host_vpc_project_id)/g" multimodal_rag_langchain.ipynb
sed -i "s/<INSERT_NOTEBOOK_PROJECT_ID>/$(terraform output -raw notebook_project_id)/g" multimodal_rag_langchain.ipynb
sed -i "s/<INSERT_BUCKET_NAME>/$(terraform output -raw vector_search_bucket_name)/g" multimodal_rag_langchain.ipynb
sed -i "s:<INSERT_HOST_VPC_NETWORK>:$(terraform output -raw host_vpc_network):g" multimodal_rag_langchain.ipynb
```

## Known Issues

- `Error: Error creating Instance: googleapi: Error 400: value_to_check(https://compute.googleapis.com/compute/v1/projects/...) is not found`.
Expand Down
95 changes: 42 additions & 53 deletions examples/genai-rag-multimodal/multimodal_rag_langchain.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,13 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"id": "R5Xep4W9lq-Z"
},
"source": [
"### Create Private Endpoint IP Address\n",
"### Restart current runtime\n",
"\n",
"Retrieve the IP address value created when setting up Private Service Connect for Vector Search."
"To use the newly installed packages in this Jupyter runtime, you must restart the runtime. You can do this by running the cell below, which will restart the current kernel."
]
},
{
Expand All @@ -192,20 +194,20 @@
"metadata": {},
"outputs": [],
"source": [
"PRIVATE_ENDPOINT_IP_ADDRESS=<INSERT_VALUE_HERE>"
"# 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": [
"### Update Project Allowlist\n",
"\n",
"Insert the values of the Host Shared VPC Project and the current notebook project on the cell below.\n",
"\n",
"For example: `PROJECT_ALLOWLIST=[\"prj-d-shared-restricted-83dn\",\"prj-d-ml-machine-learning-0v09\"]` \n",
"### Create Private Endpoint IP Address\n",
"\n",
"Remember that these values will be different on your environment"
"Retrieve the IP address value created when setting up Private Service Connect for Vector Search. You can retrieve this value by running `terraform output` on the example."
]
},
{
Expand All @@ -214,48 +216,29 @@
"metadata": {},
"outputs": [],
"source": [
"PROJECT_ALLOWLIST=[\"<INSERT_HOST_VPC_PROJECT_ID>\", \"<INSERT_NOTEBOOK_PROJECT_ID>\"]"
"PRIVATE_ENDPOINT_IP_ADDRESS=\"<INSERT_PRIVATE_IP_VALUE_HERE>\""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "R5Xep4W9lq-Z"
},
"metadata": {},
"source": [
"### Restart current runtime\n",
"### Update Project Allowlist\n",
"\n",
"To use the newly installed packages in this Jupyter runtime, you must restart the runtime. You can do this by running the cell below, which will restart the current kernel."
"Insert the values of the Host Shared VPC Project and the current notebook project on the cell below.\n",
"\n",
"For example: `PROJECT_ALLOWLIST=[\"prj-d-shared-restricted-83dn\",\"prj-d-ml-machine-learning-0v09\"]` \n",
"\n",
"Remember that these values will be different on your environment"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"executionInfo": {
"elapsed": 646,
"status": "ok",
"timestamp": 1707913872852,
"user": {
"displayName": "",
"userId": ""
},
"user_tz": -330
},
"id": "XRvKdaPDTznN",
"outputId": "759357fb-7531-4423-a75f-b896af19ce37",
"tags": []
},
"metadata": {},
"outputs": [],
"source": [
"# 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)"
"PROJECT_ALLOWLIST=[\"<INSERT_HOST_VPC_PROJECT_ID>\", \"<INSERT_NOTEBOOK_PROJECT_ID>\"]"
]
},
{
Expand Down Expand Up @@ -302,7 +285,7 @@
},
"outputs": [],
"source": [
"PROJECT_ID = \"<INSERT_PROJECT_ID_HERE>\" # @param {type:\"string\"}\n",
"PROJECT_ID = \"<INSERT_NOTEBOOK_PROJECT_ID>\" # @param {type:\"string\"}\n",
"LOCATION = \"us-central1\" # @param {type:\"string\"}\n",
"\n",
"# For Vector Search Staging\n",
Expand Down Expand Up @@ -716,27 +699,33 @@
"metadata": {},
"outputs": [],
"source": [
"index_endpoint.deployed_indexes.private_endpoints.service_attachment"
"SERVICE_ATTACHMENT=index_endpoint.deployed_indexes.private_endpoints.service_attachment\n",
"\n",
"SERVICE_ATTACHMENT"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* Retrieve the value of the service attachment and execute the command below on your local machine:\n",
"\n",
"```bash\n",
"NETWORK=<INSERT_HOST_VPC_NETWORK_NAME>\n",
"NETWORK_PROJECT_ID=<INSERT_HOST_VPC_NETWORK_PROJECT_ID>\n",
"SERVICE_ATTACHMENT=<INSERT_VALUE_FROM_CELL_ABOVE_HERE>\n",
"* Retrieve the value of the service attachment and execute the command below on your local machine:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"NETWORK=\"<INSERT_HOST_VPC_NETWORK>\"\n",
"NETWORK_PROJECT_ID=\"<INSERT_HOST_VPC_PROJECT_ID>\"\n",
"\n",
"gcloud compute forwarding-rules create vector-search-endpoint \\\n",
" --network=$NETWORK \\\n",
"!gcloud compute forwarding-rules create vector-search-endpoint \\\n",
" --network={NETWORK} \\\n",
" --address=vector-search-endpoint \\\n",
" --target-service-attachment=$SERVICE_ATTACHMENT \\\n",
" --project=$NETWORK_PROJECT_ID \\\n",
" --region=us-central1\n",
"```"
" --target-service-attachment={SERVICE_ATTACHMENT} \\\n",
" --project={NETWORK_PROJECT_ID} \\\n",
" --region=us-central1"
]
},
{
Expand Down
24 changes: 24 additions & 0 deletions examples/genai-rag-multimodal/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
output "private_endpoint_ip_address" {
description = "The private IP address of the vector search endpoint"
value = google_compute_address.vector_search_static_ip.address
}

output "host_vpc_project_id" {
description = "This is the Project ID where the Host VPC network is located"
value = var.vector_search_vpc_project
}

output "host_vpc_network" {
description = "This is the Self-link of the Host VPC network"
value = var.network
}

output "notebook_project_id" {
description = "The Project ID where the notebook will be run on"
value = var.machine_learning_project
}

output "vector_search_bucket_name" {
description = "The name of the bucket that Vector Search will use"
value = google_storage_bucket.vector_search_bucket.name
}

0 comments on commit e0a50f2

Please sign in to comment.