%c% {TheOpenAIR} | R Documentation |
Send a message to ChatGPT and assign the response to a variable
Description
This function sends a message to the ChatGPT API using the 'chat()' function and returns the response in the specified output format.
Usage
message %c% output
Arguments
message |
A character string containing the message to be sent to the ChatGPT API. |
output |
A character string specifying the output format. Valid options are "message_to_console", "message", or "response_object". Default is "message_to_console". |
Value
Depending on the value of the 'output' argument, this function returns one of the following: * "message_to_console": a message containing the response text to be printed to the console. * "message": the response text as a character vector. * "response_object": the full response object from the ChatGPT API.
Author(s)
Ulrich Matter umatter@protonmail.com
Examples
## Not run:
# Send a message and assign the response to a variable
response_var <- "Hello, ChatGPT!" %c% "message"
# Print the response
print(response_var)
# Send a message and return the full response object
response_obj <- "Hello, ChatGPT!" %c% "response_object"
# Print the response
print(response_obj)
## End(Not run)
[Package TheOpenAIR version 0.1.0 Index]