0.16.0 (latest) 0.15.0 0.14.1 0.13.0 0.12.1 0.11.1 0.10.0 0.9.0 0.8.0 0.7.0 0.6.1 0.5.0 0.4.1

    PostgresChatMessageHistory(
        key: object,
        engine: langchain_google_cloud_sql_pg.engine.PostgresEngine,
        history: langchain_google_cloud_sql_pg.async_chat_message_history.AsyncPostgresChatMessageHistory,
    )

Chat message history stored in an Cloud SQL for PostgreSQL database.

## Properties

### messages

Fetches all messages stored in AlloyDB.

## Methods

### PostgresChatMessageHistory

    PostgresChatMessageHistory(
        key: object,
        engine: langchain_google_cloud_sql_pg.engine.PostgresEngine,
        history: langchain_google_cloud_sql_pg.async_chat_message_history.AsyncPostgresChatMessageHistory,
    )

PostgresChatMessageHistory constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `key` | `object` Key to prevent direct constructor usage. |
| `engine` | `PostgresEngine` Database connection pool. |
| `history` | `AsyncPostgresChatMessageHistory` Native async 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 PostgreSQL

### aadd_messages

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

Append a list of messages to the record in PostgreSQL

### aclear

    aclear() -> None

Clear session memory from PostgreSQL

### add_message

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

Append the message to the record in PostgreSQL

### add_messages

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

Append a list of messages to the record in PostgreSQL

### clear

    clear() -> None

Clear session memory from PostgreSQL

### create

    create(
        engine: langchain_google_cloud_sql_pg.engine.PostgresEngine,
        session_id: str,
        table_name: str,
        schema_name: str = "public",
    ) -> langchain_google_cloud_sql_pg.chat_message_history.PostgresChatMessageHistory

Create a new PostgresChatMessageHistory instance.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `engine` | `PostgresEngine` Postgres 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, optional` Schema name for the chat message history table. Defaults to "public". |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `IndexError` | If the table provided does not contain required schema. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `PostgresChatMessageHistory` | A newly created instance of PostgresChatMessageHistory. |

### create_sync

    create_sync(
        engine: langchain_google_cloud_sql_pg.engine.PostgresEngine,
        session_id: str,
        table_name: str,
        schema_name: str = "public",
    ) -> langchain_google_cloud_sql_pg.chat_message_history.PostgresChatMessageHistory

Create a new PostgresChatMessageHistory instance.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `engine` | `PostgresEngine` Postgres 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, optional` Database schema name for the chat message history table. Defaults to "public". |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `IndexError` | If the table provided does not contain required schema. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `PostgresChatMessageHistory` | A newly created instance of PostgresChatMessageHistory. |