"date": "2023-08-23T13:11:23",   "date_unixtime": "1692821483",   "from": "Jiminy Cricket",   "from_id": "user123450513",   "text": "You better trust your conscience",   "text_entities": [    {     "type": "plain",     "text": "You better trust your conscience"    }   ]  },  {   "id": 2,   "type": "message",   "date": "2023-08-23T13:13:20",   "date_unixtime": "1692821600",   "from": "Batman & Robin",   "from_id": "user6565661032",   "text": "What did you just say?",   "text_entities": [    {     "type": "plain",     "text": "What did you just say?"    }   ]  } ]}2. Create the Chat Loader‚ÄãAll that's required is the file path. You can optionally specify the user name that maps to an ai message as well an configure whether to merge message runs.from langchain.chat_loaders.telegram import TelegramChatLoaderloader = TelegramChatLoader(    path="./telegram_conversation.json", )3. Load messages‚ÄãThe load() (or lazy_load) methods return a list of "ChatSessions" that currently just contain a list of messages per loaded conversation.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 same sender into a single messagemerged_messages = merge_chat_runs(raw_messages)# Convert messages from "Jiminy Cricket" to AI messagesmessages: List[ChatSession] = list(map_ai_messages(merged_messages, sender="Jiminy Cricket"))Next Steps‚ÄãYou can then use these messages how you see fit, such as fine-tuning a model, few-shot example selection, or directly make predictions for the next message  from langchain.chat_models import ChatOpenAIllm = ChatOpenAI()for chunk in llm.stream(messages[0]['messages']):    print(chunk.content, end="", flush=True)    I said, "You better trust your conscience."PreviousSlackNextTwitter (via Apify)1. Create message dump2. Create the Chat Loader3. Load messagesNext
Telegram
Telegram ->: "date": "2023-08-23T13:11:23",   "date_unixtime": "1692821483",   "from": "Jiminy Cricket",   "from_id": "user123450513",   "text": "You better trust your conscience",   "text_entities": [    {     "type": "plain",     "text": "You better trust your conscience"    }   ]  },  {   "id": 2,   "type": "message",   "date": "2023-08-23T13:13:20",   "date_unixtime": "1692821600",   "from": "Batman & Robin",   "from_id": "user6565661032",   "text": "What did you just say?",   "text_entities": [    {     "type": "plain",     "text": "What did you just say?"    }   ]  } ]}2. Create the Chat Loader‚ÄãAll that's required is the file path. You can optionally specify the user name that maps to an ai message as well an configure whether to merge message runs.from langchain.chat_loaders.telegram import TelegramChatLoaderloader = TelegramChatLoader(    path="./telegram_conversation.json", )3. Load messages‚ÄãThe load() (or lazy_load) methods return a list of "ChatSessions" that currently just contain a list of messages per loaded conversation.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 same sender into a single messagemerged_messages = merge_chat_runs(raw_messages)# Convert messages from "Jiminy Cricket" to AI messagesmessages: List[ChatSession] = list(map_ai_messages(merged_messages, sender="Jiminy Cricket"))Next Steps‚ÄãYou can then use these messages how you see fit, such as fine-tuning a model, few-shot example selection, or directly make predictions for the next message  from langchain.chat_models import ChatOpenAIllm = ChatOpenAI()for chunk in llm.stream(messages[0]['messages']):    print(chunk.content, end="", flush=True)    I said, "You better trust your conscience."PreviousSlackNextTwitter (via Apify)1. Create message dump2. Create the Chat Loader3. Load messagesNext