Control output streaming with echo
mainBy default, ellmer streams output to the console. To capture the response as a string instead of streaming it, set the echo argument to "none". This can be done when creating the chat object or when calling the $chat() method.
# Capture response as a string instead of streaming to console
my_function <- function() {
chat <- chat_openai("Be terse", model = "gpt-4o-mini", echo = "none")
chat$chat("What is 6 times 7?")
}
# Returns an 'ellmer_output' object containing the string
str(my_function())