Skip to main content

Convert GitHub Copilot chat history JSON files to formatted PDF documents

Project description

Copilot Chat History to PDF Converter

A Python package to convert GitHub Copilot chat history JSON files into formatted PDF documents. Perfect for students submitting chat logs for assignments or instructors analyzing student interactions with AI coding assistants.

Features

  • 🎨 Beautifully Formatted PDFs - Color-coded user/assistant messages with timestamps
  • 🤖 Model Tracking - Displays which AI model was used for each exchange
  • 🔧 Customizable - Text replacements, custom titles, page sizes, and more
  • 📊 Programmatic API - Extract and analyze chat data in your own Python scripts
  • 🚀 Easy to Use - Simple CLI for quick conversions

Installation

For Students (Simple Usage)

pip install copilot-history-pdf

For Development

git clone https://github.com/Oliver1811/copilot-history-pdf.git
cd copilot-history-pdf
pip install -e .

Quick Start

Command Line Usage

Convert a chat history JSON file to PDF:

copilot-to-pdf chat_history.json

With custom output path:

copilot-to-pdf chat_history.json -o my_submission.pdf

With custom title:

copilot-to-pdf chat_history.json --title "Assignment 1 - Student Name"

Python API Usage

Extract and analyze chat data programmatically:

import copilot_history_pdf

# Get all exchanges
exchanges = copilot_history_pdf.get_all_exchanges("chat_history.json")

# Print summary
for ex in exchanges:
    print(f"Exchange {ex['exchange_number']}: {ex['model_id']}")
    print(f"Q: {ex['user_message'][:100]}...")
    print(f"A: {ex['assistant_response'][:100]}...")
    print()

# Get metadata
meta = copilot_history_pdf.get_chat_metadata("chat_history.json")
print(f"Total exchanges: {meta['total_exchanges']}")
print(f"Models used: {', '.join(meta['model_ids'])}")

CLI Options

usage: copilot-to-pdf [-h] [-o OUTPUT] [--title TITLE] 
                      [--max-response-length MAX_RESPONSE_LENGTH]
                      [--replacements REPLACEMENTS] [--no-timestamps]
                      [--page-size PAGE_SIZE] [-v]
                      input

Convert GitHub Copilot chat history JSON to PDF

positional arguments:
  input                 Path to the input JSON file

optional arguments:
  -h, --help            Show this help message and exit
  -o OUTPUT, --output OUTPUT
                        Output PDF file path (default: chat_history.pdf)
  --title TITLE         Custom title for the PDF document
  --max-response-length MAX_RESPONSE_LENGTH
                        Maximum length for responses (default: 5000)
  --replacements REPLACEMENTS
                        JSON file with text replacements
  --no-timestamps       Omit timestamps from the PDF
  --page-size PAGE_SIZE
                        Page size: letter or a4 (default: letter)
  -v, --version         Show program version

Examples

Text Replacements

Anonymize or replace text in the output:

Create a replacements.json file:

{
  "oliver": "student",
  "Oliver": "Student",
  "my-email@example.com": "[redacted]"
}

Then run:

copilot-to-pdf chat.json --replacements replacements.json

Custom PDF Generation

copilot-to-pdf chat.json \
  -o "Assignment1_JohnDoe.pdf" \
  --title "CS101 Assignment 1 - John Doe" \
  --page-size a4 \
  --no-timestamps

Python API Reference

Data Extraction Functions

get_all_exchanges(json_path)

Returns list of all exchanges with user messages, assistant responses, timestamps, and model IDs.

get_exchange_by_index(json_path, idx)

Get a specific exchange by index (0-indexed).

get_user_messages(json_path)

Returns list of all user message strings.

get_assistant_responses(json_path)

Returns list of all assistant response strings.

get_chat_metadata(json_path)

Returns metadata including total exchanges, model IDs used, and timestamp range.

get_exchange_count(json_path)

Returns the number of exchanges in the chat.

Advanced Usage

from copilot_history_pdf import ChatHistoryConverter

# Create custom converter with configuration
config = {
    'replacements': {'oliver': 'student'},
    'max_response_length': 10000,
    'include_timestamps': True,
    'custom_title': 'My Custom Title'
}

converter = ChatHistoryConverter('input.json', 'output.pdf', config)
converter.convert()

Use Cases

For Students

  • Submit chat histories as part of assignment documentation
  • Create portfolios showing AI-assisted learning process
  • Archive conversations for future reference

For Instructors

  • Review student AI usage patterns
  • Grade based on question quality and engagement
  • Analyze which models students prefer and why

For Researchers

  • Study human-AI interaction patterns
  • Build datasets from chat histories
  • Analyze model performance across different tasks

File Format

The package expects JSON files in GitHub Copilot's chat history export format. The JSON should have this structure:

{
  "responderUsername": "GitHub Copilot",
  "requests": [
    {
      "message": { "text": "user question", "parts": [...] },
      "response": [...],
      "timestamp": 1234567890000,
      "modelId": "copilot/claude-sonnet-4.5"
    }
  ]
}

Requirements

  • Python 3.7 or higher
  • reportlab >= 3.6.0

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details

Support

For bug reports and feature requests, please open an issue on GitHub.

Changelog

Version 0.1.0

  • Initial release
  • Basic PDF conversion
  • CLI interface
  • Python API for data extraction
  • Model ID display per exchange
  • Text replacement support
  • Configurable styling options

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

copilot_history_pdf-0.1.0.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

copilot_history_pdf-0.1.0-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file copilot_history_pdf-0.1.0.tar.gz.

File metadata

  • Download URL: copilot_history_pdf-0.1.0.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for copilot_history_pdf-0.1.0.tar.gz
Algorithm Hash digest
SHA256 23b572a3afc3f15f32ddc231c8d5dd8f23b1282dfffe6cf241c543e6aa3a57ed
MD5 b316c01959b92a5c2d8ac43ff1825bce
BLAKE2b-256 b053a6845f17fa22ae6bf9ec6f2f10381d9dcdc8a277d8cb1cb0b426b17eb81e

See more details on using hashes here.

File details

Details for the file copilot_history_pdf-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for copilot_history_pdf-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2d7bee0c600d3fa50f9abd1868169e5763d0df744317c2c208b89cea370ba324
MD5 751763195971321e9bd816eb3561e8dc
BLAKE2b-256 96f583455808e23996aca5d92f901e29cae3dce803abf91a67cd06ac35e1f929

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page