Expand description
Canonical chat transcript codec for SIM.
This crate provides codec:chat, a provider-neutral text format for
model request, response, event, and card transcripts represented as
Expr::Map values.
Structs§
- Chat
Codec - Provider-neutral transcript codec.
- Chat
Codec Lib - Host-registered lib for
codec:chat, built on the sharedDomainCodecLibscaffold. - Ollama
Request Options - Options controlling how a chat model-request transcript is projected into an Ollama JSON request body.
Functions§
- decode_
ollama_ response - Decodes a non-streamed Ollama JSON response
bodyinto a canonical model-response transcript attributed torunnerandmodel. - decode_
ollama_ stream - Decodes a newline-delimited Ollama streaming response
bodyinto a single canonical model-response transcript attributed torunnerandmodel. - encode_
ollama_ request - Encodes a chat model-request transcript into an Ollama JSON request body.
- is_
model_ request_ expr - Returns
truewhenexpris a chat transcript map carrying a truemodel-requestmarker. - model_
card_ expr - Builds a model-card transcript map describing a model’s identity and capabilities (provider, locality, modalities, and stream/tool/JSON/shape support), with conservative defaults the caller can override.
- model_
error_ expr - Builds a model-response transcript carrying an error: a single text content
part holding
message, astop-reasonoferror, andtext/shape-okfields recording the failure. - model_
request_ messages_ expr - Returns the
messageslist of a model-request transcript, erroring ifexpris not a valid request or itsmessagesfield is not a list. - model_
response_ expr - Builds a model-response transcript map from a
runner,modelname,contentparts, andstop_reason. - number_
field - A
numbers/f64-domain map entry(name, value)for usage and metric records. - text_
part - A chat text content part: the map
{type: text, text: <text>}. - usage_
record - The canonical token-usage entries built from optional counts, in the fixed
order
input-tokens,output-tokens,total-tokens. Each present count becomes onenumber_field; absent counts are skipped. The caller decides how to wrap the result, because providers differ: some emit a usage map even when empty, others omit usage entirely when no counts are present. - validate_
chat_ transcript - Validates that
expris a well-formed chat transcript and fails closed otherwise.