Class OutputGuardrailResult
java.lang.Object
dev.langchain4j.guardrail.OutputGuardrailResult
- All Implemented Interfaces:
GuardrailResult<OutputGuardrailResult>
public final class OutputGuardrailResult
extends Object
implements GuardrailResult<OutputGuardrailResult>
The result of the validation of an
OutputGuardrail-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classRepresents an output guardrail failureNested classes/interfaces inherited from interface GuardrailResult
GuardrailResult.Result -
Method Summary
Modifier and TypeMethodDescriptionBlock all retries for this resultbooleanstatic OutputGuardrailResultfailure(List<OutputGuardrailResult.Failure> failures) Produces a non-fatal failure<F extends GuardrailResult.Failure>
List<F> failures()Gets the reprompt messageinthashCode()booleanWhether or not the guardrail is forcing a repromptbooleanisRetry()Whether or not the guardrail is forcing a retry<T> Tresponse(OutputGuardrailRequest request) Gets the response computed from the combination of the originalChatResponsein theOutputGuardrailRequestand this resultresult()The result of the guardrailstatic OutputGuardrailResultsuccess()Gets a successful output guardrail resultThe message of the successful resultstatic OutputGuardrailResultsuccessWith(AiMessage successfulAiMessage) Produces a successful result with specific success textstatic OutputGuardrailResultsuccessWith(AiMessage successfulAiMessage, Object successfulResult) Produces a non-fatal failurestatic OutputGuardrailResultsuccessWith(String successfulText) Produces a successful result with specific success textstatic OutputGuardrailResultsuccessWith(String successfulText, Object successfulResult) Produces a non-fatal failuretoString()Methods inherited from interface GuardrailResult
asString, getFirstFailureException, hasRewrittenResult, isFatal, isSuccess, validatedBy
-
Method Details
-
success
Gets a successful output guardrail result -
successWith
Produces a successful result with specific success text- Parameters:
successfulText- The text of the successful result.- Returns:
- The result of a successful output guardrail validation with a specific text.
-
successWith
Produces a non-fatal failure- Parameters:
successfulText- The text of the successful result.successfulResult- The object generated by this successful result.- Returns:
- The result of a successful output guardrail validation with a specific text.
-
successWith
Produces a successful result with specific success text- Parameters:
successfulAiMessage- The AiMessage successful result.- Returns:
- The result of a successful output guardrail validation with a specific AiMessage.
-
successWith
public static OutputGuardrailResult successWith(AiMessage successfulAiMessage, Object successfulResult) Produces a non-fatal failure- Parameters:
successfulAiMessage- The AiMessage successful result.successfulResult- The object generated by this successful result.- Returns:
- The result of a successful output guardrail validation with a specific AiMessage.
-
failure
Produces a non-fatal failure- Parameters:
failures- A list ofOutputGuardrailResult.Failures- Returns:
- The result of a failed output guardrail validation.
-
isRetry
public boolean isRetry()Whether or not the guardrail is forcing a retry -
isReprompt
public boolean isReprompt()Whether or not the guardrail is forcing a reprompt -
blockRetry
Block all retries for this result -
getReprompt
-
toString
-
equals
-
hashCode
-
response
Gets the response computed from the combination of the originalChatResponsein theOutputGuardrailRequestand this result- Type Parameters:
T- The type of response- Parameters:
request- The output guardrail request- Returns:
- A response computed from the combination of the original
ChatResponsein theOutputGuardrailRequestand this result
-
result
Description copied from interface:GuardrailResultThe result of the guardrail- Specified by:
resultin interfaceGuardrailResult<OutputGuardrailResult>
-
failures
- Specified by:
failuresin interfaceGuardrailResult<OutputGuardrailResult>- Returns:
- The list of failures eventually resulting from a set of validations.
-
successfulText
Description copied from interface:GuardrailResultThe message of the successful result- Specified by:
successfulTextin interfaceGuardrailResult<OutputGuardrailResult>
-
successfulResult
-