Google Cloud Spanner is a highly scalable database that combines unlimited scalability with relational semantics, such as secondary indexes, strong consistency, schemas, and SQL providing 99.999% availability in one easy solution.This notebook goes over how to use
Spanner
to store chat message history with the SpannerChatMessageHistory
class.
Learn more about the package on GitHub.
langchain-google-spanner
package, so we need to install it.
gcloud config list
.gcloud projects list
.langchain-google-spanner
package requires that you enable the Spanner API in your Google Cloud Project.
SpannerChatMessageHistory
class requires a database table with a specific schema in order to store the chat message history.
The helper method init_chat_history_table()
that can be used to create a table with the proper schema for you.
SpannerChatMessageHistory
class you need to provide only 3 things:
instance_id
- The name of the Spanner instancedatabase_id
- The name of the Spanner databasesession_id
- A unique identifier string that specifies an id for the session.table_name
- The name of the table within the database to store the chat message history.