TelegramChatApiLoader#

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

Load Telegram chat json directory dump.

Initialize with API parameters.

Parameters:
  • chat_entity (Optional[EntityLike]) – The chat entity to fetch data from.

  • api_id (Optional[int]) – The API ID.

  • api_hash (Optional[str]) – The API hash.

  • username (Optional[str]) – The username.

  • file_path (str) – 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.

alazy_load()

A lazy loader for Documents.

aload()

Load data into Document objects.

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: EntityLike | None = None, api_id: int | None = None, api_hash: str | None = None, username: str | None = None, file_path: str = 'telegram_data.json')[source]#

Initialize with API parameters.

Parameters:
  • chat_entity (Optional[EntityLike]) – The chat entity to fetch data from.

  • api_id (Optional[int]) – The API ID.

  • api_hash (Optional[str]) – The API hash.

  • username (Optional[str]) – The username.

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

async alazy_load() AsyncIterator[Document]#

A lazy loader for Documents.

Return type:

AsyncIterator[Document]

async aload() list[Document]#

Load data into Document objects.

Return type:

list[Document]

async fetch_data_from_telegram() None[source]#

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

Return type:

None

lazy_load() Iterator[Document]#

A lazy loader for Documents.

Return type:

Iterator[Document]

load() List[Document][source]#

Load documents.

Return type:

List[Document]

load_and_split(text_splitter: TextSplitter | None = None) list[Document]#

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

Do not override this method. It should be considered to be deprecated!

Parameters:

text_splitter (Optional[TextSplitter]) – TextSplitter instance to use for splitting documents. Defaults to RecursiveCharacterTextSplitter.

Returns:

List of Documents.

Return type:

list[Document]

Examples using TelegramChatApiLoader