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.
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 TypeMethodDescriptiondefault InputGuardrailResult
Deprecated, for removal: This API element is subject to removal in a future version.default InputGuardrailResult
Deprecated, for removal: This API element is subject to removal in a future version.default InputGuardrailResult
Deprecated, for removal: This API element is subject to removal in a future version.default InputGuardrailResult
Deprecated, for removal: This API element is subject to removal in a future version.default InputGuardrailResult
success()
Deprecated, for removal: This API element is subject to removal in a future version.default InputGuardrailResult
successWith
(String successfulText) Deprecated, for removal: This API element is subject to removal in a future version.default InputGuardrailResult
validate
(dev.langchain4j.data.message.UserMessage userMessage) Deprecated, for removal: This API element is subject to removal in a future version.Validates theuser message
that will be sent to the LLM.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.
-
Method Details
-
validate
Deprecated, for removal: This API element is subject to removal in a future version.Validates theuser message
that will be sent to the LLM.- Parameters:
userMessage
- the response from the LLM
-
validate
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 interfaceGuardrail<InputGuardrailParams,
InputGuardrailResult> - Parameters:
params
- the parameters, including the user message, the memory (maybe null), and the augmentation result (maybe null). Cannot benull
- Returns:
- The result of this validation.
-
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
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
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
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
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
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.
-
InputGuardrail
instead