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/
  model/
    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 model/openai/* or model/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.0.tar.gz (26.4 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.0-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for chat_history_schema-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cfbf0db01287935aff0a018589a107d6f566274fdf1e69181547fbcafc745007
MD5 7bf0f8b2a86bb2d8c24dbc1b72fd6f14
BLAKE2b-256 021d38731c79d360ad71b0487a546c933e24671550ba34d45cbd4d4b313352e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chat_history_schema-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 47d4146cad37e39d356f5be0af1d647205ea4bc3fd525cbdf52f4657f45b983c
MD5 9929732a084b69812284c2ba439c3d65
BLAKE2b-256 e1bac4ece9e27eeab23e1aaa107c88a5a7598953afeedfa4e16c381b2da2bd42

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