Convenience for extracting the last model output from a Chat object.

last_output(x)
last_message(x, role = NULL)

Arguments

x

The Chat object

role

The role ("assistant", "user", "tool", "system", etc) of the message source; NULL represents any role

Value

For last_output, the converted output (not necessarily the raw response). For the lower level last_message, a ChatMessage object containing the raw and converted output, among other things.

See also

predict is a convenience wrapper that uses last_output.

Author

Michael Lawrence

Examples

if (FALSE) { # \dontrun{
    last_output(chat(llama(), "Creators of R"))
} # }