Skip to main content

Functions

FUNC default_output_to_bool

default_output_to_bool(x: CBlock | str) -> bool
Checks if a given output should be marked converted to True. Checks if the output is exactly equal to “yes” or “y” (case-insensitive). If not, it will also check if any of the words in the output are “yes” (case-insensitive).

Classes

CLASS ValidationResult

ValidationResults store the output of a Requirement’s validation. They can be used to return additional info from validation functions, which is useful for sampling/repairing.
Methods:

FUNC reason

reason(self) -> str | None
Reason for the validation result.

FUNC score

score(self) -> float | None
An optional score for the validation result.

FUNC thunk

thunk(self) -> ModelOutputThunk | None
The ModelOutputThunk associated with the validation func if an llm was used to generate the final result.

FUNC context

context(self) -> Context | None
The context associated with validation if a backend was used to generate the final result.

FUNC as_bool

as_bool(self) -> bool
Return a boolean value based on the result.

CLASS Requirement

Requirements are a special type of Component used as input to the Validate step in Instruct/Validate/Repair patterns.
Methods:

FUNC validate

validate(self, backend: Backend, ctx: Context) -> ValidationResult
Chooses the appropriate validation strategy and applies that strategy.

FUNC parts

parts(self)
Returns all of the constituent parts of a Requirement.

FUNC format_for_llm

format_for_llm(self) -> TemplateRepresentation | str
Some object protocol magic happens here with management of the output.