Regenerate the last response in an ongoing chat
regenerate.Rd
This function removes the last response in a chatlog, generates a new response based on the updated chatlog, and updates the chatlog accordingly. The output can be displayed as a message in the console, returned as a message, or returned as a response object.
Arguments
- chatlog_id
A character string specifying the ID of the chatlog (default: '.__CURRENTCHAT__')
- output
A character string specifying the output format. Options are 'message_to_console', 'message', or 'response_object' (default: 'message_to_console')
- ...
Additional arguments to pass to the chat_completion() function.
Value
If output is 'message_to_console', the function returns NULL andprints the message to the console. If output is 'message', the function returns a character string containing the message. If output is 'response_object', the function returns the full response object.
Examples
if (FALSE) {
# Start a new chat and save the chatlog ID
chatlog_id <- chat("Hello, how are you?")
# Regenerate the last response in the chat and display it in the console
regenerate(chatlog_id)
# Regenerate the last response in the chat and return it as a message
message <- regenerate(chatlog_id, output = "message")
print(message)
# Regenerate the last response in the chat and return it as a response object
response_object <- regenerate(chatlog_id, output = "response_object")
print(response_object)
}