stream_chat_completion {gptstudio} | R Documentation |
Stream Chat Completion
Description
stream_chat_completion
sends the prepared chat completion request to the
OpenAI API and retrieves the streamed response.
Usage
stream_chat_completion(
messages = NULL,
element_callback = cat,
model = "gpt-3.5-turbo",
openai_api_key = Sys.getenv("OPENAI_API_KEY")
)
Arguments
messages |
A list of messages in the conversation, including the current user prompt (optional). |
element_callback |
A callback function to handle each element of the streamed response (optional). |
model |
A character string specifying the model to use for chat completion. The default model is "gpt-3.5-turbo". |
openai_api_key |
A character string of the OpenAI API key. By default, it is fetched from the "OPENAI_API_KEY" environment variable. Please note that the OpenAI API key is sensitive information and should be treated accordingly. |
Value
The same as curl::curl_fetch_stream
[Package gptstudio version 0.4.0 Index]