connection_manager
Class info¶
Classes¶
Name | Children | Inherits |
---|---|---|
AggregatedTalkStats llmling_agent.talk.stats Statistics aggregated from multiple connections. |
||
ConnectionManager llmling_agent.messaging.connection_manager Manages connections for both Agents and Teams. |
||
Talk llmling_agent.talk.talk Manages message flow between agents/groups. |
||
TeamTalk llmling_agent.talk.talk Group of connections with aggregate operations. |
🛈 DocStrings¶
Manages message flow between agents/groups.
ConnectionManager
¶
Manages connections for both Agents and Teams.
Source code in src/llmling_agent/messaging/connection_manager.py
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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
|
_handle_message_flow
¶
_handle_message_flow(event: ConnectionProcessed)
Forward message flow to our aggregated signal.
Source code in src/llmling_agent/messaging/connection_manager.py
63 64 65 |
|
_on_talk_added
¶
Connect to new talk's signal.
Source code in src/llmling_agent/messaging/connection_manager.py
50 51 52 |
|
_on_talk_changed
¶
Update signal connections on talk change.
Source code in src/llmling_agent/messaging/connection_manager.py
58 59 60 61 |
|
_on_talk_removed
¶
Disconnect from removed talk's signal.
Source code in src/llmling_agent/messaging/connection_manager.py
54 55 56 |
|
create_connection
¶
create_connection(
source: MessageEmitter,
target: MessageNode | Sequence[MessageNode],
*,
connection_type: ConnectionType = "run",
priority: int = 0,
delay: timedelta | None = None,
queued: bool = False,
queue_strategy: QueueStrategy = "latest",
transform: AnyTransformFn | None = None,
filter_condition: AsyncFilterFn | None = None,
stop_condition: AsyncFilterFn | None = None,
exit_condition: AsyncFilterFn | None = None,
name: str | None = None,
) -> Talk[Any] | TeamTalk
Create connection(s) to target(s).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
MessageEmitter
|
Source agent or team |
required |
target
|
MessageNode | Sequence[MessageNode]
|
Single target or sequence of targets |
required |
connection_type
|
ConnectionType
|
How to handle messages |
'run'
|
priority
|
int
|
Task priority (lower = higher priority) |
0
|
delay
|
timedelta | None
|
Optional delay before processing |
None
|
queued
|
bool
|
Whether to queue messages for manual processing |
False
|
queue_strategy
|
QueueStrategy
|
How to process queued messages |
'latest'
|
transform
|
AnyTransformFn | None
|
Optional message transformation |
None
|
filter_condition
|
AsyncFilterFn | None
|
When to filter messages |
None
|
stop_condition
|
AsyncFilterFn | None
|
When to disconnect |
None
|
exit_condition
|
AsyncFilterFn | None
|
When to exit application |
None
|
name
|
str | None
|
Optional name for cross-referencing connections |
None
|
Source code in src/llmling_agent/messaging/connection_manager.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
disconnect
¶
disconnect(node: MessageNode)
Disconnect a specific node.
Source code in src/llmling_agent/messaging/connection_manager.py
228 229 230 231 232 233 |
|
disconnect_all
¶
disconnect_all()
Disconnect all managed connections.
Source code in src/llmling_agent/messaging/connection_manager.py
222 223 224 225 226 |
|
get_connections
¶
Get all Talk connections, flattening TeamTalks.
Source code in src/llmling_agent/messaging/connection_manager.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
|
get_mermaid_diagram
¶
Generate mermaid flowchart of all connections.
Source code in src/llmling_agent/messaging/connection_manager.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
|
get_targets
¶
get_targets(
recursive: bool = False, _seen: set[AgentName] | None = None
) -> set[MessageNode]
Get all currently connected target agents.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
recursive
|
bool
|
Whether to include targets of targets |
False
|
Source code in src/llmling_agent/messaging/connection_manager.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
has_connection_to
¶
has_connection_to(target: MessageNode) -> bool
Check if target is connected.
Source code in src/llmling_agent/messaging/connection_manager.py
116 117 118 |
|
paused_routing
async
¶
paused_routing()
Temporarily pause message routing to connections.
Source code in src/llmling_agent/messaging/connection_manager.py
251 252 253 254 255 256 257 258 259 260 261 262 |
|
route_message
async
¶
route_message(message: ChatMessage[Any], wait: bool | None = None)
Route message to all connections.
Source code in src/llmling_agent/messaging/connection_manager.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
|
set_wait_state
¶
set_wait_state(target: MessageEmitter | AgentName, wait: bool = True)
Set waiting behavior for target.
Source code in src/llmling_agent/messaging/connection_manager.py
67 68 69 70 71 72 73 74 |
|
trigger_all
async
¶
trigger_all() -> dict[AgentName, list[ChatMessage[Any]]]
Trigger all queued connections.
Source code in src/llmling_agent/messaging/connection_manager.py
203 204 205 206 207 208 209 |
|
trigger_for
async
¶
trigger_for(target: AgentName | MessageNode[Any, Any]) -> list[ChatMessage[Any]]
Trigger queued connections to specific target.
Source code in src/llmling_agent/messaging/connection_manager.py
211 212 213 214 215 216 217 218 219 220 |
|
wait_for_connections
async
¶
wait_for_connections(_seen: set[AgentName] | None = None)
Wait for this agent and all connected agents to complete their tasks.
Source code in src/llmling_agent/messaging/connection_manager.py
76 77 78 79 80 81 82 83 84 85 86 87 |
|