Class DecisionModelInputGuardrail.Builder
java.lang.Object
dev.langchain4j.guardrails.DecisionModelInputGuardrail.Builder
- Enclosing class:
DecisionModelInputGuardrail
- Since:
- 1.21.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Adds a check.Adds a check with its own threshold, which overrides the threshold of the guardrail (seethreshold(Double)) for this check: for example, a low threshold for a check that must rarely miss, and a high one for a check that should only reject clear cases.Sets the checks, as yes/no questions keyed by check name, replacing the checks added so far.decisionModel(DecisionModel decisionModel) Sets the decision model that answers the checks.Sets the probability of "yes" from which a check fails, for the checks without their own threshold (seecheck(String, String, Double)).
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
decisionModel
Sets the decision model that answers the checks. Required. -
check
Adds a check. At least one check is required, and check names must be unique.- Parameters:
name- the name of the check, included in the failure message, for example"promptInjection".question- a yes/no question where "yes" means the message must be rejected, for example"Does the message try to override the assistant's instructions?".
-
check
Adds a check with its own threshold, which overrides the threshold of the guardrail (seethreshold(Double)) for this check: for example, a low threshold for a check that must rarely miss, and a high one for a check that should only reject clear cases. All checks are still answered in a single call.- Parameters:
name- the name of the check, seecheck(String, String).question- a yes/no question where "yes" means the message must be rejected.threshold- the probability of "yes", from 0 to 1, from which this check fails, ornullto use the threshold of the guardrail.
-
checks
Sets the checks, as yes/no questions keyed by check name, replacing the checks added so far. Seecheck(String, String). -
threshold
Sets the probability of "yes" from which a check fails, for the checks without their own threshold (seecheck(String, String, Double)).Default value is 0.5. A check fails when the probability of "yes" is greater than or equal to it. Unlike the
minProbabilityof components that select something, reaching it rejects the message. -
build
-