You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: flo_ai/flo_ai/arium/README.md
+148-3Lines changed: 148 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,9 +25,154 @@ result = await (AriumBuilder()
25
25
-**Easy Connections**: Simple `connect()` method for linear workflows
26
26
-**Flexible Routing**: Full support for custom router functions
27
27
-**🧠 LLM-Powered Routing**: Intelligent routing using Large Language Models
28
+
-**📊 Event Monitoring**: Real-time workflow execution monitoring with customizable callbacks
28
29
-**Visualization**: Built-in graph visualization support
29
30
-**Reusable Workflows**: Build once, run multiple times
30
31
32
+
## 📊 Event Monitoring
33
+
34
+
Arium provides comprehensive event monitoring capabilities that allow you to track workflow execution in real-time. This is invaluable for debugging, performance monitoring, and understanding how your workflows behave.
35
+
36
+
### Key Features
37
+
38
+
-**Real-time Events**: Monitor workflow lifecycle, node execution, and routing decisions
39
+
-**Custom Callbacks**: Write your own event handlers for logging, metrics, or debugging
40
+
-**Event Filtering**: Choose which types of events to monitor
41
+
-**Zero Configuration**: Works out of the box with sensible defaults
42
+
-**Performance Tracking**: Automatic execution time measurement for nodes
43
+
44
+
### Available Event Types
45
+
46
+
| Event Type | Description |
47
+
|------------|-------------|
48
+
|`WORKFLOW_STARTED`| Fired when workflow execution begins |
49
+
|`WORKFLOW_COMPLETED`| Fired when workflow completes successfully |
50
+
|`WORKFLOW_FAILED`| Fired when workflow fails with an error |
51
+
|`NODE_STARTED`| Fired when a node (agent/tool) begins execution |
52
+
|`NODE_COMPLETED`| Fired when a node completes successfully |
53
+
|`NODE_FAILED`| Fired when a node fails with an error |
54
+
|`ROUTER_DECISION`| Fired when a router chooses the next node |
55
+
|`EDGE_TRAVERSED`| Fired when moving from one node to another |
56
+
57
+
### Basic Usage
58
+
59
+
```python
60
+
from flo_ai.arium import AriumBuilder, AriumEventType, default_event_callback
61
+
62
+
# Enable event monitoring with default callback (logs to console)
63
+
arium = (AriumBuilder()
64
+
.add_agent(my_agent)
65
+
.add_tool(my_tool)
66
+
.start_with(my_agent)
67
+
.connect(my_agent, my_tool)
68
+
.end_with(my_tool)
69
+
.build())
70
+
71
+
result =await arium.run(
72
+
inputs=["Process this"],
73
+
event_callback=default_event_callback
74
+
)
75
+
```
76
+
77
+
### Custom Event Callbacks
78
+
79
+
```python
80
+
defmy_event_handler(event):
81
+
"""Custom event handler for specialized logging"""
Monitor only specific types of events by providing an `events_filter`:
104
+
105
+
```python
106
+
from flo_ai.arium import AriumEventType, default_event_callback
107
+
108
+
# Only monitor workflow lifecycle and node completions
109
+
important_events = [
110
+
AriumEventType.WORKFLOW_STARTED,
111
+
AriumEventType.NODE_COMPLETED,
112
+
AriumEventType.WORKFLOW_COMPLETED,
113
+
AriumEventType.WORKFLOW_FAILED
114
+
]
115
+
116
+
arium = (AriumBuilder()
117
+
.add_agent(my_agent)
118
+
.start_with(my_agent)
119
+
.end_with(my_agent)
120
+
.build())
121
+
122
+
result =await arium.run(
123
+
inputs=["Process this"],
124
+
event_callback=default_event_callback,
125
+
events_filter=important_events
126
+
)
127
+
```
128
+
129
+
### Silent Execution
130
+
131
+
By default, workflows run silently. You can use either approach:
132
+
133
+
```python
134
+
# Option 1: Use build_and_run() for convenience (no events)
135
+
result =await (AriumBuilder()
136
+
.add_agent(my_agent)
137
+
.start_with(my_agent)
138
+
.end_with(my_agent)
139
+
.build_and_run(["Silent execution"]))
140
+
141
+
# Option 2: Use build() then run() (no events)
142
+
arium = (AriumBuilder()
143
+
.add_agent(my_agent)
144
+
.start_with(my_agent)
145
+
.end_with(my_agent)
146
+
.build())
147
+
148
+
result =await arium.run(["Silent execution"])
149
+
```
150
+
151
+
### Event Monitoring vs Build-and-Run
152
+
153
+
**Important**: Event monitoring is only available through the `Arium.run()` method. The AriumBuilder's `build_and_run()` convenience method does not support event parameters.
154
+
155
+
-**For event monitoring**: Use `.build()` then `arium.run(inputs, event_callback=...)`
156
+
-**For simple execution**: Use `.build_and_run(inputs)` for convenience
157
+
-**For reusable workflows**: Use `.build()` once, then call `arium.run()` multiple times
158
+
159
+
### Event Data Structure
160
+
161
+
Each event is an `AriumEvent` object with the following properties:
162
+
163
+
```python
164
+
@dataclass
165
+
classAriumEvent:
166
+
event_type: AriumEventType # Type of event
167
+
timestamp: float# Unix timestamp
168
+
node_name: Optional[str] =None# Name of involved node
0 commit comments