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.
- Generation
Options - Program
- A signature bound to a provider: an executable, typed LLM call.
- Repair
Turn - Request
- Response
- Usage
- Violation
- One way a value fails the schema.
Enums§
- Error
- Why a program run produced no typed output.
- Finish
Reason - Provider
Error - Schema
Dialect - 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 everyProvider;Box<dyn DynProvider>is itself aProvider. - 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
schemarsintodialect.
Derive Macros§
- TypedLm
- Implements
typedlm::Signaturefor an input struct.