Skip to main content

Crate sim_codec_chat

Crate sim_codec_chat 

Source
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§

ChatCodec
Provider-neutral transcript codec.
ChatCodecLib
Host-registered lib for codec:chat, built on the shared DomainCodecLib scaffold.
OllamaRequestOptions
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 body into a canonical model-response transcript attributed to runner and model.
decode_ollama_stream
Decodes a newline-delimited Ollama streaming response body into a single canonical model-response transcript attributed to runner and model.
encode_ollama_request
Encodes a chat model-request transcript into an Ollama JSON request body.
is_model_request_expr
Returns true when expr is a chat transcript map carrying a true model-request marker.
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, a stop-reason of error, and text/shape-ok fields recording the failure.
model_request_messages_expr
Returns the messages list of a model-request transcript, erroring if expr is not a valid request or its messages field is not a list.
model_response_expr
Builds a model-response transcript map from a runner, model name, content parts, and stop_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 one number_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 expr is a well-formed chat transcript and fails closed otherwise.