langchain_community.chat_loaders.imessage.IMessageChatLoader¶

class langchain_community.chat_loaders.imessage.IMessageChatLoader(path: Optional[Union[str, Path]] = None)[source]¶

Load chat sessions from the iMessage chat.db SQLite file.

It only works on macOS when you have iMessage enabled and have the chat.db file.

The chat.db file is likely located at ~/Library/Messages/chat.db. However, your terminal may not have permission to access this file. To resolve this, you can copy the file to a different location, change the permissions of the file, or grant full disk access for your terminal emulator in System Settings > Security and Privacy > Full Disk Access.

Initialize the IMessageChatLoader.

Parameters

path (str or Path, optional) – Path to the chat.db SQLite file. Defaults to None, in which case the default path ~/Library/Messages/chat.db will be used.

Methods

__init__([path])

Initialize the IMessageChatLoader.

lazy_load()

Lazy load the chat sessions from the iMessage chat.db and yield them in the required format.

load()

Eagerly load the chat sessions into memory.

__init__(path: Optional[Union[str, Path]] = None)[source]¶

Initialize the IMessageChatLoader.

Parameters

path (str or Path, optional) – Path to the chat.db SQLite file. Defaults to None, in which case the default path ~/Library/Messages/chat.db will be used.

lazy_load() Iterator[ChatSession][source]¶

Lazy load the chat sessions from the iMessage chat.db and yield them in the required format.

Yields

ChatSession – Loaded chat session.

load() List[ChatSession]¶

Eagerly load the chat sessions into memory.

Examples using IMessageChatLoader¶