Interface GuardrailResult<GR extends GuardrailResult<GR>>
- Type Parameters:
GR- The type of guardrail result to expect
- All Known Implementing Classes:
InputGuardrailResult, OutputGuardrailResult
public sealed interface GuardrailResult<GR extends GuardrailResult<GR>>
permits InputGuardrailResult, OutputGuardrailResult
The result of the validation of an interaction between a user and the LLM.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceThe message and the cause of the failure of a single validation.static enumThe possible results of a guardrails validation. -
Method Summary
Modifier and TypeMethodDescriptiondefault StringasString()<F extends GuardrailResult.Failure>
List<F> failures()default ThrowableGets the exception from the first failuredefault booleanWhether or not the result is successful, but the result was re-written, potentially due to re-promptingdefault booleanisFatal()Whether or not the result is considered fataldefault booleanWhether or not the result is considered successfulresult()The result of the guardrailThe message of the successful resultdefault GRvalidatedBy(Class<? extends Guardrail> guardrailClass) TheGuardrailclass which performed this validation
-
Method Details
-
result
GuardrailResult.Result result()The result of the guardrail -
failures
- Returns:
- The list of failures eventually resulting from a set of validations.
-
successfulText
String successfulText()The message of the successful result -
hasRewrittenResult
default boolean hasRewrittenResult()Whether or not the result is successful, but the result was re-written, potentially due to re-prompting -
isFatal
default boolean isFatal()Whether or not the result is considered fatal -
isSuccess
default boolean isSuccess()Whether or not the result is considered successful -
getFirstFailureException
Gets the exception from the first failure -
validatedBy
-
asString
-