langchain_community.document_loaders.telegram.TelegramChatApiLoader¶

class langchain_community.document_loaders.telegram.TelegramChatApiLoader(chat_entity: Optional[EntityLike] = None, api_id: Optional[int] = None, api_hash: Optional[str] = None, username: Optional[str] = None, file_path: str = 'telegram_data.json')[source]¶

Load Telegram chat json directory dump.

Initialize with API parameters.

Parameters
  • chat_entity – The chat entity to fetch data from.

  • api_id – The API ID.

  • api_hash – The API hash.

  • username – The username.

  • file_path – The file path to save the data to. Defaults to “telegram_data.json”.

Methods

__init__([chat_entity, api_id, api_hash, ...])

Initialize with API parameters.

fetch_data_from_telegram()

Fetch data from Telegram API and save it as a JSON file.

lazy_load()

A lazy loader for Documents.

load()

Load documents.

load_and_split([text_splitter])

Load Documents and split into chunks.

__init__(chat_entity: Optional[EntityLike] = None, api_id: Optional[int] = None, api_hash: Optional[str] = None, username: Optional[str] = None, file_path: str = 'telegram_data.json')[source]¶

Initialize with API parameters.

Parameters
  • chat_entity – The chat entity to fetch data from.

  • api_id – The API ID.

  • api_hash – The API hash.

  • username – The username.

  • file_path – The file path to save the data to. Defaults to “telegram_data.json”.

async fetch_data_from_telegram() None[source]¶

Fetch data from Telegram API and save it as a JSON file.

lazy_load() Iterator[Document]¶

A lazy loader for Documents.

load() List[Document][source]¶

Load documents.

load_and_split(text_splitter: Optional[TextSplitter] = None) List[Document]¶

Load Documents and split into chunks. Chunks are returned as Documents.

Parameters

text_splitter – TextSplitter instance to use for splitting documents. Defaults to RecursiveCharacterTextSplitter.

Returns

List of Documents.

Examples using TelegramChatApiLoader¶