svjack/conversation-viewer-classic
0
Conversation Viewer
A standalone web application for viewing exported conversation history JSON files and displaying related multimedia content.
Features
- ๐ Conversation List: Display all exported conversation history files
- ๐ Conversation Details: Complete display of conversation content, including message flow and attachments
- ๐ผ๏ธ Multimedia Display: Direct playback and viewing of images, videos, and audio
- ๐ Statistics: Show message count, user/AI message ratio, etc.
- ๐ Real-time Updates: Automatically detect new files and refresh the list
- ๐ฑ Responsive Design: Adapted for desktop and mobile devices
Directory Structure
conversation-viewer/
โโโ app.py # FastAPI main application
โโโ requirements.txt # Python dependencies
โโโ start_english.bat # Windows startup script (English)
โโโ README.md # Documentation
โโโ test_port.py # Port testing utility
โโโ uv.lock # uv dependency lock file
โโโ .venv/ # Python virtual environment
โโโ data/ # Data directory
โ โโโ files/ # Multimedia files (to be linked)
โโโ hist/ # Conversation history JSON files
โโโ static/ # Static files (CSS/JS) - currently empty
โโโ templates/ # HTML templates
โโโ index.html # Home page template
โโโ conversation.html # Conversation details templateQuick Start
Method 1: Using uv (Recommended)
uv is a fast Python package manager and resolver that provides better dependency management.
1. Install uv (if not already installed)
# Windows
pip install uv
# Or use other installation methods, refer to: https://github.com/astral-sh/uv2. Start the service
# Windows - double click start_english.bat
# Or run from command line:
start_english.bat
# The script will automatically:
# 1. Check if uv is installed
# 2. Create virtual environment (.venv) if not exists
# 3. Install dependencies
# 4. Start the serviceMethod 2: Using traditional method
1. Install dependencies
pip install -r requirements.txt2. Start the service
# Directly run the application
python app.py --port 90513. Prepare Data
There are two ways to prepare data:
Method A: Create symbolic link (Recommended)
# Execute in conversation-viewer directory
mklink /J data\files ..\..\data\filesMethod B: Copy files
# Copy multimedia files
copy ..\..\data\files\* data\files\
# Copy conversation history files to hist directory
copy *.json hist\4. Access the Application
Open browser and visit: http://localhost:9051
Note: Default port is 9051 (greater than 9050). To change the port: ``bash python app.py --port 9060 # Use port 9060 ``Usage Instructions
Export Conversation History
- In the application, click the "โฌ๏ธ Download" button below AI reply messages
- The system will automatically download JSON files to the browser's default download directory
- Copy the downloaded JSON files to the
conversation-viewer/hist/directory
View Conversations
- Visit http://localhost:9051 to view the conversation list
- Click the "View Details" button to enter the conversation details page
- On the details page you can:
- View complete message flow
- Play videos and audio
- View images
- Download attachment files
File Access
- Multimedia files accessed via
/files/{file_id} - Conversation history accessed via
/conversation/{filename} - API endpoints:
/api/conversationsand/api/conversation/{filename}
Configuration
Changing Port
You can change the port via command line arguments:
# Start with specified port
python app.py --port 9060
# Or modify port parameters in the startup scriptYou can also modify the default port in the code (edit app.py):
parser.add_argument("--port", type=int, default=9051, help="Service port number (default: 9051)")Changing File Paths
Edit app.py and modify the following configuration:
BASE_DIR = Path(__file__).parent
FILES_DIR = BASE_DIR / "data" / "files" # Multimedia files directory
HIST_DIR = BASE_DIR / "hist" # Conversation history directoryAPI Endpoints
Get Conversation List
GET /api/conversationsResponse example:
{
"success": true,
"data": [
{
"filename": "conversation_20240115_103000.json",
"metadata": {...},
"stats": {...},
"preview": "User's first message...",
"export_time": "2024-01-15T10:30:00",
"size_kb": 45.2
}
],
"count": 1
}Get Conversation Details
GET /api/conversation/{filename}Get Multimedia Files
GET /files/{file_id}Notes
- File Security: The application checks file paths to prevent directory traversal attacks
- File Types: Supports common image, video, and audio formats
- Encoding Issues: Ensure JSON files use UTF-8 encoding
- Performance Considerations: Large conversation files (>10MB) may affect loading speed
Troubleshooting
Issue 1: Images/Videos not displaying
- Check if files exist in
data/files/directory - Check file permissions
- Check if file URLs are correct
Issue 2: Conversation list is empty
- Check if there are JSON files in
hist/directory - Check if JSON file format is correct
- Check console error messages
Issue 3: Service fails to start
- Check Python version (requires Python 3.7+)
- Check if dependencies are installed
- Check if port 9051 is occupied, try another port:
python app.py --port 9060Issue 4: start_english.bat not working
- Ensure file encoding is ASCII/ANSI (not UTF-8 with BOM)
- Check if uv is installed:
where uv - Run from command line to see error messages
Development
Adding New Features
- Add new route handler functions in
app.py - Add or modify HTML templates in
templates/ - Add CSS/JS files in
static/
Customizing Styles
Modify CSS styles in templates/, or add custom CSS files to static/css/
Extending Multimedia Support
Add new file type support in the media_types dictionary in app.py.
License
MIT License
