Skip to contents

Map

Usage

map(x, f, ...)

Arguments

x

A character vector or list to map over.

f

An LLM or Agent object.

...

Additional arguments passed to generate(), plus the two arguments the methods accept: verbosity and on_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:

  • verbosity Integer [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 - and verbosity = 0L silences it. The per-call verbosity is verbosity - 1L. When a message sink is set (see rtemis.core::set_msg_sink()), progress is forwarded as structured events instead of being drawn, and nests under any enclosing progress node.

  • on_error Character {"na", "abort"}: What to do when a single call fails. "na" (the default) warns, leaves NULL in that element's slot, and carries on; the result then carries an errors attribute, a data.frame of index and message with one row per failed call. responses and reasoning map those NULL slots to NA_character_. "abort" propagates the error and discards every result in the batch.

Author

EDG

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
} # }