# FileChatMessageHistory

> **Class** in `langchain_community`

📖 [View in docs](https://reference.langchain.com/python/langchain-community/chat_message_histories/file/FileChatMessageHistory)

Chat message history that stores history in a local file.

## Signature

```python
FileChatMessageHistory(
    self,
    file_path: str,
    *,
    encoding: Optional[str] = None,
    ensure_ascii: bool = True,
)
```

## Extends

- `BaseChatMessageHistory`

## Constructors

```python
__init__(
    self,
    file_path: str,
    *,
    encoding: Optional[str] = None,
    ensure_ascii: bool = True,
) -> None
```

| Name | Type |
|------|------|
| `file_path` | `str` |
| `encoding` | `Optional[str]` |
| `ensure_ascii` | `bool` |


## Properties

- `file_path`
- `encoding`
- `ensure_ascii`
- `messages`

## Methods

- [`add_message()`](https://reference.langchain.com/python/langchain-community/chat_message_histories/file/FileChatMessageHistory/add_message)
- [`clear()`](https://reference.langchain.com/python/langchain-community/chat_message_histories/file/FileChatMessageHistory/clear)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-community/blob/4b280287bd55b99b44db2dd849f02d66c89534d5/libs/community/langchain_community/chat_message_histories/file.py#L11)