langgoap.ConstraintSpec#
- class ConstraintSpec(key, max=None, min=None, weight=1.0, level='hard')[source]#
A resource/budget constraint for CSP optimization.
Constraints can be
"hard"(the default) or"soft". A hard constraint violation marks the planINFEASIBLE; a soft violation contributes a penalty to the plan’sHardSoftScorebut does not disqualify the plan.- Parameters:
key (str)
max (float | None)
min (float | None)
weight (float)
level (Literal['hard', 'soft'])
- key#
The resource key this constraint applies to (e.g.
"total_tokens","cost_usd").- Type:
str
- max#
Upper bound.
Nonemeans no upper bound.- Type:
float | None
- min#
Lower bound.
Nonemeans no lower bound.- Type:
float | None
- weight#
Penalty weight per unit of violation (default 1.0). Used by the CSP optimizer and the Score hierarchy.
- Type:
float
- level#
"hard"(default) or"soft". Hard constraints mark the plan infeasible on violation; soft constraints subtractweight * violation_amountfrom the plan’s soft score.- Type:
Literal[‘hard’, ‘soft’]
- __init__(key, max=None, min=None, weight=1.0, level='hard')#
- Parameters:
key (str)
max (float | None)
min (float | None)
weight (float)
level (Literal['hard', 'soft'])
- Return type:
None
Methods
__init__(key[, max, min, weight, level])Attributes