CoolFace
Apppublic

svjack/conversation-viewer-classic

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes
App README

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 template

Quick 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)
bash
# Windows
pip install uv

# Or use other installation methods, refer to: https://github.com/astral-sh/uv
2. Start the service
bash
# 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 service

Method 2: Using traditional method

1. Install dependencies
bash
pip install -r requirements.txt
2. Start the service
bash
# Directly run the application
python app.py --port 9051

3. Prepare Data

There are two ways to prepare data:

Method A: Create symbolic link (Recommended)
bash
# Execute in conversation-viewer directory
mklink /J data\files ..\..\data\files
Method B: Copy files
bash
# 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

  1. 1.In the application, click the "โฌ‡๏ธ Download" button below AI reply messages
  2. 2.The system will automatically download JSON files to the browser's default download directory
  3. 3.Copy the downloaded JSON files to the conversation-viewer/hist/ directory

View Conversations

  1. 1.Visit http://localhost:9051 to view the conversation list
  2. 2.Click the "View Details" button to enter the conversation details page
  3. 3.On the details page you can:
  4. 4.View complete message flow
  5. 5.Play videos and audio
  6. 6.View images
  7. 7.Download attachment files

File Access

  • โ€”Multimedia files accessed via /files/{file_id}
  • โ€”Conversation history accessed via /conversation/{filename}
  • โ€”API endpoints: /api/conversations and /api/conversation/{filename}

Configuration

Changing Port

You can change the port via command line arguments:

bash
# Start with specified port
python app.py --port 9060

# Or modify port parameters in the startup script

You can also modify the default port in the code (edit app.py):

python
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:

python
BASE_DIR = Path(__file__).parent
FILES_DIR = BASE_DIR / "data" / "files"  # Multimedia files directory
HIST_DIR = BASE_DIR / "hist"             # Conversation history directory

API Endpoints

Get Conversation List

GET /api/conversations

Response example:

json
{
  "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

  1. 1.File Security: The application checks file paths to prevent directory traversal attacks
  2. 2.File Types: Supports common image, video, and audio formats
  3. 3.Encoding Issues: Ensure JSON files use UTF-8 encoding
  4. 4.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:
bash
  python app.py --port 9060

Issue 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

  1. 1.Add new route handler functions in app.py
  2. 2.Add or modify HTML templates in templates/
  3. 3.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