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.
Re-exports§
pub use providers::anthropic::AnthropicCodec;pub use providers::anthropic::AnthropicCodecLib;pub use providers::anthropic::AnthropicCodecOptions;pub use providers::anthropic::AnthropicRequestOptions;pub use providers::anthropic::anthropic_codec_symbol;pub use providers::anthropic::decode_anthropic_request;pub use providers::anthropic::decode_anthropic_response;pub use providers::anthropic::decode_anthropic_stream;pub use providers::anthropic::decode_anthropic_stream_events;pub use providers::anthropic::encode_anthropic_request;pub use providers::anthropic::encode_anthropic_response;pub use providers::lemonade::LemonadeCodec;pub use providers::lemonade::LemonadeCodecLib;pub use providers::lemonade::LemonadeCodecOptions;pub use providers::lemonade::LemonadeRequestOptions;pub use providers::lemonade::decode_lemonade_request;pub use providers::lemonade::decode_lemonade_response;pub use providers::lemonade::decode_lemonade_stream;pub use providers::lemonade::encode_lemonade_request;pub use providers::lemonade::encode_lemonade_response;pub use providers::lemonade::lemonade_codec_symbol;pub use providers::lm_studio::LmStudioCodec;pub use providers::lm_studio::LmStudioCodecLib;pub use providers::lm_studio::LmStudioCodecOptions;pub use providers::lm_studio::LmStudioRequestOptions;pub use providers::lm_studio::decode_lm_studio_request;pub use providers::lm_studio::decode_lm_studio_response;pub use providers::lm_studio::decode_lm_studio_stream;pub use providers::lm_studio::encode_lm_studio_request;pub use providers::lm_studio::encode_lm_studio_response;pub use providers::lm_studio::lm_studio_codec_symbol;pub use providers::openai::OpenAiCodec;pub use providers::openai::OpenAiCodecLib;pub use providers::openai::OpenAiCodecOptions;pub use providers::openai::OpenAiRequestOptions;pub use providers::openai::decode_openai_request;pub use providers::openai::decode_openai_response;pub use providers::openai::decode_openai_stream;pub use providers::openai::encode_openai_request;pub use providers::openai::encode_openai_response;pub use providers::openai::openai_codec_symbol;pub use providers::profile::CodecProfile;pub use providers::profile::RequestWire;pub use providers::profile::StreamWire;pub use providers::profile::anthropic_profile;pub use providers::profile::lemonade_profile;pub use providers::profile::lm_studio_profile;pub use providers::profile::ollama_profile;pub use providers::profile::openai_profile;
Modules§
- providers
- Provider-specific chat wire codecs built on the canonical transcript shape.
Structs§
- Chat
Codec - Provider-neutral transcript codec.
- Chat
Codec Lib - Host-registered lib for
codec:chat, built on the sharedDomainCodecLibscaffold. - Ollama
Codec - Runtime codec for Ollama chat JSON and NDJSON response bodies.
- Ollama
Codec Lib - Host-registered lib for
codec:ollama. - Ollama
Request Options - Options controlling how a chat model-request transcript is projected into an Ollama JSON request body.
Statics§
- RECIPES
- Cookbook recipes for this codec, embedded at build time.
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.