Google Cloud AlloyDB for PostgreSQL is a fully managedThis notebook goes over how to usePostgreSQL
compatible database service for your most demanding enterprise workloads.AlloyDB
combines the best ofGoogle Cloud
withPostgreSQL
, for superior performance, scale, and availability. Extend your database application to build AI-powered experiences leveragingAlloyDB
Langchain integrations.
Google Cloud AlloyDB for PostgreSQL
to store chat message history with the AlloyDBChatMessageHistory
class.
Learn more about the package on GitHub.
langchain-google-alloydb-pg
package, so we need to install it.
gcloud config list
.gcloud projects list
.langchain-google-alloydb-pg
package requires that you enable the AlloyDB Admin API in your Google Cloud Project.
AlloyDBEngine
object. The AlloyDBEngine
configures a connection pool to your AlloyDB database, enabling successful connections from your application and following industry best practices.
To create a AlloyDBEngine
using AlloyDBEngine.from_instance()
you need to provide only 5 things:
project_id
: Project ID of the Google Cloud Project where the AlloyDB instance is located.region
: Region where the AlloyDB instance is located.cluster
: The name of the AlloyDB cluster.instance
: The name of the AlloyDB instance.database
: The name of the database to connect to on the AlloyDB instance.user
and password
arguments to AlloyDBEngine.from_instance()
:
user
: Database user to use for built-in database authentication and loginpassword
: Database password to use for built-in database authentication and login.AlloyDBChatMessageHistory
class requires a database table with a specific schema in order to store the chat message history.
The AlloyDBEngine
engine has a helper method init_chat_history_table()
that can be used to create a table with the proper schema for you.
AlloyDBChatMessageHistory
class you need to provide only 3 things:
engine
- An instance of a AlloyDBEngine
engine.session_id
- A unique identifier string that specifies an id for the session.table_name
: The name of the table within the AlloyDB database to store the chat message history.