A powerful tool for processing AI chat logs - Group by Agent · Local Processing · Privacy Safe
ChatLog Converter is a lightweight, privacy-focused tool designed to process and transform AI chat conversation logs. It automatically detects conversation structure, groups messages by agent name, and converts them into various formats suitable for analysis, backup, or model fine-tuning.
- 🔒 Privacy First: All processing happens locally - your data never leaves your machine
- 🎯 Smart Detection: Automatically identifies agent names, roles, content, and timestamps
- 📊 Multiple Modes: Extract specific agents, classify all agents, or convert to JSON formats
- 🎨 Modern UI: Clean web interface with dark theme and intuitive workflow
- 💻 CLI Support: Command-line interface for automation and batch processing
- 🌍 Bilingual: Full support for Chinese and English interfaces
- 📦 Zero Config: Works out of the box with automatic delimiter detection
- ⚡ Batch Processing: Process multiple files at once with automatic chunked processing for large files
- 🤖 OpenAI Ready: Direct conversion to JSONL format for OpenAI/Azure fine-tuning
- AI Developers: Organize multi-agent conversation data for model fine-tuning
- Data Analysts: Clean and categorize chat logs for analysis
- Regular Users: Backup and manage personal AI conversation records
- Researchers: Process large-scale dialogue datasets efficiently
# Clone the repository
git clone https://github.com/Edeeron/chatlog-converter.git
cd chatlog-converter
# Install dependencies
pip install -r requirements.txtNote: On Linux/macOS, you may need to use pip3 and python3 instead of pip and python.
# Windows
python main.py
# Linux/macOS
python3 main.pyThen open your browser to: http://127.0.0.1:8010
# Launch CLI mode
# Windows
python main.py --cli
# Linux/macOS
python3 main.py --cli
# Or use CLI directly
# Windows
python cli.py convert chat.csv --mode finetune
# Linux/macOS
python3 cli.py convert chat.csv --mode finetune| Mode | Description | Output |
|---|---|---|
| 📄 Extract Agent | Extract all conversations for a specific agent | CSV |
| 📑 Classify Agents | Split mixed conversations by agent into separate files | Multiple CSVs |
| 🔧 JSON - Storage Format | Convert with full metadata (message_id, turn_id, token_count) | JSON |
| 🔗 JSON - Context Format | Simplified format (role + content + timestamp) | JSON |
| 🤖 OpenAI Fine-tuning | Pure messages format in JSONL for OpenAI/Azure fine-tuning | JSONL |
- Select Mode: Choose your processing mode
- Upload File: Drag & drop your CSV/TXT file
- Confirm Mapping: Verify auto-detected column mappings
- Process & Save: Click to process and download results
# Auto-detect and convert to JSON
python cli.py convert chat.csv --mode finetune
# Extract specific agent
python cli.py extract chat.csv --agent "GPT-4" --output ./extracted
# Classify all agents
python cli.py classify chat.csv --output ./classified
# Preview file structure (first 10 rows)
python cli.py preview chat.csv --rows 10
# Set language to English
python cli.py lang en
# Force streaming mode for large files
python cli.py convert large_file.csv --mode context --streamingSuppose you have a chat log containing multiple AI assistants and only want to extract conversations with "Customer Service Bot":
- Select "📄 Extract Agent" mode
- Upload
chat_history.csv - Enter in the "Target Agent" input box:
Customer Service Bot - Click "Preview Match" to confirm results
- Click "Start Processing" and save
Output file: chat_history_extracted_Customer_Service_Bot.csv
Convert chat logs to JSON format with complete metadata:
- Select "🔧 JSON - Storage Format" mode
- Upload file and confirm field mappings
- Check "Reverse message sequence" (if you need chronological order from old to new)
- Save as JSON file
Output example:
[
{
"conversation_id": "conv_Customer_Service_Bot_001",
"user_id": "",
"agent_name": "Customer Service Bot",
"created_at": "2024-05-09 11:20:45",
"messages": [
{
"message_id": "msg_001",
"turn_id": "turn_001",
"role": "user",
"content": "Hello, I'd like to inquire about a product issue",
"timestamp": "2024-05-09 11:20:45",
"token_count": 15
},
{
"message_id": "msg_002",
"turn_id": "turn_001",
"role": "assistant",
"content": "Hello! Happy to assist you, what questions do you have?",
"timestamp": "2024-05-09 11:20:46",
"token_count": 18
}
]
}
]Split a mixed chat log with multiple agents by agent name:
- Select "📑 Classify Agents" mode
- Upload
mixed_conversation.csv - Confirm Agent column detection is correct
- Click "Start Processing"
Output files:
mixed_conversation_GPT4.csvmixed_conversation_Claude.csvmixed_conversation_Customer_Service_Bot.csv
Convert chat logs directly to JSONL format for OpenAI/Azure fine-tuning:
- Select "🤖 OpenAI Fine-tuning" mode
- Upload your CSV file
- Confirm field mappings (Agent, Role, Content columns)
- Click "Start Processing"
Output example (chat_history_openai.jsonl):
{"messages": [{"role": "user", "content": "Hello, how are you?"}, {"role": "assistant", "content": "I'm doing well! How can I help you today?"}]}
{"messages": [{"role": "user", "content": "What's the weather like?"}, {"role": "assistant", "content": "It's sunny and warm today."}]}This format is directly compatible with OpenAI's fine-tuning API - no conversion needed!
- Input: CSV (comma/tab delimited), TXT (table format)
- Output: CSV, JSON (storage/context format), JSONL (OpenAI fine-tuning)
- Encoding: UTF-8-SIG (Excel compatible)
The tool uses an intelligent scoring system that combines:
- Keyword matching: Recognizes common column names in multiple languages (Chinese & English)
- Heuristic analysis: Evaluates data characteristics such as value diversity, text length, and format patterns
- Sample validation: Confirms detection accuracy by analyzing the first 50 rows
Uses OpenAI's official tiktoken library (cl100k_base encoding) for accurate GPT-4 token counting, ensuring consistency with OpenAI API. Falls back to character count if the library is unavailable.
- Auto delimiter detection: Intelligently recognizes multiple CSV/TXT formats (comma/tab)
- Streaming mode: Automatically enabled for files >100MB, constant memory usage ~50-100MB
- Batch processing: Process multiple files at once, reusing first detection results for efficiency
- Scope: Streaming mode currently applies only to JSON conversion modes (
finetune,context, andopenai)
A: Ensure the file uses UTF-8 encoding, has column headers in the first row, and consistent data format. Use python cli.py preview your_file.csv to check structure.
A: In the web interface, manually adjust field mappings in the "Field Mapping" section after uploading.
A: Supports Chinese and English:
- Agent:
agent名称,agent_name,智能体,bot - Role:
role,角色,speaker,说话人 - Content:
content,内容,message,消息 - Time:
time,时间,timestamp,日期
chatlog-converter/
├── main.py # Unified entry point (Web/CLI selector)
├── api.py # FastAPI backend service
├── cli.py # Command-line interface
├── core.py # Core processing logic
├── static/
│ └── index.html # Web frontend (single-page app)
├── locales/
│ ├── zh.json # Chinese translations
│ └── en.json # English translations
├── requirements.txt # Python dependencies
├── LICENSE # MIT License
├── README.md # This file (English documentation)
└── README-zh.md # Chinese documentation
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with FastAPI and Uvicorn
- Token counting powered by tiktoken
- Inspired by the need for privacy-safe AI chat log management
Made with ❤️ by Edeeron
⭐ Star this repo if you find it helpful!