Skip to main content

Provider-organized schema + ingestion/cleanup pipeline for AI chat exports

Project description

Chat History Schema

Provider-organized schema + ingestion/cleanup pipeline for chat history exports.

Purpose

This repo is for cleaning up raw chat data exports.
The final merged output can be used for downstream data analysis and visualizations across your past ChatGPT and Claude conversations.

Structure

chat-history-schema/
  chat_history_schema/
    openai/
    anthropic/
  scripts/
    combine_conversations.py
    parse_validate_clean.py
    merge_provider_histories.py
    run_pipeline.py
  data/
    raw/{openai,anthropic}/
    combined/{openai,anthropic}/
    merged/

Workflow

  1. Drop raw exports into:
    • data/raw/openai/
    • data/raw/anthropic/
  2. Combine raw files by provider:
    • All providers: python scripts/combine_conversations.py --provider all
    • One provider only:
      • OpenAI: python scripts/combine_conversations.py --provider openai
      • Anthropic: python scripts/combine_conversations.py --provider anthropic
  3. Validate by provider:
    • All providers: python scripts/parse_validate_clean.py --provider all
    • One provider only:
      • OpenAI: python scripts/parse_validate_clean.py --provider openai
      • Anthropic: python scripts/parse_validate_clean.py --provider anthropic
  4. Merge provider histories with a provider field (this command validates before writing output):
    • All providers: python scripts/merge_provider_histories.py --provider all
    • One provider only:
      • OpenAI: python scripts/merge_provider_histories.py --provider openai
      • Anthropic: python scripts/merge_provider_histories.py --provider anthropic

One-command end-to-end run

Run combine + validate + merge in one command:

  • All providers:
    • python scripts/run_pipeline.py --provider all
  • One provider only:
    • python scripts/run_pipeline.py --provider openai
    • python scripts/run_pipeline.py --provider anthropic

Script outputs

  • scripts/combine_conversations.py
    • Writes:
      • data/combined/openai/conversations.json (when provider includes openai)
      • data/combined/anthropic/conversations.json (when provider includes anthropic)
  • scripts/parse_validate_clean.py
    • Writes: no files
    • Prints terminal validation results only
  • scripts/merge_provider_histories.py
    • Writes:
      • If you do nothing: data/merged/all-conversations-clean.pkl
      • If you want a different file: pass --output-pkl <your/path.pkl>
    • Main argument:
      • --provider all|openai|anthropic
  • scripts/run_pipeline.py
    • Writes:
      • Combined JSON files under data/combined/<provider>/conversations.json
      • Final merged pickle:
        • If you do nothing: data/merged/all-conversations-clean.pkl
        • If you want a different file: pass --output-pkl <your/path.pkl>

Validation behavior (make it your own)

This schema is intentionally strict and not meant to be a final bulletproof version for every export.
It is designed to surface structure differences early, so you can evolve it to match your own history.

  • Models use strict validation (extra='forbid') so unknown fields fail fast instead of being silently ignored.
  • You may see validation errors because chat histories differ by provider, account features, tool usage, and export date.
  • Treat validation as an iterative loop:
    1. Run validation.
    2. Read terminal errors.
    3. Update chat_history_schema/openai/* or chat_history_schema/anthropic/* to support the new shape.
    4. Rerun until validation passes.

If you want this repo to fit your data long-term, keep extending the provider schemas as your exports evolve.

Inspiration

This repo was inspired by the original ChatGPT schema project:
https://github.com/ryayoung/chatgpt-schema

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

chat_history_schema-0.1.1.tar.gz (26.5 kB view details)

Uploaded Source

Built Distribution

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

chat_history_schema-0.1.1-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file chat_history_schema-0.1.1.tar.gz.

File metadata

  • Download URL: chat_history_schema-0.1.1.tar.gz
  • Upload date:
  • Size: 26.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.8

File hashes

Hashes for chat_history_schema-0.1.1.tar.gz
Algorithm Hash digest
SHA256 885d1fdd6a5b8ec7d10b8aed01d33e6538f1dfa885b12cb917ac6dcc240d9a3b
MD5 cd88fbf590291819bee134d983cf63e2
BLAKE2b-256 4ba66351a9107b8365d1a2770f56f9ef0c40332cd03d19d2b1a91c958044a26e

See more details on using hashes here.

File details

Details for the file chat_history_schema-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for chat_history_schema-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d6ba2cf5b6edc57ccab61953ccff8ae84e41348043385566894d8aae688506a5
MD5 0b176900eb98c10a30f877f0e636bf74
BLAKE2b-256 dd95656a6133529eaac74d617f10b4992f3f28eb547159943b72fcb088ad7184

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