ModelResponseStream R6 Class
ModelResponseStream R6 Class
Super classes
openaiapi::Utils
-> openaiapi::ModelResponse
-> ModelResponseStream
Methods
Inherited methods
Method new()
Initialize a ModelResponseStream
object.
Usage
ModelResponseStream$new(stream_reader = NULL, init = NULL)
Method stream()
Stream the model response.
Usage
ModelResponseStream$stream(
on_event = function(event) {
},
on_output_text = function(output_text) {
},
on_output_text_delta = function(data) {
},
env = parent.frame()
)
Arguments
on_event
Function. Callback function to handle all events. The function should accept a single argument,
event
, which is a list containing the eventtype
anddata
.on_output_text
Function. Callback function to handle event that change output text. The function should accept a single argument containing the output text string.
on_output_text_delta
Function. Callback function to handle output text delta events. The function should accept a single argument containing the delta event data.
env
Environment. The environment in which to evaluate the tool calls.
Method generator()
Get the generator function for the stream.
Usage
ModelResponseStream$generator(
on_event = function(event) {
},
on_output_text = function(output_text) {
},
on_output_text_delta = function(data) {
},
env = parent.frame()
)
Arguments
on_event
Function. Callback function to handle all events. The function should accept a single argument,
event
, which is a list containing the eventtype
anddata
.on_output_text
Function. Callback function to handle event that change output text. The function should accept a single argument containing the output text string.
on_output_text_delta
Function. Callback function to handle output text delta events. The function should accept a single argument containing the delta event data.
env
Environment. The environment in which to evaluate the tool calls.
Method async_generator()
Get the async generator function for the stream.
Usage
ModelResponseStream$async_generator(
on_event = function(event) {
},
on_output_text = function(output_text) {
},
on_output_text_delta = function(data) {
},
env = parent.frame()
)
Arguments
on_event
Function. Callback function to handle all events. The function should accept a single argument,
event
, which is a list containing the eventtype
anddata
.on_output_text
Function. Callback function to handle event that change output text. The function should accept a single argument containing the output text string.
on_output_text_delta
Function. Callback function to handle output text delta events. The function should accept a single argument containing the delta event data.
env
Environment. The environment in which to evaluate the tool calls.