Skip to main content
이 노트북은 Twitter에서 채팅 메시지를 로드하여 파인튜닝하는 방법을 보여줍니다. Apify를 활용하여 수행합니다. 먼저 Apify를 사용하여 트윗을 내보냅니다. 예제
import json

from langchain_community.adapters.openai import convert_message_to_dict
from langchain.messages import AIMessage
with open("example_data/dataset_twitter-scraper_2023-08-23_22-13-19-740.json") as f:
    data = json.load(f)
# Filter out tweets that reference other tweets, because it's a bit weird
tweets = [d["full_text"] for d in data if "t.co" not in d["full_text"]]
# Create them as AI messages
messages = [AIMessage(content=t) for t in tweets]
# Add in a system message at the start
# TODO: we could try to extract the subject from the tweets, and put that in the system message.
system_message = {"role": "system", "content": "write a tweet"}
data = [[system_message, convert_message_to_dict(m)] for m in messages]

Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I