talk
Class info¶
Classes¶
Name | Children | Inherits |
---|---|---|
AggregatedTalkStats llmling_agent.talk.stats Statistics aggregated from multiple connections. |
||
ConnectionRegistry llmling_agent.talk.registry Registry for managing named connections. |
||
Talk llmling_agent.talk.talk Manages message flow between agents/groups. |
||
TalkStats llmling_agent.talk.stats Statistics for a single connection. |
||
TeamTalk llmling_agent.talk.talk Group of connections with aggregate operations. |
🛈 DocStrings¶
Talk classes.
AggregatedTalkStats
dataclass
¶
Bases: AggregatedMessageStats
Statistics aggregated from multiple connections.
Source code in src/llmling_agent/talk/stats.py
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 |
|
ConnectionRegistry
¶
Bases: BaseRegistry[str, Talk]
Registry for managing named connections.
Allows looking up Talk instances by their name. Only named connections get registered.
Source code in src/llmling_agent/talk/registry.py
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 |
|
__init__
¶
__init__(*args, **kwargs)
Initialize registry and connect event handlers.
Source code in src/llmling_agent/talk/registry.py
69 70 71 72 73 74 75 |
|
_handle_message_flow
¶
_handle_message_flow(event: ConnectionProcessed)
Forward message flow to global stream.
Source code in src/llmling_agent/talk/registry.py
93 94 95 |
|
_on_talk_added
¶
Handle new talk being added to registry.
Source code in src/llmling_agent/talk/registry.py
77 78 79 80 |
|
_on_talk_changed
¶
Handle talk being replaced in registry.
Source code in src/llmling_agent/talk/registry.py
87 88 89 90 91 |
|
_on_talk_removed
¶
Handle talk being removed from registry.
Source code in src/llmling_agent/talk/registry.py
82 83 84 85 |
|
_validate_item
¶
Ensure only Talk instances can be registered.
Source code in src/llmling_agent/talk/registry.py
101 102 103 104 105 106 107 |
|
register_auto
¶
Register talk with auto-generated unique name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
talk
|
Talk[Any]
|
Talk instance to register |
required |
base_name
|
str | None
|
Optional base name to use (defaults to talk.name) |
None
|
Returns:
Type | Description |
---|---|
str
|
The actual name used for registration |
Source code in src/llmling_agent/talk/registry.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
Talk
¶
Manages message flow between agents/groups.
Source code in src/llmling_agent/talk/talk.py
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 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 |
|
ConnectionProcessed
dataclass
¶
Event emitted when a message flows through a connection.
Source code in src/llmling_agent/talk/talk.py
42 43 44 45 46 47 48 49 50 51 |
|
__init__
¶
__init__(
source: MessageEmitter,
targets: Sequence[MessageNode],
group: TeamTalk | None = None,
*,
name: str | None = None,
connection_type: ConnectionType = "run",
wait_for_connections: bool = False,
priority: int = 0,
delay: timedelta | None = None,
queued: bool = False,
queue_strategy: QueueStrategy = "latest",
transform: AnyTransformFn[ChatMessage[TTransmittedData]] | None = None,
filter_condition: AnyFilterFn | None = None,
stop_condition: AnyFilterFn | None = None,
exit_condition: AnyFilterFn | None = None,
)
Initialize talk connection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
MessageEmitter
|
Agent sending messages |
required |
targets
|
Sequence[MessageNode]
|
Agents receiving messages |
required |
group
|
TeamTalk | None
|
Optional group this talk belongs to |
None
|
name
|
str | None
|
Optional name for this talk |
None
|
connection_type
|
ConnectionType
|
How to handle messages: - "run": Execute message as a new run in target - "context": Add message as context to target - "forward": Forward message to target's outbox |
'run'
|
wait_for_connections
|
bool
|
Whether to wait for all targets to complete |
False
|
priority
|
int
|
Task priority (lower = higher priority) |
0
|
delay
|
timedelta | None
|
Optional delay before processing |
None
|
queued
|
bool
|
Whether messages should be queued for manual processing |
False
|
queue_strategy
|
QueueStrategy
|
How to process queued messages: - "concat": Combine all messages with newlines - "latest": Use only the most recent message - "buffer": Process all messages individually |
'latest'
|
transform
|
AnyTransformFn[ChatMessage[TTransmittedData]] | None
|
Optional function to transform messages |
None
|
filter_condition
|
AnyFilterFn | None
|
Optional condition for filtering messages |
None
|
stop_condition
|
AnyFilterFn | None
|
Optional condition for disconnecting |
None
|
exit_condition
|
AnyFilterFn | None
|
Optional condition for stopping the event loop |
None
|
Source code in src/llmling_agent/talk/talk.py
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 |
|
__rshift__
¶
__rshift__(
other: MessageNode[Any, Any]
| ProcessorCallback[Any]
| Sequence[MessageNode[Any, Any] | ProcessorCallback[Any]],
) -> TeamTalk[Any]
Add another node as target to the connection or group.
Example
connection >> other_agent # Connect to single agent connection >> (agent2 & agent3) # Connect to group
Source code in src/llmling_agent/talk/talk.py
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 |
|
_evaluate_condition
async
¶
_evaluate_condition(
condition: Callable[..., bool | Awaitable[bool]] | None,
message: ChatMessage[Any],
target: MessageNode,
*,
default_return: bool = False,
) -> bool
Evaluate a condition with flexible parameter handling.
Source code in src/llmling_agent/talk/talk.py
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 |
|
_handle_message
async
¶
_handle_message(
message: ChatMessage[TTransmittedData], prompt: str | None = None
) -> list[ChatMessage[Any]]
Handle message forwarding based on connection configuration.
Source code in src/llmling_agent/talk/talk.py
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 |
|
_process_for_target
async
¶
_process_for_target(
message: ChatMessage[Any],
target: MessageNode,
prompt: AnyPromptType | Image | PathLike[str] | None = None,
) -> ChatMessage[Any] | None
Process message for a single target.
Source code in src/llmling_agent/talk/talk.py
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
|
disconnect
¶
disconnect()
Permanently disconnect the connection.
Source code in src/llmling_agent/talk/talk.py
492 493 494 |
|
on_event
¶
on_event(
event_type: ConnectionEventType,
callback: Callable[[ConnectionEventData[TTransmittedData]], None | Awaitable[None]],
) -> Self
Register callback for connection events.
Source code in src/llmling_agent/talk/talk.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
|
paused
async
¶
paused()
Temporarily set inactive.
Source code in src/llmling_agent/talk/talk.py
482 483 484 485 486 487 488 489 490 |
|
transform
¶
transform(
transformer: Callable[
[ChatMessage[TTransmittedData]],
ChatMessage[TNewData] | Awaitable[ChatMessage[TNewData]],
],
*,
name: str | None = None,
description: str | None = None,
) -> Talk[TNewData]
Chain a new transformation after existing ones.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transformer
|
Callable[[ChatMessage[TTransmittedData]], ChatMessage[TNewData] | Awaitable[ChatMessage[TNewData]]]
|
Function to transform messages |
required |
name
|
str | None
|
Optional name for debugging |
None
|
description
|
str | None
|
Optional description |
None
|
Returns:
Type | Description |
---|---|
Talk[TNewData]
|
New Talk instance with chained transformation |
Example
talk = (agent1 >> agent2)
.transform(parse_json) # str -> dict
.transform(extract_values) # dict -> list
Source code in src/llmling_agent/talk/talk.py
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 |
|
trigger
async
¶
trigger(
prompt: AnyPromptType | Image | PathLike[str] | None = None,
) -> list[ChatMessage[TTransmittedData]]
Process queued messages.
Source code in src/llmling_agent/talk/talk.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
|
TalkStats
dataclass
¶
Bases: MessageStats
Statistics for a single connection.
Source code in src/llmling_agent/talk/stats.py
60 61 62 63 64 65 |
|
TeamTalk
¶
Bases: list['Talk | TeamTalk']
Group of connections with aggregate operations.
Source code in src/llmling_agent/talk/talk.py
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 |
|
__rshift__
¶
__rshift__(
other: MessageNode[Any, Any]
| ProcessorCallback[Any]
| Sequence[MessageNode[Any, Any] | ProcessorCallback[Any]],
) -> TeamTalk[Any]
Add another node as target to the connection or group.
Example
connection >> other_agent # Connect to single agent connection >> (agent2 & agent3) # Connect to group
Source code in src/llmling_agent/talk/talk.py
515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 |
|
disconnect
¶
disconnect()
Disconnect all connections in group.
Source code in src/llmling_agent/talk/talk.py
617 618 619 620 |
|
from_nodes
classmethod
¶
from_nodes(
agents: Sequence[MessageNode], targets: list[MessageNode] | None = None
) -> Self
Create TeamTalk from a collection of agents.
Source code in src/llmling_agent/talk/talk.py
579 580 581 582 583 584 585 586 |
|
get_active_talks
¶
Get list of currently active talks.
Source code in src/llmling_agent/talk/talk.py
602 603 604 |
|
has_active_talks
¶
has_active_talks() -> bool
Check if any contained talks are active.
Source code in src/llmling_agent/talk/talk.py
598 599 600 |
|
iter_talks
¶
Get all contained talks.
Source code in src/llmling_agent/talk/talk.py
558 559 560 561 562 563 564 565 |
|
paused
async
¶
paused()
Temporarily set inactive.
Source code in src/llmling_agent/talk/talk.py
588 589 590 591 592 593 594 595 596 |
|