messaging
Class info¶
Classes¶
Name | Children | Inherits |
---|---|---|
AgentResponse llmling_agent.messaging.messages Result from an agent's execution. |
||
ChatMessage llmling_agent.messaging.messages Common message format for all UI types. |
||
ChatMessageContainer llmling_agent.messaging.message_container Container for tracking and managing chat messages. |
||
EventManager llmling_agent.messaging.event_manager Manages multiple event sources and their lifecycles. |
||
MessageNode llmling_agent.messaging.messagenode Base class for all message processing nodes. |
||
NodeLogger llmling_agent.messaging.node_logger Handles database logging for node interactions. |
||
TeamResponse llmling_agent.messaging.messages Results from a team execution. |
||
TokenCost llmling_agent.messaging.messages Combined token and cost tracking. |
||
TokenUsage llmling_agent.messaging.messages Token usage statistics from model responses. |
🛈 DocStrings¶
Core messsaging classes for LLMling agent.
AgentResponse
dataclass
¶
Result from an agent's execution.
Source code in src/llmling_agent/messaging/messages.py
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 |
|
message
instance-attribute
¶
message: ChatMessage[TResult] | None
The actual message with content and metadata
ChatMessage
dataclass
¶
Common message format for all UI types.
Generically typed with: ChatMessage[Type of Content] The type can either be str or a BaseModel subclass.
Source code in src/llmling_agent/messaging/messages.py
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 |
|
associated_messages
class-attribute
instance-attribute
¶
associated_messages: list[ChatMessage[Any]] = field(default_factory=list)
List of messages which were generated during the the creation of this messsage.
content
instance-attribute
¶
content: TContent
Message content, typed as TContent (either str or BaseModel).
conversation_id
class-attribute
instance-attribute
¶
conversation_id: str | None = None
ID of the conversation this message belongs to.
cost_info
class-attribute
instance-attribute
¶
cost_info: TokenCost | None = None
Token usage and costs for this specific message if available.
forwarded_from
class-attribute
instance-attribute
¶
List of agent names (the chain) that forwarded this message to the sender.
message_id
class-attribute
instance-attribute
¶
Unique identifier for this message.
metadata
class-attribute
instance-attribute
¶
Additional metadata about the message.
model
class-attribute
instance-attribute
¶
model: str | None = None
Name of the model that generated this message.
name
class-attribute
instance-attribute
¶
name: str | None = None
Display name for the message sender in UI.
provider_extra
class-attribute
instance-attribute
¶
Provider specific metadata / extra information.
response_time
class-attribute
instance-attribute
¶
response_time: float | None = None
Time it took the LLM to respond.
timestamp
class-attribute
instance-attribute
¶
When this message was created.
tool_calls
class-attribute
instance-attribute
¶
tool_calls: list[ToolCallInfo] = field(default_factory=list)
List of tool calls made during message generation.
_get_content_str
¶
_get_content_str() -> str
Get string representation of content.
Source code in src/llmling_agent/messaging/messages.py
218 219 220 221 222 223 224 225 226 227 |
|
format
¶
format(
style: FormatStyle = "simple",
*,
template: str | None = None,
variables: dict[str, Any] | None = None,
show_metadata: bool = False,
show_costs: bool = False,
) -> str
Format message with configurable style.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
style
|
FormatStyle
|
Predefined style or "custom" for custom template |
'simple'
|
template
|
str | None
|
Custom Jinja template (required if style="custom") |
None
|
variables
|
dict[str, Any] | None
|
Additional variables for template rendering |
None
|
show_metadata
|
bool
|
Whether to include metadata |
False
|
show_costs
|
bool
|
Whether to include cost information |
False
|
Raises:
Type | Description |
---|---|
ValueError
|
If style is "custom" but no template provided or if style is invalid |
Source code in src/llmling_agent/messaging/messages.py
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 |
|
forwarded
¶
forwarded(previous_message: ChatMessage[Any]) -> Self
Create new message showing it was forwarded from another message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
previous_message
|
ChatMessage[Any]
|
The message that led to this one's creation |
required |
Returns:
Type | Description |
---|---|
Self
|
New message with updated chain showing the path through previous message |
Source code in src/llmling_agent/messaging/messages.py
202 203 204 205 206 207 208 209 210 211 212 |
|
to_text_message
¶
to_text_message() -> ChatMessage[str]
Convert this message to a text-only version.
Source code in src/llmling_agent/messaging/messages.py
214 215 216 |
|
ChatMessageContainer
¶
Bases: EventedList[ChatMessage[Any]]
Container for tracking and managing chat messages.
Extends EventedList to provide: - Message statistics (tokens, costs) - History formatting - Token-aware context window management - Role-based filtering
Source code in src/llmling_agent/messaging/message_container.py
28 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 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 |
|
last_message
property
¶
last_message: ChatMessage[Any] | None
Get most recent message or None if empty.
_build_flow_dag
¶
_build_flow_dag(message: ChatMessage[Any]) -> DAGNode | None
Build DAG from message flow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
ChatMessage[Any]
|
Message to build flow DAG for |
required |
Returns:
Type | Description |
---|---|
DAGNode | None
|
Root DAGNode of the graph |
Source code in src/llmling_agent/messaging/message_container.py
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 |
|
filter_by_role
¶
filter_by_role(
role: MessageRole, *, max_messages: int | None = None
) -> list[ChatMessage[Any]]
Get messages with specific role.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
role
|
MessageRole
|
Role to filter by (user/assistant/system) |
required |
max_messages
|
int | None
|
Optional limit on number of messages to return |
None
|
Returns:
Type | Description |
---|---|
list[ChatMessage[Any]]
|
List of messages with matching role |
Source code in src/llmling_agent/messaging/message_container.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
format
¶
Format conversation history with configurable style.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
style
|
FormatStyle
|
Formatting style to use |
'simple'
|
**kwargs
|
Any
|
Additional formatting options passed to message.format() |
{}
|
Returns:
Type | Description |
---|---|
str
|
Formatted conversation history as string |
Source code in src/llmling_agent/messaging/message_container.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
get_between
¶
get_between(
*, start_time: datetime | None = None, end_time: datetime | None = None
) -> list[ChatMessage[Any]]
Get messages within a time range.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start_time
|
datetime | None
|
Optional start of range |
None
|
end_time
|
datetime | None
|
Optional end of range |
None
|
Returns:
Type | Description |
---|---|
list[ChatMessage[Any]]
|
List of messages within the time range |
Source code in src/llmling_agent/messaging/message_container.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
|
get_context_window
¶
get_context_window(
*,
max_tokens: int | None = None,
max_messages: int | None = None,
include_system: bool = True,
) -> list[ChatMessage[Any]]
Get messages respecting token and message limits.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_tokens
|
int | None
|
Optional token limit for window |
None
|
max_messages
|
int | None
|
Optional message count limit |
None
|
include_system
|
bool
|
Whether to include system messages |
True
|
Returns:
Type | Description |
---|---|
list[ChatMessage[Any]]
|
List of messages fitting within constraints |
Source code in src/llmling_agent/messaging/message_container.py
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 |
|
get_history_tokens
¶
Get total token count for all messages.
Uses cost_info when available, falls back to tiktoken estimation for messages without usage information.
Returns:
Type | Description |
---|---|
int
|
Total token count across all messages |
Source code in src/llmling_agent/messaging/message_container.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
get_message_tokens
¶
get_message_tokens(message: ChatMessage[Any]) -> int
Get token count for a single message.
Uses cost_info if available, falls back to tiktoken estimation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
ChatMessage[Any]
|
Message to count tokens for |
required |
Returns:
Type | Description |
---|---|
int
|
Token count for the message |
Source code in src/llmling_agent/messaging/message_container.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
get_total_cost
¶
get_total_cost() -> float
Calculate total cost in USD across all messages.
Only includes messages with cost information.
Returns:
Type | Description |
---|---|
float
|
Total cost in USD |
Source code in src/llmling_agent/messaging/message_container.py
76 77 78 79 80 81 82 83 84 |
|
to_mermaid_graph
¶
to_mermaid_graph(
message: ChatMessage[Any],
*,
title: str = "",
theme: str | None = None,
rankdir: Literal["TB", "BT", "LR", "RL"] = "LR",
) -> str
Convert message flow to mermaid graph.
Source code in src/llmling_agent/messaging/message_container.py
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 |
|
EventManager
¶
Manages multiple event sources and their lifecycles.
Source code in src/llmling_agent/messaging/event_manager.py
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 |
|
__aenter__
async
¶
__aenter__() -> Self
Allow using manager as async context manager.
Source code in src/llmling_agent/messaging/event_manager.py
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
|
__aexit__
async
¶
__aexit__(*exc: object)
Clean up when exiting context.
Source code in src/llmling_agent/messaging/event_manager.py
310 311 312 |
|
__init__
¶
__init__(
node: MessageEmitter[Any, Any], enable_events: bool = True, auto_run: bool = True
)
Initialize event manager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node
|
MessageEmitter[Any, Any]
|
Agent to manage events for |
required |
enable_events
|
bool
|
Whether to enable event processing |
True
|
auto_run
|
bool
|
Whether to automatically call run() for event callbacks |
True
|
Source code in src/llmling_agent/messaging/event_manager.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
_default_handler
async
¶
_default_handler(event: EventData)
Default event handler that converts events to node runs.
Source code in src/llmling_agent/messaging/event_manager.py
65 66 67 68 |
|
_process_events
async
¶
_process_events(source: EventSource)
Process events from a source.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
EventSource
|
Event source to process |
required |
Source code in src/llmling_agent/messaging/event_manager.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
|
add_callback
¶
add_callback(callback: EventCallback)
Register an event callback.
Source code in src/llmling_agent/messaging/event_manager.py
70 71 72 |
|
add_email_watch
async
¶
add_email_watch(
host: str,
username: str,
password: str,
*,
name: str | None = None,
port: int = 993,
folder: str = "INBOX",
ssl: bool = True,
check_interval: int = 60,
mark_seen: bool = True,
filters: dict[str, str] | None = None,
max_size: int | None = None,
) -> EventSource
Add email monitoring event source.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
host
|
str
|
IMAP server hostname |
required |
username
|
str
|
Email account username |
required |
password
|
str
|
Account password or app password |
required |
name
|
str | None
|
Optional source name |
None
|
port
|
int
|
Server port (default: 993 for IMAP SSL) |
993
|
folder
|
str
|
Mailbox to monitor |
'INBOX'
|
ssl
|
bool
|
Whether to use SSL/TLS |
True
|
check_interval
|
int
|
Seconds between checks |
60
|
mark_seen
|
bool
|
Whether to mark processed emails as seen |
True
|
filters
|
dict[str, str] | None
|
Optional email filtering criteria |
None
|
max_size
|
int | None
|
Maximum email size in bytes |
None
|
Source code in src/llmling_agent/messaging/event_manager.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 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
|
add_file_watch
async
¶
add_file_watch(
paths: str | Sequence[str],
*,
name: str | None = None,
extensions: list[str] | None = None,
ignore_paths: list[str] | None = None,
recursive: bool = True,
debounce: int = 1600,
) -> EventSource
Add file system watch event source.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
paths
|
str | Sequence[str]
|
Paths or patterns to watch |
required |
name
|
str | None
|
Optional source name (default: generated from paths) |
None
|
extensions
|
list[str] | None
|
File extensions to monitor |
None
|
ignore_paths
|
list[str] | None
|
Paths to ignore |
None
|
recursive
|
bool
|
Whether to watch subdirectories |
True
|
debounce
|
int
|
Minimum time between events (ms) |
1600
|
Source code in src/llmling_agent/messaging/event_manager.py
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 |
|
add_source
async
¶
add_source(config: EventConfig) -> EventSource
Add and start a new event source.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
EventConfig
|
Event source configuration |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If source already exists or is invalid |
Source code in src/llmling_agent/messaging/event_manager.py
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 |
|
add_timed_event
async
¶
add_timed_event(
schedule: str,
prompt: str,
*,
name: str | None = None,
timezone: str | None = None,
skip_missed: bool = False,
) -> TimeEventSource
Add time-based event source.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
schedule
|
str
|
Cron expression (e.g. "0 9 * * 1-5" for weekdays at 9am) |
required |
prompt
|
str
|
Prompt to send when triggered |
required |
name
|
str | None
|
Optional source name |
None
|
timezone
|
str | None
|
Optional timezone (system default if None) |
None
|
skip_missed
|
bool
|
Whether to skip missed executions |
False
|
Source code in src/llmling_agent/messaging/event_manager.py
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 |
|
add_webhook
async
¶
add_webhook(
path: str, *, name: str | None = None, port: int = 8000, secret: str | None = None
) -> EventSource
Add webhook event source.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
URL path to listen on |
required |
name
|
str | None
|
Optional source name |
None
|
port
|
int
|
Port to listen on |
8000
|
secret
|
str | None
|
Optional secret for request validation |
None
|
Source code in src/llmling_agent/messaging/event_manager.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
cleanup
async
¶
cleanup()
Clean up all event sources and tasks.
Source code in src/llmling_agent/messaging/event_manager.py
287 288 289 290 291 292 |
|
emit_event
async
¶
emit_event(event: EventData)
Emit event to all callbacks and optionally handle via node.
Source code in src/llmling_agent/messaging/event_manager.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|
poll
¶
poll(
event_type: str, interval: timedelta | None = None
) -> Callable[[Callable[..., Any]], Callable[..., Any]]
Decorator to register an event observer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_type
|
str
|
Type of event to observe |
required |
interval
|
timedelta | None
|
Optional polling interval for periodic checks |
None
|
Example
@event_manager.observe("file_changed") async def handle_file_change(event: FileEventData): await process_file(event.path)
Source code in src/llmling_agent/messaging/event_manager.py
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 |
|
remove_callback
¶
remove_callback(callback: EventCallback)
Remove a previously registered callback.
Source code in src/llmling_agent/messaging/event_manager.py
74 75 76 |
|
remove_source
async
¶
remove_source(name: str)
Stop and remove an event source.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of source to remove |
required |
Source code in src/llmling_agent/messaging/event_manager.py
256 257 258 259 260 261 262 263 264 |
|
track
¶
track(
event_name: str | None = None, **event_metadata: Any
) -> Callable[[Callable[..., Any]], Callable[..., Any]]
Track function calls as events.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_name
|
str | None
|
Optional name for the event (defaults to function name) |
None
|
**event_metadata
|
Any
|
Additional metadata to include with event |
{}
|
Example
@event_manager.track("user_search") async def search_docs(query: str) -> list[Doc]: results = await search(query) return results # This result becomes event data
Source code in src/llmling_agent/messaging/event_manager.py
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 |
|
MessageNode
¶
Bases: MessageEmitter[TDeps, TResult]
Base class for all message processing nodes.
Source code in src/llmling_agent/messaging/messagenode.py
28 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 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 |
|
tool_used
class-attribute
instance-attribute
¶
tool_used = Signal(ToolCallInfo)
Signal emitted when node uses a tool.
pre_run
async
¶
pre_run(
*prompt: AnyPromptType | Image | PathLike[str] | ChatMessage,
) -> tuple[ChatMessage[Any], list[Content | str]]
Hook to prepare a MessgeNode run call.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*prompt
|
AnyPromptType | Image | PathLike[str] | ChatMessage
|
The prompt(s) to prepare. |
()
|
Returns:
Type | Description |
---|---|
tuple[ChatMessage[Any], list[Content | str]]
|
A tuple of: - Either incoming message, or a constructed incoming message based on the prompt(s). - A list of prompts to be sent to the model. |
Source code in src/llmling_agent/messaging/messagenode.py
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 |
|
run
async
¶
run(
*prompt: AnyPromptType | Image | PathLike[str] | ChatMessage,
wait_for_connections: bool | None = None,
store_history: bool = True,
**kwargs: Any,
) -> ChatMessage[TResult]
Execute node with prompts and handle message routing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt
|
AnyPromptType | Image | PathLike[str] | ChatMessage
|
Input prompts |
()
|
wait_for_connections
|
bool | None
|
Whether to wait for forwarded messages |
None
|
store_history
|
bool
|
Whether to store in conversation history |
True
|
**kwargs
|
Any
|
Additional arguments for _run |
{}
|
Source code in src/llmling_agent/messaging/messagenode.py
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 |
|
run_iter
abstractmethod
¶
run_iter(*prompts: Any, **kwargs: Any) -> AsyncIterator[ChatMessage[Any]]
Yield messages during execution.
Source code in src/llmling_agent/messaging/messagenode.py
123 124 125 126 127 128 129 |
|
NodeLogger
¶
Handles database logging for node interactions.
Source code in src/llmling_agent/messaging/node_logger.py
23 24 25 26 27 28 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 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 |
|
__init__
¶
__init__(node: MessageEmitter[Any, Any], enable_db_logging: bool = True)
Initialize logger.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node
|
MessageEmitter[Any, Any]
|
Node to log interactions for |
required |
enable_db_logging
|
bool
|
Whether to enable logging |
True
|
Source code in src/llmling_agent/messaging/node_logger.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
clear_state
¶
clear_state()
Clear node state.
Source code in src/llmling_agent/messaging/node_logger.py
47 48 49 50 |
|
init_conversation
¶
init_conversation()
Create initial conversation record.
Source code in src/llmling_agent/messaging/node_logger.py
62 63 64 65 66 67 |
|
log_message
¶
log_message(message: ChatMessage)
Handle message from chat signal.
Source code in src/llmling_agent/messaging/node_logger.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
log_tool_call
¶
log_tool_call(tool_call: ToolCallInfo)
Handle tool usage signal.
Source code in src/llmling_agent/messaging/node_logger.py
86 87 88 89 90 91 92 93 94 95 96 |
|
TeamResponse
¶
Bases: list[AgentResponse[Any]]
Results from a team execution.
Source code in src/llmling_agent/messaging/messages.py
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 |
|
by_agent
¶
by_agent(name: str) -> AgentResponse[TMessageContent] | None
Get response from specific agent.
Source code in src/llmling_agent/messaging/messages.py
338 339 340 |
|
format_durations
¶
format_durations() -> str
Format execution times.
Source code in src/llmling_agent/messaging/messages.py
342 343 344 345 |
|
to_chat_message
¶
to_chat_message() -> ChatMessage[str]
Convert team response to a single chat message.
Source code in src/llmling_agent/messaging/messages.py
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
|
TokenCost
dataclass
¶
Combined token and cost tracking.
Source code in src/llmling_agent/messaging/messages.py
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 |
|
from_usage
async
classmethod
¶
Create result from usage data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
usage
|
Usage | None
|
Token counts from model response |
required |
model
|
str
|
Name of the model used |
required |
prompt
|
str
|
The prompt text sent to model |
required |
completion
|
str
|
The completion text received |
required |
Returns:
Type | Description |
---|---|
TokenCost | None
|
TokenCost if usage data available, None otherwise |
Source code in src/llmling_agent/messaging/messages.py
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 |
|
TokenUsage
¶
Bases: TypedDict
Token usage statistics from model responses.
Source code in src/llmling_agent/messaging/messages.py
85 86 87 88 89 90 91 92 93 |
|