pub struct BaseStreamEvent {
pub event: String,
pub run_id: String,
pub tags: Vec<String>,
pub metadata: HashMap<String, Value>,
pub parent_ids: Vec<String>,
}Expand description
Base streaming event.
Schema of a streaming event which is produced from the astream_events method.
Event names are of the format: on_[runnable_type]_(start|stream|end).
Runnable types are one of:
- llm - used by non chat models
- chat_model - used by chat models
- prompt - e.g.,
ChatPromptTemplate - tool - from tools defined via
@tooldecorator or inheriting fromTool/BaseTool - chain - most
Runnableobjects are of this type
Further, the events are categorized as one of:
- start - when the
Runnablestarts - stream - when the
Runnableis streaming - end - when the
Runnableends
Fields§
§event: StringEvent names are of the format: on_[runnable_type]_(start|stream|end).
run_id: StringA randomly generated ID to keep track of the execution of the given Runnable.
Each child Runnable that gets invoked as part of the execution of a parent
Runnable is assigned its own unique ID.
Tags associated with the Runnable that generated this event.
Tags are always inherited from parent Runnable objects.
Tags can either be bound to a Runnable using .with_config({"tags": ["hello"]})
or passed at run time using .astream_events(..., {"tags": ["hello"]}).
metadata: HashMap<String, Value>Metadata associated with the Runnable that generated this event.
Metadata can either be bound to a Runnable using
.with_config({"metadata": { "foo": "bar" }})
or passed at run time using
.astream_events(..., {"metadata": {"foo": "bar"}}).
parent_ids: Vec<String>A list of the parent IDs associated with this event.
Root Events will have an empty list.
For example, if a Runnable A calls Runnable B, then the event generated by
Runnable B will have Runnable A’s ID in the parent_ids field.
The order of the parent IDs is from the root parent to the immediate parent.
Only supported as of v2 of the astream events API. v1 will return an empty list.
Implementations§
Source§impl BaseStreamEvent
impl BaseStreamEvent
Sourcepub fn new(event: impl Into<String>, run_id: impl Into<String>) -> Self
pub fn new(event: impl Into<String>, run_id: impl Into<String>) -> Self
Create a new BaseStreamEvent.
Set the tags for this event.
Sourcepub fn with_metadata(self, metadata: HashMap<String, Value>) -> Self
pub fn with_metadata(self, metadata: HashMap<String, Value>) -> Self
Set the metadata for this event.
Sourcepub fn with_parent_ids(self, parent_ids: Vec<String>) -> Self
pub fn with_parent_ids(self, parent_ids: Vec<String>) -> Self
Set the parent IDs for this event.
Trait Implementations§
Source§impl Clone for BaseStreamEvent
impl Clone for BaseStreamEvent
Source§fn clone(&self) -> BaseStreamEvent
fn clone(&self) -> BaseStreamEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more