examples/google-cloudsql-vectorstore-example/README.md
This example demonstrates how to use Cloud SQL for Postgres for vector similarity search with LangChain in Go.
Creates a Cloud SQL VectorStore:
cloudsql.PostgresEngine object to establish a connection to the Cloud SQL database.cloudsql.VectorStore object using a VertexAI model for embeddings.Initializes VertexAI Embeddings:
Adds Sample Documents:
Performs Similarity Searches:
Set the following environment variables:
export PROJECT_ID=<your project Id>
export GOOGLE_CLOUD_LOCATION=<your cloud location>
export POSTGRES_USERNAME=<your user>
export POSTGRES_PASSWORD=<your password>
export POSTGRES_REGION=<your region>
export POSTGRES_INSTANCE=<your instance>
export POSTGRES_DATABASE=<your database>
export POSTGRES_TABLE=<your tablename>
Run the Go example:
go run google_cloudsql_vectorstore_example.go
cloudsql.PostgresEngine for connection pooling.cloudsql.VectorStore.This example provides a practical demonstration of using vector databases for semantic search and similarity matching, which can be incredibly useful for various AI and machine learning applications.