IMessageChatLoader#
- class langchain_community.chat_loaders.imessage.IMessageChatLoader(path: str | Path | None = 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 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: str | Path | None = 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.
- Return type:
Iterator[ChatSession]
- load() list[ChatSession] #
Eagerly load the chat sessions into memory.
- Returns:
A list of chat sessions.
- Return type:
list[ChatSession]
Examples using IMessageChatLoader