Skip to main content

StreamEvent

Defined in the streaming module.
Rust AI Agent SDK A single streaming event emitted during LLM response streaming.

Fields

NameTypeDescription
event_typeStreamEventTypeEvent type
timestampu64Timestamp (milliseconds since epoch)
contentOption<String>Text content for DeltaText events
tool_callOption<ToolCallData>Tool call data for DeltaToolCall events
metadataHashMap<StringAdditional metadata
errorOption<String>Error message for Error events
is_reasoningboolWhether this is reasoning/thinking content
agent_idOption<String>Agent ID for multi-agent scenarios
session_idOption<String>Session ID for tracking
run_idOption<String>Run ID for correlation

Methods

new

fn new(event_type: StreamEventType) -> Self
Create a new stream event Parameters:
NameType
event_typeStreamEventType

content

fn content(mut self, content: impl Into<String>) -> Self
Set content Parameters:
NameType
contentimpl Into&lt;String&gt;

tool_call

fn tool_call(mut self, tool_call: ToolCallData) -> Self
Set tool call Parameters:
NameType
tool_callToolCallData

error

fn error(mut self, error: impl Into<String>) -> Self
Set error Parameters:
NameType
errorimpl Into&lt;String&gt;

reasoning

fn reasoning(mut self, is_reasoning: bool) -> Self
Set as reasoning content Parameters:
NameType
is_reasoningbool

agent_id

fn agent_id(mut self, id: impl Into<String>) -> Self
Set agent ID Parameters:
NameType
idimpl Into&lt;String&gt;

session_id

fn session_id(mut self, id: impl Into<String>) -> Self
Set session ID Parameters:
NameType
idimpl Into&lt;String&gt;

run_id

fn run_id(mut self, id: impl Into<String>) -> Self
Set run ID Parameters:
NameType
idimpl Into&lt;String&gt;

metadata

fn metadata(mut self, key: impl Into<String>, value: impl Into<String>) -> Self
Add metadata Parameters:
NameType
keyimpl Into&lt;String&gt;
valueimpl Into&lt;String&gt;

request_start

fn request_start() -> Self
Create a request start event

first_token

fn first_token(content: impl Into<String>) -> Self
Create a first token event Parameters:
NameType
contentimpl Into&lt;String&gt;

delta_text

fn delta_text(content: impl Into<String>) -> Self
Create a delta text event Parameters:
NameType
contentimpl Into&lt;String&gt;

stream_end

fn stream_end() -> Self
Create a stream end event

error_event

fn error_event(message: impl Into<String>) -> Self
Create an error event Parameters:
NameType
messageimpl Into&lt;String&gt;

Source

View on GitHub

praisonai/src/streaming/mod.rs at line 119