Class OutputGuardrail.ValidationException

java.lang.Object
java.lang.Throwable
java.lang.Exception
io.quarkiverse.langchain4j.guardrails.OutputGuardrail.ValidationException
All Implemented Interfaces:
Serializable
Enclosing interface:
OutputGuardrail

public static class OutputGuardrail.ValidationException extends Exception
An exception thrown when the validation fails.
See Also:
  • Constructor Details

    • ValidationException

      public ValidationException(String message, boolean retry, String reprompt)
      Creates a new instance of OutputGuardrail.ValidationException without a cause.
      Parameters:
      message - the error message
      retry - whether the request should be retried
      reprompt - if the request should be retried, the reprompt message. If null, the original request with the same context will be retried.
    • ValidationException

      public ValidationException(String message, Throwable cause, boolean retry, String reprompt)
      Creates a new instance of OutputGuardrail.ValidationException with a cause.
      Parameters:
      message - the error message
      cause - the cause
      retry - whether the request should be retried
      reprompt - if the request should be retried, the reprompt message. If null, the original request with the same context will be retried.
  • Method Details

    • isRetry

      public boolean isRetry()
      Whether the request should be retried.
      Returns:
      true if the request should be retried, false otherwise.
    • getReprompt

      public String getReprompt()
      The reprompt message.

      If isRetry() returns true, the reprompt message (if not null is added to the LLM context and the request is retried. If the reprompt message is null, the original request with the same context.

      If isRetry() returns false, the reprompt message is ignored.

      Returns:
      the reprompt message, or null if the original request with the same context should be retried.