Google Cloud Bigtable is a key-value and wide-column store, ideal for fast access to structured, semi-structured, or unstructured data. Extend your database application to build AI-powered experiences leveraging Bigtable’s LangChain integrations.This notebook goes over how to use Google Cloud Bigtable to store chat message history with the
BigtableChatMessageHistory
class.
Learn more about the package on GitHub.
Before You Begin
To run this notebook, you will need to do the following:- Create a Google Cloud Project
- Enable the Bigtable API
- Create a Bigtable instance
- Create a Bigtable table
- Create Bigtable access credentials
🦜🔗 Library Installation
The integration lives in its ownlangchain-google-bigtable
package, so we need to install it.
☁ Set Your Google Cloud Project
Set your Google Cloud project so that you can leverage Google Cloud resources within this notebook. If you don’t know your project ID, try the following:- Run
gcloud config list
. - Run
gcloud projects list
. - See the support page: Locate the project ID.
🔐 Authentication
Authenticate to Google Cloud as the IAM user logged into this notebook in order to access your Google Cloud Project.- If you are using Colab to run this notebook, use the cell below and continue.
- If you are using Vertex AI Workbench, check out the setup instructions here.
Basic Usage
Initialize Bigtable schema
The schema for BigtableChatMessageHistory requires the instance and table to exist, and have a column family calledlangchain
.
BigtableChatMessageHistory
To initialize theBigtableChatMessageHistory
class you need to provide only 3 things:
instance_id
- The Bigtable instance to use for chat message history.table_id
: The Bigtable table to store the chat message history.session_id
- A unique identifier string that specifies an id for the session.