Package dev.langchain4j.guardrail
@Experimental
package dev.langchain4j.guardrail
-
ClassDescriptionAbstractGuardrailExecutor<C extends GuardrailsConfig, P extends GuardrailRequest<P>, R extends GuardrailResult<R>, G extends Guardrail<P,
R>, E extends GuardrailExecutedEvent<P, R, G>, F extends GuardrailResult.Failure> Abstract base class forGuardrailExecutors.AbstractGuardrailExecutor.GuardrailExecutorBuilder<C extends GuardrailsConfig, R extends GuardrailResult<R>, P extends GuardrailRequest<P>, G extends Guardrail<P,R>, E extends GuardrailExecutedEvent<P, R, G>, B extends AbstractGuardrailExecutor.GuardrailExecutorBuilder<C, R, P, G, E, B>> A generic abstract builder class for creating instances ofGuardrailExecutor.AbstractToolGuardrailExecutor<C extends GuardrailsConfig, P extends GuardrailRequest<P>, R extends GuardrailResult<R>, G extends Guardrail<P,R>, E extends GuardrailExecutedEvent<P, R, G>, F extends GuardrailResult.Failure> Base class of theGuardrailExecutors of tool guardrails, which share the same semantics: the guardrails run once, with no retry or reprompt; a non-fatal failure does not stop the chain and is returned, not thrown, so that the caller can turn it into an error tool result; a fatal failure stops the chain and is thrown (async: fails the future) as theGuardrailExceptioncreated byAbstractGuardrailExecutor.createGuardrailException(String, Throwable), which names the tool in its message and carries the tool call it stopped (toolExecutionRequest()).Generic executor interface that defines a chat interactionChatExecutor.AbstractBuilder<T extends ChatExecutor.AbstractBuilder<T>>An abstract base-builder class for constructing instances ofChatExecutor.StreamingToSynchronousBuilder for constructing instances ofChatExecutor.SynchronousBuilder for constructing instances ofChatExecutor.A guardrail is a rule that is applied when interacting with an LLM: to the input (the user message), to the output of the model, or to the calls of tools and their results, to ensure that they are safe and meet expectations.Exception thrown when an input, output, tool input or tool output guardrail validation fails.GuardrailExecutor<C extends GuardrailsConfig, P extends GuardrailRequest<P>, R extends GuardrailResult<R>, G extends Guardrail<P,R>, E extends GuardrailExecutedEvent<P, R, G>> Represents a mechanism to execute a set of guardrails on given parameters.GuardrailRequest<P extends GuardrailRequest<P>>Represents the parameter passed toGuardrail.validate(GuardrailRequest)} in order to validate an interaction between a user and the LLM, or a tool interaction (tool input before execution, tool output after).Represents the common parameters shared across guardrail checks when validating interactions between a user and a language model.Builder forGuardrailRequestParams.GuardrailResult<GR extends GuardrailResult<GR>>The result of the validation of an interaction between a user and the LLM.The message and the cause of the failure of a single validation.The possible results of a guardrails validation.An input guardrail is a rule that is applied to the input of the model to ensure that the input (i.e. the user message and parameters) is safe and meets the expectations of the model.Exception thrown when an input guardrail validation fails.TheGuardrailExecutorforInputGuardrails.Builder class for constructing instances ofInputGuardrailExecutor.Represents the parameter passed toInputGuardrail.validate(InputGuardrailRequest).Builder forInputGuardrailRequest.The result of the validation of anInputGuardrailRepresents an input guardrail failureAn output guardrail is a rule that is applied to the output of the model to ensure that the output is safe and meets the expectations.Exception thrown when an output guardrail validation fails.TheGuardrailExecutorforOutputGuardrails.Builder class for constructing instances ofOutputGuardrailExecutor.Represents the parameter passed toOutputGuardrail.validate(OutputGuardrailRequest).Builder forOutputGuardrailRequest.The result of the validation of anOutputGuardrailA tool input guardrail is a rule applied before a tool is executed, to validate or rewrite the arguments the LLM chose.Exception thrown when a fatalToolInputGuardrailfailure aborts the AI service invocation.TheGuardrailExecutorforToolInputGuardrails.Builder class for constructing instances ofToolInputGuardrailExecutor.Represents the parameter passed to a tool input guardrail, before a tool is executed.Builder forToolInputGuardrailRequest.The result of the validation of aToolInputGuardrail.Represents a tool input guardrail failure.A tool output guardrail is a rule applied after a tool was executed, to validate or rewrite the result before the LLM sees it.Exception thrown when a fatalToolOutputGuardrailfailure aborts the AI service invocation.TheGuardrailExecutorforToolOutputGuardrails.Builder class for constructing instances ofToolOutputGuardrailExecutor.Represents the parameter passed to a tool output guardrail, after a tool has been executed.Builder forToolOutputGuardrailRequest.The result of the validation of aToolOutputGuardrail.Represents a tool output guardrail failure.