Create a standard structured-prediction module. This is the primary
constructor in the dsprrr journey:
signature() -> module() -> run() -> evaluate() -> compile().
Agentic, reasoning, and code-executing programs use explicit constructors
such as react(), chain_of_thought(), multi_chain_comparison(),
program_of_thought(), code_act(), rlm_module(), and flex(). Keeping
those choices in the function name prevents configuration from silently
changing the kind of program being built.
Arguments
- signature
A Signature object defining the module interface.
- chat
Optional ellmer Chat object. When supplied,
run()uses it unless an explicit.llmis provided.- template
Optional glue template for prompt generation.
- demos
Optional list of demonstration examples.
- config
Optional prediction configuration. Model parameters such as temperature belong here, for example
config = list(temperature = 0.2).- ...
Must be empty. Use a dedicated constructor for advanced module behavior.
Value
A PredictModule executed with run().
Examples
classifier <- signature("text -> sentiment") |>
module(template = "Analyze: {text}")
configured <- signature("question -> answer") |>
module(config = list(temperature = 0.2))
if (FALSE) { # \dontrun{
llm <- ellmer::chat_openai()
result <- classifier |>
run(text = "Great package!", .llm = llm)
} # }