Stream chunks
Stream chunk primitives for unified streaming data handling.
This module provides a unified StreamChunk class that can encapsulate different types of streaming data (Messages, EventModels, etc.) in a type-safe manner. This enables clean separation between conversation content and execution state while providing a consistent interface for streaming consumers.
Classes:
| Name | Description |
|---|---|
StreamChunk |
Unified wrapper for streaming data with type discrimination. |
Classes¶
StreamChunk
¶
Bases: BaseModel
Unified wrapper for different types of streaming data.
This class provides a single interface for handling various streaming chunk types (messages, events, state updates, errors) with type-safe discrimination.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
The type of streaming chunk. |
|
data |
dict | None
|
The actual chunk data (Message, EventModel, dict, etc.). |
metadata |
dict | None
|
Optional additional metadata for the chunk. |
Classes:
| Name | Description |
|---|---|
Config |
Pydantic configuration for EventModel. |
Source code in agentflow/state/stream_chunks.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
Attributes¶
timestamp
class-attribute
instance-attribute
¶
timestamp = Field(default_factory=timestamp, description='UNIX timestamp of when chunk was created')
Classes¶
Config
¶
Pydantic configuration for EventModel.
Attributes:
| Name | Type | Description |
|---|---|---|
use_enum_values |
Output enums as strings. |
Source code in agentflow/state/stream_chunks.py
59 60 61 62 63 64 65 66 | |