Map
Arguments
- x
A character vector or list to map over.
- f
An
LLMorAgentobject.- ...
Additional arguments passed to
generate(), plus the two arguments the methods accept:verbosityandon_error. See Details.
Value
A list of Message objects (for LLM) or list of lists of Message objects
(for Agent). With an output schema, validation_results retrieves an aligned
report. Validation happens per item; on_validation_failure = "warn" emits
one summary message at completion, respecting verbosity. Validation options
are forwarded to generate.
Details
Use responses to retrieve just the content from the assistant messages, or reasoning to retrieve the reasoning traces (if enabled).
Both methods accept:
verbosityInteger [0, Inf): Verbosity level. Progress is reported through rtemis.core's nested progress API - one status line labelled with the model name, ticking once per element, with an ETA - andverbosity = 0Lsilences it. The per-call verbosity isverbosity - 1L. When a message sink is set (seertemis.core::set_msg_sink()), progress is forwarded as structured events instead of being drawn, and nests under any enclosing progress node.on_errorCharacter {"na", "abort"}: What to do when a single call fails."na"(the default) warns, leavesNULLin that element's slot, and carries on; the result then carries anerrorsattribute, a data.frame ofindexandmessagewith one row per failed call. responses and reasoning map thoseNULLslots toNA_character_."abort"propagates the error and discards every result in the batch.
Examples
# Requires running Ollama server and gemma4:e4b model
if (FALSE) { # \dontrun{
llm <- create_Ollama(
"gemma4:e4b",
system_prompt = "Convert color to hex code using the format #FFFFFF"
)
x <- c("ocean teal", "california poppy orange", "bougainvillea pink")
hex <- map(x, llm)
hex
} # }