Class OutputGuardrailRequest
java.lang.Object
dev.langchain4j.guardrail.OutputGuardrailRequest
- All Implemented Interfaces:
GuardrailRequest<OutputGuardrailRequest>
public final class OutputGuardrailRequest
extends Object
implements GuardrailRequest<OutputGuardrailRequest>
Represents the parameter passed to
OutputGuardrail.validate(OutputGuardrailRequest).-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Creates a new builder forOutputGuardrailRequest.Returns the chat executor.Returns the request that was sent to the model to produceresponseFromLLM(), if known: when the response is the result of a tool-calling loop, the last request of the loop, whose messages include the tool calls and tool results of all rounds; when the model was asked again after a guardrail failure (reprompt), the request of that call, whose messages include the reprompt.Returns the common parameters that are shared across guardrail checks.Returns the response from the LLM.Recreate this guardrail param with the given input or output text.
-
Method Details
-
responseFromLLM
Returns the response from the LLM.- Returns:
- the response from the LLM
-
chatRequest
Returns the request that was sent to the model to produceresponseFromLLM(), if known: when the response is the result of a tool-calling loop, the last request of the loop, whose messages include the tool calls and tool results of all rounds; when the model was asked again after a guardrail failure (reprompt), the request of that call, whose messages include the reprompt. The request is not known, for example, when that call was made by aChatExecutorthat does not overrideChatExecutor.exchange(List).- Returns:
- the request, or
nullif it is not known - Since:
- 1.23.0
-
chatExecutor
-
requestParams
Returns the common parameters that are shared across guardrail checks.- Specified by:
requestParamsin interfaceGuardrailRequest<OutputGuardrailRequest>- Returns:
- an instance of
GuardrailRequestParamscontaining shared parameters
-
withText
Description copied from interface:GuardrailRequestRecreate this guardrail param with the given input or output text.- Specified by:
withTextin interfaceGuardrailRequest<OutputGuardrailRequest>- Parameters:
text- The text of the rewritten param.- Returns:
- A clone of this guardrail params with the given input or output text.
-
builder
Creates a new builder forOutputGuardrailRequest.- Returns:
- a new builder
-