# Class AlloyDBChatMessageHistory (0.15.0)

0.15.0 (latest) 0.14.0 0.12.0 0.11.0 0.10.0 0.9.3 0.8.0 0.7.0 0.6.0 0.5.0 0.4.1 0.3.0 0.2.2

    AlloyDBChatMessageHistory(
        key: object,
        engine: langchain_google_alloydb_pg.engine.AlloyDBEngine,
        history: langchain_google_alloydb_pg.async_chat_message_history.AsyncAlloyDBChatMessageHistory,
    )

Chat message history stored in an AlloyDB for PostgreSQL database.

## Properties

### messages

Fetches all messages stored in AlloyDB.

## Methods

### AlloyDBChatMessageHistory

    AlloyDBChatMessageHistory(
        key: object,
        engine: langchain_google_alloydb_pg.engine.AlloyDBEngine,
        history: langchain_google_alloydb_pg.async_chat_message_history.AsyncAlloyDBChatMessageHistory,
    )

AlloyDBChatMessageHistory constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `key` | `object` Key to prevent direct constructor usage. |
| `engine` | `AlloyDBEngine` Database connection pool. |
| `history` | `AsyncAlloyDBChatMessageHistory` Async only implementation. |

| **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

### clear

    clear() -> None

Clear session memory from AlloyDB

### create

    create(
        engine: langchain_google_alloydb_pg.engine.AlloyDBEngine,
        session_id: str,
        table_name: str,
        schema_name: str = "public",
    ) -> 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. |
| `schema_name` | `str` The schema name where the table is located (default: "public"). |

| **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,
        schema_name: str = "public",
    ) -> 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. |