# DSRs ## Docs - [DSRs](https://dsrs.herumbshandilya.com/index.md): Typed LM programming in Rust: declare contracts instead of writing prompts, hold your pipeline as data, and improve it with optimizers - [Quickstart](https://dsrs.herumbshandilya.com/docs/getting-started/quickstart.md): Build your first LM pipeline in minutes - [How DSRs thinks](https://dsrs.herumbshandilya.com/docs/getting-started/how-dsrs-thinks.md): The mental model behind the library: typed contracts, programs as data, and the three authoring lanes - [Examples](https://dsrs.herumbshandilya.com/docs/guides/examples.md): Runnable examples in the repository, from a first typed call to full optimizer runs - [Signatures](https://dsrs.herumbshandilya.com/docs/components/signatures.md): Declare an LM interaction as a typed Rust struct: inputs, outputs, instruction, and constraints - [Predict](https://dsrs.herumbshandilya.com/docs/components/predict.md): Predict, Predicted, CallMetadata, PredictError, and ToolSet: the leaf module that formats a signature into a prompt, calls the LM, and parses the typed output - [Modules](https://dsrs.herumbshandilya.com/docs/components/modules.md): The Module trait, batch execution, predictor discovery via Predictors, ChainOfThought, and signature augmentation - [Adapters](https://dsrs.herumbshandilya.com/docs/components/adapters.md): Turn signatures into prompts and parse LM responses - [LM](https://dsrs.herumbshandilya.com/docs/components/lm.md): The provider client: model selection, sampling parameters, retries, response caching, and multi-provider support - [Data](https://dsrs.herumbshandilya.com/docs/components/data.md): Trainset rows as plain structs: #[derive(Example)], ToInput/ToOutput, DataLoader, TypedLoadOptions, RowRecord, and DataLoadError - [Functional DSRs (fx)](https://dsrs.herumbshandilya.com/docs/components/fx.md): Author harnesses as plain async functions with named predict call sites and injected Params - [The Module Macro](https://dsrs.herumbshandilya.com/docs/components/module-macro.md): Author LM calls as bodyless functions and whole pipelines as function bodies: #[predict], #[cot], and #[module] - [Holes](https://dsrs.herumbshandilya.com/docs/components/holes.md): Plain Rust inside a module, kept in the program graph as a named, typed black box - [Capabilities](https://dsrs.herumbshandilya.com/docs/components/capabilities.md): Named permissions: programs declare a ceiling, tools and holes declare needs, hosts grant, and load checks the subset - [Program and nodes](https://dsrs.herumbshandilya.com/docs/components/program-and-nodes.md): Reference for the IR Program, the nine node kinds, tunable parameters, the Overlay API, and baking a candidate - [The edit calculus](https://dsrs.herumbshandilya.com/docs/components/edit-calculus.md): Structural program mutation: the Edit enum, Program::edited, legal_edits, and carrying overlays across an edit with migrate_overlay - [The .dsrs file](https://dsrs.herumbshandilya.com/docs/components/dsrs-file.md): Reference for the .dsrs program text format: declarations, node forms, ports, and the hard rules - [Runtime](https://dsrs.herumbshandilya.com/docs/components/runtime.md): Reference for RuntimeEnv, Interpreter load and run, Budget, ambient overlays, and embedding programs with include_program! - [CLI](https://dsrs.herumbshandilya.com/docs/components/cli.md): Reference for the dsrs binary: check, fmt, the HTTP serving host, and the full print-and-serve workflow - [State](https://dsrs.herumbshandilya.com/docs/components/state.md): Save and restore optimized module state with ModuleState and PredictState - [Tools and Agents](https://dsrs.herumbshandilya.com/docs/components/tools-and-agents.md): Host and sandboxed tools, the #[agent] loop and its options, stop tools, and standalone versus in-module execution - [Code Mode](https://dsrs.herumbshandilya.com/docs/components/code-mode.md): Reference for the run_js meta-tool, the QuickJS sandbox, ToolSource, Capability, and every ExecError and RegisterError variant - [Traces](https://dsrs.herumbshandilya.com/docs/components/traces.md): Capture a run as a trace and replay it strictly or until divergence - [Evaluation](https://dsrs.herumbshandilya.com/docs/components/evaluation.md): TypedMetric, Eval, and the trainset evaluation loop - [Optimizers](https://dsrs.herumbshandilya.com/docs/components/optimizers.md): The Optimizer trait, every optimizer configuration, and every report type: COPRO, MIPROv2, GEPA, SIMBA, and BootstrapFewShot - [COPRO](https://dsrs.herumbshandilya.com/docs/optimizers/copro.md): Iterative instruction refinement: config, usage, and when to use it - [MIPROv2](https://dsrs.herumbshandilya.com/docs/optimizers/miprov2.md): Trace-guided instruction and demo optimization: config, usage, and when to use it - [GEPA](https://dsrs.herumbshandilya.com/docs/optimizers/gepa.md): Reflective instruction evolution from textual feedback: config, usage, and when to use it - [Structural](https://dsrs.herumbshandilya.com/docs/optimizers/structural.md): LM-guided graph edits over the edit calculus: config, usage, and when to use it - [Optimizer Engine](https://dsrs.herumbshandilya.com/docs/components/optimizer-engine.md): Engine, OptimizeTarget, Candidate, Budget, RolloutCache, ScoreMatrix, and the Pareto and outcome types every optimizer shares - [Utilities](https://dsrs.herumbshandilya.com/docs/components/utils.md): Response caching, telemetry initialization, and stable hashing - [API Reference](https://dsrs.herumbshandilya.com/docs/api/index.md): Auto-generated index of every public item in the DSRs crates, linked to full rustdoc - [dspy_rs (crate root)](https://dsrs.herumbshandilya.com/docs/api/dspy-rs.md): Everything importable directly from dspy_rs - [dspy_rs::adapter](https://dsrs.herumbshandilya.com/docs/api/adapter.md): Prompt formatting and LM response parsing. - [dspy_rs::augmentation](https://dsrs.herumbshandilya.com/docs/api/augmentation.md): Public API of the augmentation module - [dspy_rs::core](https://dsrs.herumbshandilya.com/docs/api/core.md): The foundational abstractions everything else is built on. - [dspy_rs::data](https://dsrs.herumbshandilya.com/docs/api/data.md): Data loading. - [dspy_rs::evaluate](https://dsrs.herumbshandilya.com/docs/api/evaluate.md): Evaluation and metrics for measuring module performance. - [dspy_rs::fx](https://dsrs.herumbshandilya.com/docs/api/fx.md): Functional DSRs (experimental): harnesses as plain async functions. - [dspy_rs::ir](https://dsrs.herumbshandilya.com/docs/api/ir.md): The intermediate representation (RFC 0002). - [dspy_rs::modules](https://dsrs.herumbshandilya.com/docs/api/modules.md): Public API of the modules module - [dspy_rs::optimizer](https://dsrs.herumbshandilya.com/docs/api/optimizer.md): Automatic prompt optimization. - [dspy_rs::predictors](https://dsrs.herumbshandilya.com/docs/api/predictors.md): Public API of the predictors module - [dspy_rs::prelude](https://dsrs.herumbshandilya.com/docs/api/prelude.md): The curated core surface — the recommended import for DSRs programs. - [dspy_rs::trace](https://dsrs.herumbshandilya.com/docs/api/trace.md): Execution trace capture (RFC 0001). - [dspy_rs::typesys](https://dsrs.herumbshandilya.com/docs/api/typesys.md): In-house type system that replaces the vendored BAML stack (`bamltype`, `baml_types`, `internal_baml_jinja`, `jsonish`). - [dspy_rs::utils](https://dsrs.herumbshandilya.com/docs/api/utils.md): LM response caching. - [dsrs_tools](https://dsrs.herumbshandilya.com/docs/api/dsrs-tools.md): # dsrs-tools: sandboxed tool execution for DSRs - [dsrs_syntax](https://dsrs.herumbshandilya.com/docs/api/dsrs-syntax.md): Shared syntax layer for the `.dsrs` text format (RFC 0002 §4). This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.