Class SpannerChatMessageHistory (0.6.0)

SpannerChatMessageHistory(
    instance_id: str,
    database_id: str,
    session_id: str,
    table_name: str,
    client: typing.Optional[google.cloud.spanner_v1.client.Client] = None,
)

Chat message history that stores history in Spanner.

Properties

messages

Retrieve the messages from Cloud Spanner

Methods

_verify_schema

_verify_schema() -> None

Verify table exists with required schema for SpannerChatMessageHistory class. Use helper method MSSQLEngine.create_chat_history_table(...) to create table with valid schema.

add_message

add_message(message: langchain_core.messages.base.BaseMessage) -> None

Append the message to the record in Cloud Spanner

clear

clear() -> None

Clear session memory from Cloud Spanner

create_chat_history_table

create_chat_history_table(
    instance_id: str,
    database_id: str,
    table_name: str,
    client: typing.Optional[google.cloud.spanner_v1.client.Client] = None,
) -> None

Create a chat history table in a Cloud Spanner database.

Parameters
Name Description
instance_id str

The ID of the Cloud Spanner instance.

database_id str

The ID of the Cloud Spanner database.

table_name str

The name of the table to be created.

client spanner.Client, optional

An instance of the Cloud Spanner client. Defaults to None.

Exceptions
Type Description
Exception If the specified instance or database does not exist.
Returns
Type Description
Operation The operation to create the table.