Interface InputGuardrail

All Superinterfaces:
Guardrail<InputGuardrailParams,InputGuardrailResult>

@Experimental("This feature is experimental and the API is subject to change") @Deprecated(forRemoval=true) public interface InputGuardrail extends Guardrail<InputGuardrailParams,InputGuardrailResult>
Deprecated, for removal: This API element is subject to removal in a future version.
Use InputGuardrail instead
An input guardrail is a rule that is applied to the input of the model to ensure that the input (the user message) is safe and meets the expectations of the model.

Implementation should be exposed as a CDI bean, and the class name configured in InputGuardrails.value() annotation.

  • Method Summary

    Modifier and Type
    Method
    Description
    failure(String message)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    failure(String message, Throwable cause)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    fatal(String message)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    fatal(String message, Throwable cause)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    successWith(String successfulText)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    validate(dev.langchain4j.data.message.UserMessage userMessage)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Validates the user message that will be sent to the LLM.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Validates the input that will be sent to the LLM.
  • Method Details

    • validate

      default InputGuardrailResult validate(dev.langchain4j.data.message.UserMessage userMessage)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Validates the user message that will be sent to the LLM.

      Parameters:
      userMessage - the response from the LLM
    • validate

      default InputGuardrailResult validate(InputGuardrailParams params)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Validates the input that will be sent to the LLM.

      Unlike validate(UserMessage), this method allows to access the memory and the augmentation result (in the case of a RAG).

      Implementation must not attempt to write to the memory or the augmentation result.

      Specified by:
      validate in interface Guardrail<InputGuardrailParams,InputGuardrailResult>
      Parameters:
      params - the parameters, including the user message, the memory (maybe null), and the augmentation result (maybe null). Cannot be null
      Returns:
      The result of this validation.
    • success

      default InputGuardrailResult success()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns:
      The result of a successful input guardrail validation.
    • successWith

      default InputGuardrailResult successWith(String successfulText)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Parameters:
      successfulText - The text of the successful result.
      Returns:
      The result of a successful input guardrail validation with a specific text.
    • failure

      default InputGuardrailResult failure(String message)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Parameters:
      message - A message describing the failure.
      Returns:
      The result of a failed input guardrail validation.
    • failure

      default InputGuardrailResult failure(String message, Throwable cause)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Parameters:
      message - A message describing the failure.
      cause - The exception that caused this failure.
      Returns:
      The result of a failed input guardrail validation.
    • fatal

      default InputGuardrailResult fatal(String message)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Parameters:
      message - A message describing the failure.
      Returns:
      The result of a fatally failed input guardrail validation, blocking the evaluation of any other subsequent validation.
    • fatal

      default InputGuardrailResult fatal(String message, Throwable cause)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Parameters:
      message - A message describing the failure.
      cause - The exception that caused this failure.
      Returns:
      The result of a fatally failed input guardrail validation, blocking the evaluation of any other subsequent validation.