examples/google-alloydb-chat-message-history-example/README.md
This example demonstrates how to use AlloyDB for Postgres as a backend for the ChatMessageHistory for LangChain in Go.
Creates an AlloyDB Chat Message History:
alloydb.PostgresEngine object to establish a connection to the AlloyDB database.alloydb.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 AlloyDB values can be found in the Google Cloud Console:
export PROJECT_ID=<your project Id>
export ALLOYDB_USERNAME=<your user>
export ALLOYDB_PASSWORD=<your password>
export ALLOYDB_REGION=<your region>
export ALLOYDB_CLUSTER=<your cluster>
export ALLOYDB_INSTANCE=<your instance>
export ALLOYDB_DATABASE=<your database>
export ALLOYDB_TABLE=<your tablename>
export ALLOYDB_SESSION_ID=<your sessionID>
Run the Go example:
go run google_alloydb_chat_message_history_example.go