pub struct EventData {
pub input: Option<Value>,
pub error: Option<String>,
pub output: Option<Value>,
pub chunk: Option<Value>,
}Expand description
Data associated with a streaming event.
This struct contains optional fields that may be present depending on the event type (start, stream, end).
Fields§
§input: Option<Value>The input passed to the Runnable that generated the event.
Inputs will sometimes be available at the START of the Runnable, and
sometimes at the END of the Runnable.
If a Runnable is able to stream its inputs, then its input by definition
won’t be known until the END of the Runnable when it has finished streaming
its inputs.
error: Option<String>The error that occurred during the execution of the Runnable.
This field is only available if the Runnable raised an exception.
output: Option<Value>The output of the Runnable that generated the event.
Outputs will only be available at the END of the Runnable.
For most Runnable objects, this field can be inferred from the chunk field,
though there might be some exceptions for special a cased Runnable (e.g., like
chat models), which may return more information.
chunk: Option<Value>A streaming chunk from the output that generated the event.
Chunks support addition in general, and adding them up should result
in the output of the Runnable that generated the event.
Implementations§
Source§impl EventData
impl EventData
Sourcepub fn with_input(self, input: Value) -> Self
pub fn with_input(self, input: Value) -> Self
Create EventData with an input value.
Sourcepub fn with_error(self, error: impl Into<String>) -> Self
pub fn with_error(self, error: impl Into<String>) -> Self
Create EventData with an error.
Sourcepub fn with_output(self, output: Value) -> Self
pub fn with_output(self, output: Value) -> Self
Create EventData with an output value.
Sourcepub fn with_chunk(self, chunk: Value) -> Self
pub fn with_chunk(self, chunk: Value) -> Self
Create EventData with a chunk value.