current_timestamp = line.split(" ‚Äî ")[:2]                current_content = [                    line[len(current_sender) + len(current_timestamp) + 4 :].strip()                ]            elif re.match(r"\[\d{1,2}:\d{2} (?:AM|PM)\]", line.strip()):                results.append(                    HumanMessage(                        content="".join(current_content).strip(),                        additional_kwargs={                            "sender": current_sender,                            "events": [{"message_time": current_timestamp}],                        },                    )                )                current_timestamp = line.strip()[1:-1]                current_content = []            else:                current_content.append("\n" + line.strip())        if current_sender and current_content:            results.append(                HumanMessage(                    content="".join(current_content).strip(),                    additional_kwargs={                        "sender": current_sender,                        "events": [{"message_time": current_timestamp}],                    },                )            )        return chat_loaders.ChatSession(messages=results)    def lazy_load(self) -> Iterator[chat_loaders.ChatSession]:        """        Lazy load the messages from the chat file and yield them in the required format.        Yields:            A `ChatSession` object containing the loaded chat messages.        """        yield self._load_single_chat_session_from_txt(self.path)2. Create loader‚ÄãWe will point to the file we just wrote to disk.loader = DiscordChatLoader(    path="./discord_chats.txt",)3. Load Messages‚ÄãAssuming the format is correct, the loader will convert the chats to langchain messages.from typing import Listfrom langchain.chat_loaders.base import ChatSessionfrom langchain.chat_loaders.utils import (    map_ai_messages,    merge_chat_runs,)raw_messages = loader.lazy_load()# Merge consecutive messages from the
This notebook shows how to create your own chat loader that works on copy-pasted messages (from dms) to a list of LangChain messages.
This notebook shows how to create your own chat loader that works on copy-pasted messages (from dms) to a list of LangChain messages. ->: current_timestamp = line.split(" ‚Äî ")[:2]                current_content = [                    line[len(current_sender) + len(current_timestamp) + 4 :].strip()                ]            elif re.match(r"\[\d{1,2}:\d{2} (?:AM|PM)\]", line.strip()):                results.append(                    HumanMessage(                        content="".join(current_content).strip(),                        additional_kwargs={                            "sender": current_sender,                            "events": [{"message_time": current_timestamp}],                        },                    )                )                current_timestamp = line.strip()[1:-1]                current_content = []            else:                current_content.append("\n" + line.strip())        if current_sender and current_content:            results.append(                HumanMessage(                    content="".join(current_content).strip(),                    additional_kwargs={                        "sender": current_sender,                        "events": [{"message_time": current_timestamp}],                    },                )            )        return chat_loaders.ChatSession(messages=results)    def lazy_load(self) -> Iterator[chat_loaders.ChatSession]:        """        Lazy load the messages from the chat file and yield them in the required format.        Yields:            A `ChatSession` object containing the loaded chat messages.        """        yield self._load_single_chat_session_from_txt(self.path)2. Create loader‚ÄãWe will point to the file we just wrote to disk.loader = DiscordChatLoader(    path="./discord_chats.txt",)3. Load Messages‚ÄãAssuming the format is correct, the loader will convert the chats to langchain messages.from typing import Listfrom langchain.chat_loaders.base import ChatSessionfrom langchain.chat_loaders.utils import (    map_ai_messages,    merge_chat_runs,)raw_messages = loader.lazy_load()# Merge consecutive messages from the