Skip to contents

Returns the assistant content from a single Message, from a flat list of Message objects (e.g. the output of llmapply with extract_responses = FALSE), or from a list of lists of Message objects (e.g. the output of map() on an Agent with extract_responses = FALSE).

Usage

responses(x)

Arguments

x

Message object, list of Message objects, or list of lists of Message objects. NULL elements are allowed: llmapply and agentapply leave one in the slot of every call that failed under on_error = "na".

Value

Character vector of assistant responses. Returns NA_character_ in slots where no assistant message is present (including failed calls), so that the length of the result matches the length of x. An agent history returned by generate yields only the final assistant response. Attached validation reports are preserved.

Author

EDG

Examples

# Requires running Ollama server and gemma4:e4b model
if (FALSE) { # \dontrun{
  llmapply(
    c("burgundy", "crimson", "maroon", "ruby", "scarlet"),
    "gemma4:e4b",
    system_prompt = "Return the hexadecimal code for the color provided in format #FFFFFF",
    temperature = 0.2
  ) |> responses()
} # }