1. Validate a fine-tuning dataset
medium25 XPWrite validate_jsonl(text) -> (valid_examples, errors). Each non-blank line must be JSON with a messages list; roles must be system (optional, only first), then alternating user/assistant starting with user and ending with assistant; every content a non-empty string. Duplicate examples (identical messages) after the first are errors. Errors are strings "line N: <reason>" (1-based). Reasons: invalid json, missing messages, bad roles, empty content, duplicate.
Ctrl/⌘ + Enter runs the tests · Esc then Tab leaves the editor