Learn R Programming

rtemis.llm (version 0.8.1)

responses: Extract response(s) from a Message or list of Messages

Description

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)

Value

Character vector of assistant responses. Returns NA_character_ in slots where no assistant message is present, so that the length of the result matches the length of x.

Arguments

x

Message object, list of Message objects, or list of lists of Message objects.

Author

EDG

Examples

Run this code
# Requires running Ollama server and gemma4:e4b model
if (FALSE) {
  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()
}

Run the code above in your browser using DataLab