33 lines
1001 B
Markdown
33 lines
1001 B
Markdown
# Package: dirigent_chatgpt
|
|
|
|
Pure-Rust parser for OpenAI's ChatGPT `conversations.json` data export.
|
|
|
|
## Scope
|
|
|
|
- `parse_export(path)` — reads a `conversations.json` file on disk and
|
|
returns `Vec<ParsedConversation>`.
|
|
- `parse_str(json)` — parses an in-memory JSON string (useful for tests
|
|
and piped inputs).
|
|
- Types: `ParsedConversation`, `ParsedMessage`, `ContentPart` (`Text`,
|
|
`Code`, `Tool`).
|
|
|
|
No dirigent-specific types. `dirigent_archivist::import::sources::chatgpt`
|
|
consumes this crate and maps into the archivist's internal types.
|
|
|
|
## Example
|
|
|
|
```rust
|
|
let convs = dirigent_chatgpt::parse_export(path)?;
|
|
for c in convs {
|
|
println!("{}: {} messages", c.title.as_deref().unwrap_or("(untitled)"), c.messages.len());
|
|
}
|
|
```
|
|
|
|
## Failure modes
|
|
|
|
- Truly broken JSON → `ParseError::Json`.
|
|
- Malformed individual messages are skipped where possible.
|
|
- Unknown content shapes are preserved as best-effort text in
|
|
`ContentPart::Text { text: raw_json }` so no user data is silently
|
|
lost.
|