Stream Event • Rust AI Agent SDK
StreamEvent: A single streaming event emitted during LLM response streaming.
StreamEvent
Defined in the streaming module.
Rust AI Agent SDK
A single streaming event emitted during LLM response streaming.
Fields
| Name | Type | Description |
|---|---|---|
event_type | StreamEventType | Event type |
timestamp | u64 | Timestamp (milliseconds since epoch) |
content | Option<String> | Text content for DeltaText events |
tool_call | Option<ToolCallData> | Tool call data for DeltaToolCall events |
metadata | HashMap<String | Additional metadata |
error | Option<String> | Error message for Error events |
is_reasoning | bool | Whether this is reasoning/thinking content |
agent_id | Option<String> | Agent ID for multi-agent scenarios |
session_id | Option<String> | Session ID for tracking |
run_id | Option<String> | Run ID for correlation |
Methods
new
fn new(event_type: StreamEventType) -> SelfCreate a new stream event
Parameters:
| Name | Type |
|---|---|
event_type | StreamEventType |
content
fn content(mut self, content: impl Into<String>) -> SelfSet content
Parameters:
| Name | Type |
|---|---|
content | impl Into<String> |
tool_call
fn tool_call(mut self, tool_call: ToolCallData) -> SelfSet tool call
Parameters:
| Name | Type |
|---|---|
tool_call | ToolCallData |
error
fn error(mut self, error: impl Into<String>) -> SelfSet error
Parameters:
| Name | Type |
|---|---|
error | impl Into<String> |
reasoning
fn reasoning(mut self, is_reasoning: bool) -> SelfSet as reasoning content
Parameters:
| Name | Type |
|---|---|
is_reasoning | bool |
agent_id
fn agent_id(mut self, id: impl Into<String>) -> SelfSet agent ID
Parameters:
| Name | Type |
|---|---|
id | impl Into<String> |
session_id
fn session_id(mut self, id: impl Into<String>) -> SelfSet session ID
Parameters:
| Name | Type |
|---|---|
id | impl Into<String> |
run_id
fn run_id(mut self, id: impl Into<String>) -> SelfSet run ID
Parameters:
| Name | Type |
|---|---|
id | impl Into<String> |
metadata
fn metadata(mut self, key: impl Into<String>, value: impl Into<String>) -> SelfAdd metadata
Parameters:
| Name | Type |
|---|---|
key | impl Into<String> |
value | impl Into<String> |
request_start
fn request_start() -> SelfCreate a request start event
first_token
fn first_token(content: impl Into<String>) -> SelfCreate a first token event
Parameters:
| Name | Type |
|---|---|
content | impl Into<String> |
delta_text
fn delta_text(content: impl Into<String>) -> SelfCreate a delta text event
Parameters:
| Name | Type |
|---|---|
content | impl Into<String> |
stream_end
fn stream_end() -> SelfCreate a stream end event
error_event
fn error_event(message: impl Into<String>) -> SelfCreate an error event
Parameters:
| Name | Type |
|---|---|
message | impl Into<String> |
Source
View on GitHubpraisonai/src/streaming/mod.rs at line 119