TelegramChatLoader#
- class langchain_community.chat_loaders.telegram.TelegramChatLoader(path: str | Path)[source]#
Load telegram conversations to LangChain chat messages.
To export, use the Telegram Desktop app from https://desktop.telegram.org/, select a conversation, click the three dots in the top right corner, and select “Export chat history”. Then select “Machine-readable JSON” (preferred) to export. Note: the ‘lite’ versions of the desktop app (like “Telegram for MacOS”) do not support exporting chat history.
Initialize the TelegramChatLoader.
- Parameters:
path (Union[str, Path]) – Path to the exported Telegram chat zip, directory, json, or HTML file.
Methods
__init__
(path)Initialize the TelegramChatLoader.
Lazy load the messages from the chat file and yield them in as chat sessions.
load
()Eagerly load the chat sessions into memory.
- __init__(path: str | Path)[source]#
Initialize the TelegramChatLoader.
- Parameters:
path (Union[str, Path]) – Path to the exported Telegram chat zip, directory, json, or HTML file.
- lazy_load() Iterator[ChatSession] [source]#
Lazy load the messages from the chat file and yield them in as chat sessions.
- Yields:
ChatSession – The 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 TelegramChatLoader