Skip to main content

validate_chat_transcript

Function validate_chat_transcript 

Source
pub fn validate_chat_transcript(expr: &Expr) -> Result<()>
Expand description

Validates that expr is a well-formed chat transcript and fails closed otherwise.

A transcript must be an Expr::Map with exactly one true marker among model-request, model-response, model-event, and model-card; the matching variant’s required fields are then checked. This is the domain gate the codec runs on both decode and encode.

The validator owns a finite field set for each transcript variant and rejects duplicates in that set. Nested canonical records such as messages, content parts, tool-call arguments, usage, and provider raw projections are strict over their bare-symbol keys. Qualified symbols, non-symbol keys, and model-card advisory fields beyond runner/model/provider/locality stay open extension space.

§Examples

use sim_codec_chat::{model_response_expr, validate_chat_transcript};
use sim_kernel::Symbol;

let response = model_response_expr(
    Symbol::new("local-reasoner"),
    "qwen2.5-coder:14b",
    Vec::new(),
    Symbol::new("stop"),
);
assert!(validate_chat_transcript(&response).is_ok());