-
Notifications
You must be signed in to change notification settings - Fork 286
feat(vector search): Add examples for streaming, endpoints, and deploy #750
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
Merged
glasnt
merged 4 commits into
terraform-google-modules:main
from
ericgribkoff:vector_search_sample
Oct 25, 2024
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ab15de9
feat(vector search): Add examples for streaming, endpoints, and deploy
ericgribkoff f3b9511
Merge branch 'main' into vector_search_sample
ericgribkoff fde2968
rename vars to default
ericgribkoff aabbf49
Merge branch 'main' into vector_search_sample
glasnt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| /** | ||
| * Copyright 2024 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
|
|
||
| # [START aiplatform_create_index_endpoint_sample] | ||
| resource "google_vertex_ai_index_endpoint" "index_endpoint" { | ||
| display_name = "sample-endpoint" | ||
| description = "A sample index endpoint with a public endpoint" | ||
| region = "us-central1" | ||
| public_endpoint_enabled = true | ||
| } | ||
|
|
||
| # Cloud Storage bucket name must be unique | ||
| resource "random_id" "bucket_name_suffix" { | ||
ericgribkoff marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| byte_length = 8 | ||
| } | ||
|
|
||
| # Create a Cloud Storage bucket | ||
| resource "google_storage_bucket" "bucket" { | ||
| name = "vertex-ai-index-bucket-${random_id.bucket_name_suffix.hex}" | ||
| location = "us-central1" | ||
| uniform_bucket_level_access = true | ||
| } | ||
|
|
||
| # Create index content | ||
| resource "google_storage_bucket_object" "data" { | ||
| name = "contents/data.json" | ||
| bucket = google_storage_bucket.bucket.name | ||
| content = <<EOF | ||
| {"id": "42", "embedding": [0.5, 1.0], "restricts": [{"namespace": "class", "allow": ["cat", "pet"]},{"namespace": "category", "allow": ["feline"]}]} | ||
| {"id": "43", "embedding": [0.6, 1.0], "restricts": [{"namespace": "class", "allow": ["dog", "pet"]},{"namespace": "category", "allow": ["canine"]}]} | ||
| EOF | ||
| } | ||
|
|
||
| resource "google_vertex_ai_index" "default" { | ||
| region = "us-central1" | ||
| display_name = "sample-index-batch-update" | ||
| description = "A sample index for batch update" | ||
| labels = { | ||
| foo = "bar" | ||
| } | ||
|
|
||
| metadata { | ||
| contents_delta_uri = "gs://${google_storage_bucket.bucket.name}/contents" | ||
| config { | ||
| dimensions = 2 | ||
| approximate_neighbors_count = 150 | ||
| distance_measure_type = "DOT_PRODUCT_DISTANCE" | ||
| algorithm_config { | ||
| tree_ah_config { | ||
| leaf_node_embedding_count = 500 | ||
| leaf_nodes_to_search_percent = 7 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| index_update_method = "BATCH_UPDATE" | ||
|
|
||
| timeouts { | ||
| create = "2h" | ||
| update = "1h" | ||
| } | ||
| } | ||
| # [END aiplatform_create_index_endpoint_sample] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| /** | ||
| * Copyright 2024 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
|
|
||
| # [START aiplatform_deploy_index_endpoint_sample] | ||
| provider "google" { | ||
| region = "us-central1" | ||
| } | ||
|
|
||
| resource "google_vertex_ai_index_endpoint_deployed_index" "deployed_index" { | ||
ericgribkoff marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| depends_on = [google_vertex_ai_index_endpoint.index_endpoint] | ||
| index_endpoint = google_vertex_ai_index_endpoint.index_endpoint.id | ||
| index = google_vertex_ai_index.default.id | ||
| deployed_index_id = "deployed_index_id" | ||
| } | ||
|
|
||
| resource "google_vertex_ai_index_endpoint" "index_endpoint" { | ||
ericgribkoff marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| display_name = "sample-endpoint" | ||
| description = "A sample index endpoint with a public endpoint" | ||
| region = "us-central1" | ||
| public_endpoint_enabled = true | ||
| } | ||
|
|
||
| # Cloud Storage bucket name must be unique | ||
| resource "random_id" "bucket_name_suffix" { | ||
| byte_length = 8 | ||
| } | ||
|
|
||
| # Create a Cloud Storage bucket | ||
| resource "google_storage_bucket" "bucket" { | ||
| name = "vertex-ai-index-bucket-${random_id.bucket_name_suffix.hex}" | ||
| location = "us-central1" | ||
| uniform_bucket_level_access = true | ||
| } | ||
|
|
||
| # Create index content | ||
| resource "google_storage_bucket_object" "data" { | ||
| name = "contents/data.json" | ||
| bucket = google_storage_bucket.bucket.name | ||
| content = <<EOF | ||
| {"id": "42", "embedding": [0.5, 1.0], "restricts": [{"namespace": "class", "allow": ["cat", "pet"]},{"namespace": "category", "allow": ["feline"]}]} | ||
| {"id": "43", "embedding": [0.6, 1.0], "restricts": [{"namespace": "class", "allow": ["dog", "pet"]},{"namespace": "category", "allow": ["canine"]}]} | ||
| EOF | ||
| } | ||
|
|
||
| resource "google_vertex_ai_index" "default" { | ||
| region = "us-central1" | ||
| display_name = "sample-index-batch-update" | ||
| description = "A sample index for batch update" | ||
| labels = { | ||
| foo = "bar" | ||
| } | ||
|
|
||
| metadata { | ||
| contents_delta_uri = "gs://${google_storage_bucket.bucket.name}/contents" | ||
| config { | ||
| dimensions = 2 | ||
| approximate_neighbors_count = 150 | ||
| distance_measure_type = "DOT_PRODUCT_DISTANCE" | ||
| algorithm_config { | ||
| tree_ah_config { | ||
| leaf_node_embedding_count = 500 | ||
| leaf_nodes_to_search_percent = 7 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| index_update_method = "BATCH_UPDATE" | ||
|
|
||
| timeouts { | ||
| create = "2h" | ||
| update = "1h" | ||
| } | ||
| } | ||
| # [END aiplatform_deploy_index_endpoint_sample] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /** | ||
| * Copyright 2024 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
|
|
||
| # [START aiplatform_create_streaming_index_sample] | ||
| # Cloud Storage bucket name must be unique | ||
| resource "random_id" "bucket_name_suffix" { | ||
| byte_length = 8 | ||
| } | ||
|
|
||
| # Create a Cloud Storage bucket | ||
| resource "google_storage_bucket" "bucket" { | ||
| name = "vertex-ai-index-bucket-${random_id.bucket_name_suffix.hex}" | ||
| location = "us-central1" | ||
| uniform_bucket_level_access = true | ||
| } | ||
|
|
||
| # Create index content | ||
| resource "google_storage_bucket_object" "data" { | ||
| name = "contents/data.json" | ||
| bucket = google_storage_bucket.bucket.name | ||
| content = <<EOF | ||
| {"id": "42", "embedding": [0.5, 1.0], "restricts": [{"namespace": "class", "allow": ["cat", "pet"]},{"namespace": "category", "allow": ["feline"]}]} | ||
| {"id": "43", "embedding": [0.6, 1.0], "restricts": [{"namespace": "class", "allow": ["dog", "pet"]},{"namespace": "category", "allow": ["canine"]}]} | ||
| EOF | ||
| } | ||
|
|
||
| resource "google_vertex_ai_index" "streaming_index" { | ||
| region = "us-central1" | ||
| display_name = "sample-index-streaming-update" | ||
| description = "A sample index for streaming update" | ||
| labels = { | ||
| foo = "bar" | ||
| } | ||
|
|
||
| metadata { | ||
| contents_delta_uri = "gs://${google_storage_bucket.bucket.name}/contents" | ||
| config { | ||
| dimensions = 2 | ||
| approximate_neighbors_count = 150 | ||
| distance_measure_type = "DOT_PRODUCT_DISTANCE" | ||
| algorithm_config { | ||
| tree_ah_config { | ||
| leaf_node_embedding_count = 500 | ||
| leaf_nodes_to_search_percent = 7 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| index_update_method = "STREAM_UPDATE" | ||
|
|
||
| timeouts { | ||
| create = "2h" | ||
| update = "1h" | ||
| } | ||
| } | ||
| # [END aiplatform_create_streaming_index_sample] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.