Workflow
1. 运行 analyze_chat.py 分析聊天记录
↓
2. AI 根据聊天文本生成内容 (ai_content.json)
↓
3. 运行 generate_report.py 生成日报图片 (.png)
⚠️ The final output is a PNG image, not HTML. Make sure the --output parameter uses the
.pngsuffix.
Usage steps
1. Analyze chat records
python scripts/analyze_chat.py <聊天记录.json> --output-stats stats.json --output-text simplified_chat.txt
Output:
stats.json- Statistics (chatterbox ranking, staying-up-late champion, word cloud, etc.)simplified_chat.txt- Full chat text, for AI analysis
2. AI-generated content
Based on simplified_chat.txt and stats.json, generate AI content according to the format in references/ai_prompt.md , and save it as ai_content.json。
The content AI needs to generate includes:
topics: Discussion hot topics (3-5)resources: Tutorials/resource sharingimportant_messages: Important messagesdialogues: Interesting conversationsqas: Q&Atalker_profiles: Characteristic tags of chatterbox members (common words are already counted by the script)
3. Generate daily report image
python scripts/generate_report.py --stats stats.json --ai-content ai_content.json --output report.png --clean-temp
✅ The output suffix must be
.png, using iPhone 14 Pro Max resolution (430x932 @3x)Using the
--clean-tempparameter can automatically delete temporary files after generation is complete (stats.json, ai_content.json, simplified_chat.txt, temporary HTML)Image generation requires installing playwright:
pip install playwright && playwright install chromium
Chat record JSON format
{
"meta": {
"name": "群名称",
"platform": "wechat",
"type": "group"
},
"members": [
{"platformId": "xxx", "accountName": "昵称", "groupNickname": "群昵称"}
],
"messages": [
{
"sender": "platformId",
"accountName": "昵称",
"groupNickname": "群昵称",
"timestamp": 1234567890,
"type": 0,
"content": "消息内容"
}
]
}
💡 Display name priority:
groupNickname>accountName
Message type (type):
0: Plain text (the script and AI analyze this type)1: Image2: Voice-to-text (the script and AI analyze this type, content format:[语音转文字] xxx)5: Animated emoji99: System message
Script analysis content (ensures accuracy)
| Data | Description |
|---|---|
| Total message count | Count of all messages |
| Active user count | Deduplicated user count |
| Time range | Time of first and last messages |
| Chatterbox ranking TOP3 | Sorted by number of messages + common words |
| Staying-up-late champion | The person most active latest between 23:00-06:00 |
| Word cloud data | jieba word segmentation + word frequency statistics |
AI-generated content (requires understanding context)
| Content | Input data |
|---|---|
| Discussion hot topics | Condensed text + word cloud TOP50 |
| Member profiles | Statements in the condensed text |
| Interesting conversations | High-interaction segments |
| Q&A identification | Question mark messages ± context |
| Tutorials/resources | Condensed full-text identification |
Dependencies
pip install jieba jinja2 playwright
playwright install chromium