sync from monorepo @ 2452e92e
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
# 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.
|
||||
Reference in New Issue
Block a user