Skip to contents

Signatures

Declare a task’s inputs, typed outputs and instructions.

signature()
Define a module's inputs and outputs
input()
Describe one signature input
with_instructions() append_instructions()
Replace or extend signature instructions
with_reasoning()
Add a reasoning field to a signature
without_reasoning()
Remove the reasoning field from a signature
has_reasoning()
Test whether a signature has a reasoning field

Build a program

Turn a signature into a module. module() makes one model call; the other constructors answer the same signature in a different way.

module()
Create a prediction module
chain_of_thought()
Create a chain-of-thought module
multi_chain_comparison()
Compare several reasoning chains and synthesize an answer
react()
Create a tool-using ReAct module
rag_module()
Create a retrieval-augmented generation module
module_fn()
Wrap an R function as a module
flex() experimental
Flex: a module whose implementation can be optimized

Compose programs

Chain modules, retry them with a reward, or combine several answers.

`%>>%` pipeline()
Chain modules into a pipeline
step()
Configure one pipeline step
best_of_n()
Run a module up to N times and keep the best result
refine()
Retry a module with feedback until it scores well
as_reward_fn()
Turn a metric into a reward function
ensemble()
Combine several modules into one
reduce_majority()
Pick the most common ensemble output
reduce_weighted_vote()
Pick the ensemble output with the most total weight
reduce_first()
Pick the first successful ensemble output
reduce_best_by_metric()
Pick the ensemble output that scores best against a known answer

Programs that run code

Let a model write and run R code, and choose where that code runs.

program_of_thought()
Create a Program of Thought module that answers by running R code
code_act()
Create a CodeAct agent that calls tools and runs R code
rlm_module() experimental
Create an RLM module that explores its inputs with R code
rlm()
Run a recursive language model (RLM) in one call
r_code_runner()
Run R code in a separate process
mcp_repl_runner()
Run R code in an operating-system sandbox with mcp-repl
run_demo()
Run the interactive RLM demo

Run programs

Run a module on named inputs or on a data frame, in parallel, asynchronously or as a stream, and read what came back.

run()
Run a module on named inputs
run_dataset()
Run a module on each row of a data frame
predict(<Module>)
Predict with a module on new data
concurrency_control()
Control how batches run in parallel
run_async()
Run a module asynchronously
run_stream()
Run a module with streaming callbacks
stream_listener()
Listen to one output field while streaming
stream_async()
Stream a module's text output asynchronously
get_output() get_metadata() get_tokens() get_cost()
Extract outputs, metadata and costs from results

Validate outputs

Check outputs and retry with feedback when a check fails.

with_assertions()
Validate a module's outputs and retry on failure
assert_output() suggest_output() assertion_set()
Define output assertions
assert_length()
Assert the length of an output
assert_contains()
Assert that an output contains a string
assert_not_contains()
Assert that an output does not contain a string
assert_matches()
Assert that an output matches a regular expression
assert_not_matches()
Assert that an output does not match a regular expression
assert_one_of()
Assert that an output is one of a set of values
assert_range()
Assert that a numeric output is within a range
assert_not_empty()
Assert that an output is not empty
assert_custom()
Assert a custom condition

Evaluate

Score a program on labeled data with a metric.

evaluate()
Score a module on a dataset
metric_exact_match()
Exact-match metric
metric_f1()
Token-overlap F1 metric
metric_contains()
Metric that checks for a pattern in the output
metric_field_match()
Metric that compares several output fields
metric_custom()
Wrap a custom metric function
metric_threshold()
Turn a numeric metric into pass/fail
metric_with_feedback()
Metric that returns a score and feedback
metric_with_trace()
Metric that also sees the execution trace
metric_model_graded_qa() metric_model_graded_fact() metric_detect_match() metric_detect_includes() metric_detect_pattern()
Metrics built on vitals scorers

Optimize with compile()

Optimizers, which dsprrr calls teleprompters, tune a program’s demonstrations, instructions or decision rules against a metric. The “Choose an optimizer” article compares them.

compile()
Optimize a program with a teleprompter
LabeledFewShot()
Labeled few-shot: add training rows as demonstrations
BootstrapFewShot()
BootstrapFewShot: keep the program's own successful outputs as demos
BootstrapFewShotWithRandomSearch()
BootstrapFewShot with random search over candidate programs
KNNFewShot()
KNN few-shot: choose demonstrations by similarity at run time
COPRO()
COPRO: refine instructions by coordinate ascent
MIPROv2()
MIPROv2: search instructions and demonstrations together
GEPA()
GEPA: reflective prompt evolution
SIMBA()
SIMBA: stochastic introspective mini-batch ascent
GridSearchTeleprompter()
Grid search over instructions and demos
BetterTogether()
BetterTogether: run several optimizers in sequence
ReAnchor() experimental
ReAnchor: calibrate decision outputs against a metric
Teleprompter()
Arguments shared by all optimizers

Experimental optimizers

Compose optimizers, or let an agent run optimization experiments.

Omni()
Omni: explore with several optimizers, then continue from the best
AutoResearch()
AutoResearch: let an agent run optimization experiments
MetaHarness()
Meta-Harness: fresh proposer sessions over a candidate frontier

Inspect optimization results

See what an optimizer changed and reuse the result.

optimization_result() print(<dsprrr_optimization_result>)
Inspect what an optimizer did
optimization_summary() print(<dsprrr_optimization_summary>)
Summarize an optimization result
best_params()
Best parameters found by an optimizer
best_demos()
Demonstrations attached to a module
top_trials()
Highest-scoring optimization trials
config_diff()
Compare a module's settings with baseline values
apply_best_config()
Copy optimized settings to another module
export_module_code()
Export a program as standalone R code

Try combinations of request settings, instructions and templates.

optimize_grid()
Grid search over module settings
module_trials()
Summarize grid search trials
module_metrics()
Per-trial rows from a grid search
module_parameters()
Build a tidymodels parameter set for a module

Calibrated decisions

Experimental. Yes/no and label outputs decoded locally from probability evidence, with thresholds you can tune.

decision_bool() decision_score() decision_choice() experimental
Calibrated decision outputs
with_decisions() experimental
Attach calibrated decision outputs to a module
decision_settings() experimental
Decision settings of a module
decision_evidence() experimental
Probability evidence behind decision outputs

Models and caching

Choose the chat a call uses and control the response cache.

dsp_configure()
Configure the default chat from a provider name
get_default_chat() set_default_chat() clear_default_chat()
Get, set or clear the default chat
with_lm() local_lm()
Use a chat for a block of code
is_reasoning_model()
Test whether a model name is a reasoning model
configure_cache()
Configure the response cache
cache_stats()
Report response-cache statistics
clear_cache()
Clear the response cache
dsprrr_sitrep()
Report dsprrr's configuration

Prompts, traces and costs

Inspect what was sent to the model, what came back and what it cost.

get_last_prompt()
Show the most recent prompt and response
inspect_history()
List recent model calls
clear_prompt_history()
Clear the prompt history
export_traces()
Export a module's traces as a tibble
summarize_traces()
Summarize a module's traces
clear_traces()
Clear a module's traces
session_cost()
Summarize this session's token use and cost

Save and deploy

Save programs, pin them to a board, and start a workflow project.

program_artifact() program_artifact_id() save_program() load_program()
Save and load complete programs
pin_module_config()
Pin a program to a pins board
restore_module_config()
Rebuild a program from a saved artifact
pin_trace()
Pin a module's traces to a pins board
pin_vitals_log()
Pin evaluation results to a pins board
use_dsprrr_template()
Copy a workflow template into a project
validate_workflow()
Check a module and its data before a run

Program graphs

Inspect, freeze and transform the modules inside a program.

vitals

Evaluate modules with the vitals package.

as_vitals_solver()
Use a dsprrr module as a vitals solver
as_vitals_task()
Build a vitals Task from a module and a data set
as_vitals_samples()
Convert dsprrr traces to vitals samples
as_vitals_cost()
Report dsprrr costs in the vitals format
as_dsprrr_traces()
Convert vitals samples to dsprrr traces
summarize_traces_df()
Summarize a traces data frame
as_dsprrr_metric()
Use a vitals scorer as a dsprrr metric

Tools and retrieval

Expose modules as ellmer tools and search document stores.

as_ellmer_tool()
Turn a module into an ellmer tool
ragnar_tool()
Search a ragnar store from a tool-using module
create_search_tool()
Build a search tool from a set of documents

tidymodels

A parsnip model specification and dials parameters.

llm_predict()
LLM model specification for parsnip
register_dsprrr_engine()
Register the dsprrr engine with parsnip
temperature()
Temperature parameter for dials
top_p()
Top-p parameter for dials
reasoning_effort()
Reasoning effort parameter for dials

Build your own optimizer

Lower-level pieces the built-in optimizers are made from.

optimizer_control()
Budgets and settings for an optimizer run
eval_program()
Evaluate a program with per-example detail
sample_dataset()
Sample rows reproducibly
split_dataset()
Split data into training and validation sets
TrialLog
Record optimization trials in memory or on disk
create_trial()
Create an optimization trial record
complete_trial()
Record evaluation results on a trial
write_trials_jsonl()
Write trial records to a JSON Lines file
read_trials_jsonl()
Read trial records from a JSON Lines file
load_trial_log()
Load a saved trial log