Skip to main content

Crate typedlm

Crate typedlm 

Source
Expand description

Typed, testable LLM programs for Rust.

A Signature is the typed contract of one LLM call: the implementing type is the input, Signature::Output is an ordinary Rust type the model’s answer is validated against. A Provider executes requests against a model.

Re-exports§

pub use compiled::CompileError;
pub use compiled::CompiledProgram;

Modules§

compiled
Compiled programs: a program’s configuration as a reviewable JSON artefact.
eval
Measuring a program on a labelled dataset (feature eval).
http
Provider for OpenAI-compatible chat completion APIs (feature http).
optimize
Choosing worked examples automatically (feature optimize).
prelude
testing
Providers for tests that run without a model: fixed answers, closures, answers generated from the schema, and recording real interactions to replay them offline.
tools
Typed tools: the model chooses one action, Rust checks and executes it.

Structs§

Capabilities
What a provider supports for getting structured output.
Demonstration
A worked example: an input and the output the model should give for it.
Execution
A successful run with what it cost.
Failed
A failed run with what it cost — model calls are paid for even when they fail.
GenerationOptions
Program
A signature bound to a provider: an executable, typed LLM call.
RepairTurn
Request
Response
Usage
Violation
One way a value fails the schema.

Enums§

Error
Why a program run produced no typed output.
FinishReason
ProviderError
SchemaDialect
JSON Schema flavour accepted by a provider.
Strategy
How structured output is obtained, strongest first.

Traits§

DynProvider
Object-safe counterpart of Provider, for holding different providers in one collection (e.g. comparing models). Implemented for every Provider; Box<dyn DynProvider> is itself a Provider.
Provider
Executes requests against a language model.
Signature
The typed contract of one LLM call.

Functions§

output_schema
JSON Schema of a signature’s output, as generated by schemars.
parse_output
Runs the validation pipeline on one response: finish reason → JSON extraction → schema validation → deserialization → Signature::validate.
schema_for_dialect
Converts a schema generated by schemars into dialect.

Derive Macros§

TypedLm
Implements typedlm::Signature for an input struct.