Class DecisionModelOutputGuardrail.Builder
java.lang.Object
dev.langchain4j.guardrails.DecisionModelOutputGuardrail.Builder
- Enclosing class:
DecisionModelOutputGuardrail
- 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 instruction sent to the model when a response is rejected, to ask it for a new response.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"personalData".question- a yes/no question where "yes" means the response must be rejected, for example"Does the response reveal personal data?".
-
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 response 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 response. -
reprompt
Sets the instruction sent to the model when a response is rejected, to ask it for a new response. Optional: by default, a rejected response fails with a fatal result. -
build
-