Class AlloyDBChatMessageHistory (0.5.0)

AlloyDBChatMessageHistory(
    key: object,
    engine: langchain_google_alloydb_pg.engine.AlloyDBEngine,
    session_id: str,
    table_name: str,
    messages: typing.List[langchain_core.messages.base.BaseMessage],
)

Chat message history stored in an AlloyDB.

Methods

AlloyDBChatMessageHistory

AlloyDBChatMessageHistory(
    key: object,
    engine: langchain_google_alloydb_pg.engine.AlloyDBEngine,
    session_id: str,
    table_name: str,
    messages: typing.List[langchain_core.messages.base.BaseMessage],
)

AlloyDBChatMessageHistory constructor.

Parameters
Name Description
key object

Key to prevent direct constructor usage.

engine AlloyDBEngine

database connection pool.

session_id str

Retrieve the table content with this session ID.

table_name str

Table name that stores the chat message history.

messages List[BaseMessage]

Messages to store.

Exceptions
Type Description
Exception If constructor is directly called by the user.

aadd_message

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

Append the message to the record in AlloyDB.

aadd_messages

aadd_messages(
    messages: typing.Sequence[langchain_core.messages.base.BaseMessage],
) -> None

Append a list of messages to the record in AlloyDB.

aclear

aclear() -> None

Clear session memory from AlloyDB.

add_message

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

Append the message to the record in AlloyDB.

add_messages

add_messages(
    messages: typing.Sequence[langchain_core.messages.base.BaseMessage],
) -> None

Append a list of messages to the record in AlloyDB.

async_messages

async_messages() -> None

Retrieve the messages from AlloyDB.

clear

clear() -> None

Clear session memory from AlloyDB.

create

create(
    engine: langchain_google_alloydb_pg.engine.AlloyDBEngine,
    session_id: str,
    table_name: str,
) -> langchain_google_alloydb_pg.chat_message_history.AlloyDBChatMessageHistory

Create a new AlloyDBChatMessageHistory instance.

Parameters
Name Description
engine AlloyDBEngine

AlloyDB engine to use.

session_id str

Retrieve the table content with this session ID.

table_name str

Table name that stores the chat message history.

Exceptions
Type Description
IndexError If the table provided does not contain required schema.
Returns
Type Description
AlloyDBChatMessageHistory A newly created instance of AlloyDBChatMessageHistory.

create_sync

create_sync(
    engine: langchain_google_alloydb_pg.engine.AlloyDBEngine,
    session_id: str,
    table_name: str,
) -> langchain_google_alloydb_pg.chat_message_history.AlloyDBChatMessageHistory

Create a new AlloyDBChatMessageHistory instance.

Parameters
Name Description
engine AlloyDBEngine

AlloyDB engine to use.

session_id str

Retrieve the table content with this session ID.

table_name str

Table name that stores the chat message history.

Exceptions
Type Description
IndexError If the table provided does not contain required schema.
Returns
Type Description
AlloyDBChatMessageHistory A newly created instance of AlloyDBChatMessageHistory.

sync_messages

sync_messages() -> None

Retrieve the messages from AlloyDB.