docstrings: `chat_loaders` (#10307)

Updated docstrings. Made them consistent across the module.
bagatur/konko
Leonid Ganeline 1 year ago committed by GitHub
parent 8826293c88
commit 1b3ea1eeb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,19 @@
"""Load chat messages from common communications platforms for finetuning.
"""**Chat Loaders** load chat messages from common communications platforms.
This module provides functions to load chat messages from various
Load chat messages from various
communications platforms such as Facebook Messenger, Telegram, and
WhatsApp. The loaded chat messages can be used for finetuning models.
"""
WhatsApp. The loaded chat messages can be used for fine-tuning models.
**Class hierarchy:**
.. code-block::
BaseChatLoader --> <name>ChatLoader # Examples: WhatsAppChatLoader, IMessageChatLoader
**Main helpers:**
.. code-block::
ChatSession
""" # noqa: E501

@ -1,10 +1,3 @@
"""Base definitions for chat loaders.
A chat loader is a class that loads chat messages from an external
source such as a file or a database. The chat messages can then be
used for finetuning.
"""
from abc import ABC, abstractmethod
from typing import Iterator, List, Sequence, TypedDict
@ -12,7 +5,7 @@ from langchain.schema.messages import BaseMessage
class ChatSession(TypedDict):
"""A chat session represents a single
"""Chat Session represents a single
conversation, channel, or other group of messages."""
messages: Sequence[BaseMessage]

@ -10,7 +10,7 @@ logger = logging.getLogger(__file__)
class SingleFileFacebookMessengerChatLoader(BaseChatLoader):
"""A chat loader for loading Facebook Messenger chat data from a single file.
"""Load `Facebook Messenger` chat data from a single file.
Args:
path (Union[Path, str]): The path to the chat file.
@ -45,7 +45,7 @@ class SingleFileFacebookMessengerChatLoader(BaseChatLoader):
class FolderFacebookMessengerChatLoader(BaseChatLoader):
"""A chat loader for loading Facebook Messenger chat data from a folder.
"""Load `Facebook Messenger` chat data from a folder.
Args:
path (Union[str, Path]): The path to the directory

@ -62,7 +62,7 @@ def _get_message_data(service: Any, message: Any) -> ChatSession:
class GMailLoader(BaseChatLoader):
"""This loader goes over how to load data from GMail.
"""Load data from `GMail`.
There are many ways you could want to load data from GMail.
This loader is currently fairly opinionated in how to do so.

@ -1,14 +1,3 @@
"""IMessage Chat Loader.
This class is used to 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.
"""
from __future__ import annotations
from pathlib import Path
@ -22,6 +11,17 @@ if TYPE_CHECKING:
class IMessageChatLoader(chat_loaders.BaseChatLoader):
"""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.
"""
def __init__(self, path: Optional[Union[str, Path]] = None):
"""
Initialize the IMessageChatLoader.

@ -12,6 +12,8 @@ logger = logging.getLogger(__name__)
class SlackChatLoader(chat_loaders.BaseChatLoader):
"""Load `Slack` conversations from a dump zip file."""
def __init__(
self,
path: Union[str, Path],

@ -13,8 +13,7 @@ logger = logging.getLogger(__name__)
class TelegramChatLoader(chat_loaders.BaseChatLoader):
"""A loading utility for converting telegram conversations
to LangChain chat messages.
"""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

@ -12,6 +12,8 @@ logger = logging.getLogger(__name__)
class WhatsAppChatLoader(chat_loaders.BaseChatLoader):
"""Load `WhatsApp` conversations from a dump zip file or directory."""
def __init__(self, path: str):
"""Initialize the WhatsAppChatLoader.

Loading…
Cancel
Save