conditions
Class info¶
Classes¶
Name | Children | Inherits |
---|---|---|
AndCondition llmling_agent.models.conditions Require all conditions to be met. |
||
CallableCondition llmling_agent.models.conditions Custom predicate function. |
||
ConnectionCondition llmling_agent.models.conditions Base class for connection control conditions. |
||
CostCondition llmling_agent.models.conditions Stop when cost threshold is reached. |
||
CostLimitCondition llmling_agent.models.conditions Disconnect when cost limit is reached. |
||
Jinja2Condition llmling_agent.models.conditions Evaluate condition using Jinja2 template. |
||
MessageCountCondition llmling_agent.models.conditions Disconnect after N messages. |
||
OrCondition llmling_agent.models.conditions Require any condition to be met. |
||
TimeCondition llmling_agent.models.conditions Disconnect after time period. |
||
TokenThresholdCondition llmling_agent.models.conditions Disconnect after token threshold is reached. |
||
WordMatchCondition llmling_agent.models.conditions Disconnect when word/phrase is found in message. |
🛈 DocStrings¶
AndCondition
¶
Bases: ConnectionCondition
Require all conditions to be met.
Source code in src/llmling_agent/models/conditions.py
213 214 215 216 217 218 219 220 221 222 223 224 225 |
|
type
class-attribute
instance-attribute
¶
type: Literal['and'] = Field('and', init=False)
Condition to AND-combine multiple conditions.
check
async
¶
check(context: EventContext) -> bool
Check if all conditions are met.
Source code in src/llmling_agent/models/conditions.py
222 223 224 225 |
|
CallableCondition
¶
Bases: ConnectionCondition
Custom predicate function.
Source code in src/llmling_agent/models/conditions.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
|
predicate
instance-attribute
¶
Function to evaluate condition: Args: message: Current message being processed stats: Current connection statistics Returns: Whether condition is met
type
class-attribute
instance-attribute
¶
type: Literal['callable'] = Field('callable', init=False)
Condition based on an import path pointing to a predicate.
check
async
¶
check(context: EventContext) -> bool
Execute predicate function.
Source code in src/llmling_agent/models/conditions.py
208 209 210 |
|
ConnectionCondition
¶
Bases: BaseModel
Base class for connection control conditions.
Source code in src/llmling_agent/models/conditions.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
name
class-attribute
instance-attribute
¶
name: str | None = None
Optional name for the condition for referencing.
type
class-attribute
instance-attribute
¶
type: str = Field(init=False)
Discriminator for condition types.
check
async
¶
check(context: EventContext) -> bool
Check if condition is met.
Source code in src/llmling_agent/models/conditions.py
27 28 29 |
|
CostCondition
¶
Bases: ConnectionCondition
Stop when cost threshold is reached.
Source code in src/llmling_agent/models/conditions.py
163 164 165 166 167 168 169 170 171 172 173 174 |
|
type
class-attribute
instance-attribute
¶
type: Literal['cost'] = Field('cost', init=False)
Cost-based condition.
check
async
¶
check(context: EventContext) -> bool
Check if cost limit is reached.
Source code in src/llmling_agent/models/conditions.py
172 173 174 |
|
CostLimitCondition
¶
Bases: ConnectionCondition
Disconnect when cost limit is reached.
Source code in src/llmling_agent/models/conditions.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
|
type
class-attribute
instance-attribute
¶
type: Literal['cost_limit'] = Field('cost_limit', init=False)
Cost-limit condition.
check
async
¶
check(context: EventContext) -> bool
Check if cost limit is reached.
Source code in src/llmling_agent/models/conditions.py
186 187 188 189 190 |
|
Jinja2Condition
¶
Bases: ConnectionCondition
Evaluate condition using Jinja2 template.
Source code in src/llmling_agent/models/conditions.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
MessageCountCondition
¶
Bases: ConnectionCondition
Disconnect after N messages.
Source code in src/llmling_agent/models/conditions.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 |
|
count_mode
class-attribute
instance-attribute
¶
count_mode: Literal['total', 'per_agent'] = 'total'
How to count messages: - total: All messages in conversation - per_agent: Messages from each agent separately
type
class-attribute
instance-attribute
¶
type: Literal['message_count'] = Field('message_count', init=False)
Message-count-based condition.
check
async
¶
check(context: EventContext) -> bool
Check if message count threshold is reached.
Source code in src/llmling_agent/models/conditions.py
104 105 106 107 108 109 110 111 112 113 |
|
OrCondition
¶
Bases: ConnectionCondition
Require any condition to be met.
Source code in src/llmling_agent/models/conditions.py
228 229 230 231 232 233 234 235 236 237 238 239 240 |
|
type
class-attribute
instance-attribute
¶
type: Literal['or'] = Field('or', init=False)
Condition to OR-combine multiple conditions.
check
async
¶
check(context: EventContext) -> bool
Check if any condition is met.
Source code in src/llmling_agent/models/conditions.py
237 238 239 240 |
|
TimeCondition
¶
Bases: ConnectionCondition
Disconnect after time period.
Source code in src/llmling_agent/models/conditions.py
116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
type
class-attribute
instance-attribute
¶
type: Literal['time'] = Field('time', init=False)
Time-based condition.
check
async
¶
check(context: EventContext) -> bool
Check if time duration has elapsed.
Source code in src/llmling_agent/models/conditions.py
125 126 127 128 |
|
TokenThresholdCondition
¶
Bases: ConnectionCondition
Disconnect after token threshold is reached.
Source code in src/llmling_agent/models/conditions.py
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 |
|
count_type
class-attribute
instance-attribute
¶
count_type: Literal['total', 'prompt', 'completion'] = 'total'
What tokens to count: - total: All tokens used - prompt: Only prompt tokens - completion: Only completion tokens
type
class-attribute
instance-attribute
¶
type: Literal['token_threshold'] = Field('token_threshold', init=False)
Type discriminator.
check
async
¶
check(context: EventContext) -> bool
Check if token threshold is reached.
Source code in src/llmling_agent/models/conditions.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
WordMatchCondition
¶
Bases: ConnectionCondition
Disconnect when word/phrase is found in message.
Source code in src/llmling_agent/models/conditions.py
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 |
|
case_sensitive
class-attribute
instance-attribute
¶
case_sensitive: bool = False
Whether to match case-sensitively.
mode
class-attribute
instance-attribute
¶
mode: Literal['any', 'all'] = 'any'
Match mode: - any: Trigger if any word matches - all: Require all words to match
type
class-attribute
instance-attribute
¶
type: Literal['word_match'] = Field('word_match', init=False)
Word-comparison-based condition.
check
async
¶
check(context: EventContext) -> bool
Check if message contains specified words.
Source code in src/llmling_agent/models/conditions.py
76 77 78 79 80 81 82 83 84 85 86 |
|