Skip to main content

LLM Conversation Parser

A Python library for parsing LLM conversation JSON files into RAG-optimized format.

Documentation

Supported LLMs

  • Claude (Anthropic)
  • ChatGPT (OpenAI)
  • Grok (xAI)

Installation

pip install llm-conversation-parser

Quick Start

from llm_conversation_parser import LLMConversationParser

# Initialize parser
parser = LLMConversationParser()

# Parse single file (auto-detect LLM type)
data = parser.parse_file("claude_conversations.json")
print(f"Parsed {len(data)} conversations")

# Parse multiple files
all_data = parser.parse_multiple_files([
    "claude_conversations.json",
    "gpt_conversations.json",
    "grok_conversations.json"
])

# Save parsed data
parser.save_parsed_data_by_llm(all_data, "parsed_data")

Key Features

  • Automatic LLM Detection: Analyzes JSON structure to determine LLM type
  • Unified Output Format: Converts all LLM formats to standardized RAG-optimized structure
  • Batch Processing: Process multiple files at once
  • Error Handling: Robust error handling with detailed error messages
  • Zero Dependencies: Uses only Python standard library
  • CLI Support: Command-line interface included

Output Format

[
  {
    "id": "message_uuid",
    "content": {
      "user_query": "User's question",
      "conversation_flow": "[AI_ANSWER] Previous AI response\n[USER_QUESTION] User's question"
    },
    "metadata": {
      "previous_ai_answer": "Previous AI response or null",
      "conversation_id": "conversation_uuid"
    }
  }
]

Usage Examples

1. Automatic LLM Type Detection

from llm_conversation_parser import LLMConversationParser

parser = LLMConversationParser()

# Automatically detect LLM type based on JSON structure
claude_data = parser.parse_file("my_conversations.json")  # Auto-detected as Claude
gpt_data = parser.parse_file("chat_history.json")       # Auto-detected as ChatGPT
grok_data = parser.parse_file("ai_chat.json")          # Auto-detected as Grok

2. Explicit LLM Type Specification

# Specify LLM type explicitly
claude_data = parser.parse_file("conversations.json", "claude")
gpt_data = parser.parse_file("conversations.json", "gpt")
grok_data = parser.parse_file("conversations.json", "grok")

3. Batch Processing

# Process multiple files at once
files = [
    "claude_conversations.json",
    "gpt_conversations.json",
    "grok_conversations.json"
]

# Process all files with auto-detection
data_by_llm = parser.parse_multiple_files(files)

# Check results
for llm_type, conversations in data_by_llm.items():
    print(f"{llm_type}: {len(conversations)} conversations")

# Save by LLM type
parser.save_parsed_data_by_llm(data_by_llm, "parsed_data")

4. RAG Data Utilization

# Use parsed data for RAG systems
for conversation in data:
    message_id = conversation["id"]
    user_query = conversation["content"]["user_query"]
    conversation_flow = conversation["content"]["conversation_flow"]

    # Extract text for vectorization
    rag_text = f"{user_query}\n{conversation_flow}"

    # Store in vector database
    # vector_db.add_document(message_id, rag_text)

Command Line Interface

# Parse single file
llm-conversation-parser parse input.json

# Parse multiple files
llm-conversation-parser parse file1.json file2.json --output parsed_data/

# Auto-detect LLM type
llm-conversation-parser parse conversations.json

# Specify LLM type explicitly
llm-conversation-parser parse conversations.json --llm-type claude

License

MIT License

Changelog

See CHANGELOG.md for detailed changelog.

Metadata

Release files for llm-conversation-parser 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-conversation-parser 1.0.1
File Size Uploaded Provenance
llm_conversation_parser-1.0.1.tar.gz 21.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for llm-conversation-parser 1.0.1
File Interpreter ABI Platform
llm_conversation_parser-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 31.2 kB

Release files / llm_conversation_parser-1.0.1.tar.gz

Download URL llm_conversation_parser-1.0.1.tar.gz
Size 21.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f03dad5941413d7a0a1d351697153801c1913b2acc86cfe868e0314bca007e85
BLAKE2b-256 checksum
How to use checksums
d3cf85e150612fd68d52106ebc5b1718b5a3bb3f83fd521f362c7a42a11ca506
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / llm_conversation_parser-1.0.1-py3-none-any.whl

Download URL llm_conversation_parser-1.0.1-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
35540fa1fa0caba7efd9dd3c5f41071412a9b5c42ab558aee7136066ef04dc27
BLAKE2b-256 checksum
How to use checksums
827a7660ae616d233557139d9784309e1e50a09a8c507a6f45737ab739b8ca51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for llm-conversation-parser 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page