Functions
FUNC requirement_check_to_bool
True.
By default, the requirement check alora outputs: \{"requirement_likelihood": 0.0\}.
Returns True if the likelihood value is > 0.5.
Args:
x: ALoRA output string or CBlock containing JSON with arequirement_likelihoodfield.
- True if the extracted likelihood exceeds 0.5, False otherwise.
FUNC reqify
r: A[Requirement](../../core/requirement#class-requirement)object or a plain string description to wrap as one.
- A
[Requirement](../../core/requirement#class-requirement)instance.
Exception: Ifris neither astrnor a[Requirement](../../core/requirement#class-requirement)instance.
FUNC req
Requirement.__init__.
Args:
*args: Positional arguments forwarded toRequirement.__init__.**kwargs: Keyword arguments forwarded toRequirement.__init__.
- A new
[Requirement](../../core/requirement#class-requirement)instance.
FUNC check
Requirement.__init__(..., check_only=True).
Args:
*args: Positional arguments forwarded toRequirement.__init__.**kwargs: Keyword arguments forwarded toRequirement.__init__.
- A new
[Requirement](../../core/requirement#class-requirement)instance withcheck_only=True.
FUNC simple_validate
Requirement("Answer 'yes' or 'no'", simple_validate(lambda x: x == 'yes' or x == 'no')
Validation functions operate over Context. Often you do not care about the entire context, and just want to consider the most recent output from the model.
Args:
fn: the simple validation function that takes a string and returns either a bool or (bool, str)reason: only used if the provided function returns a bool; if the validation function fails, a static reason for that failure to give to the llm when repairing
- A validation function that takes a
[Context](../../core/base#class-context)and returns a[ValidationResult](../../core/requirement#class-validationresult).
ValueError: Iffnreturns a type other thanboolortuple[bool, str].
Classes
CLASS LLMaJRequirement
A requirement that always uses LLM-as-a-Judge. Any available constraint ALoRA will be ignored.
Attributes:
use_aloras: AlwaysFalsefor this class; ALoRA adapters are never used even if they are available.
CLASS ALoraRequirement
A requirement validated by an ALoRA adapter; falls back to LLM-as-a-Judge only on error.
If an exception is thrown during the ALoRA execution path, mellea will
fall back to LLMaJ. That is the only case where LLMaJ will be used.
Args:
description: Human-readable requirement description.intrinsic_name: Name of the ALoRA intrinsic to use. Defaults to"requirement_check".
use_aloras: AlwaysTrue; this class always attempts to use ALoRA adapters for validation.