examples/google-cloudsql-chat-message-history-example/README.md
This example demonstrates how to use CloudSQL for Postgres as a backend for the ChatMessageHistory for LangChain in Go.
Creates a CloudSQL Chat Message History:
cloudsql.PostgresEngine object to establish a connection to the CloudSQL database.cloudsql.ChatMessageHistory object, which provides methods to store, retrieve, and clear message contents with a specific session ID.Add Single Messages:
Add Multiple Messages:
Overwrite Messages:
Clear All Messages:
Set the following environment variables. Your CloudSQL values can be found in the Google Cloud Console:
export PROJECT_ID=<your project Id>
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>
export POSTGRES_SESSION_ID=<your sessionID>
Run the Go example:
go run google_cloudsql_chat_message_history_example.go