Interface ToolGuardrailService.Builder
- Enclosing interface:
ToolGuardrailService
Builds a
ToolGuardrailService. The guardrails and the guardrail classes it is given apply to every tool;
the input ones run first and the output ones last (see ToolGuardrailService). The configurations apply
to the executors of every tool.
Setting guardrails, or guardrail classes, replaces what was set before, and null clears them.- Since:
- 1.25.0
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the service.default <I extends ToolInputGuardrail>
ToolGuardrailService.BuilderinputGuardrailClasses(Class<? extends I>... guardrailClasses) Sets the classes of the input guardrails that apply to every tool, replacing the ones set before.<I extends ToolInputGuardrail>
ToolGuardrailService.BuilderinputGuardrailClasses(@Nullable List<Class<? extends I>> guardrailClasses) Sets the classes of the input guardrails that apply to every tool, replacing the ones set before.default <I extends ToolInputGuardrail>
ToolGuardrailService.BuilderinputGuardrails(I... guardrails) Sets the input guardrails that apply to every tool, replacing the ones set before.<I extends ToolInputGuardrail>
ToolGuardrailService.BuilderinputGuardrails(@Nullable List<I> guardrails) Sets the input guardrails that apply to every tool, replacing the ones set before.Configures the input guardrails of every tool.default <O extends ToolOutputGuardrail>
ToolGuardrailService.BuilderoutputGuardrailClasses(Class<? extends O>... guardrailClasses) Sets the classes of the output guardrails that apply to every tool, replacing the ones set before.<O extends ToolOutputGuardrail>
ToolGuardrailService.BuilderoutputGuardrailClasses(@Nullable List<Class<? extends O>> guardrailClasses) Sets the classes of the output guardrails that apply to every tool, replacing the ones set before.<O extends ToolOutputGuardrail>
ToolGuardrailService.BuilderoutputGuardrails(@Nullable List<O> guardrails) Sets the output guardrails that apply to every tool, replacing the ones set before.default <O extends ToolOutputGuardrail>
ToolGuardrailService.BuilderoutputGuardrails(O... guardrails) Sets the output guardrails that apply to every tool, replacing the ones set before.Configures the output guardrails of every tool.
-
Method Details
-
inputGuardrailsConfig
Configures the input guardrails of every tool.- Parameters:
config- The configuration for the input guardrails. Must not be null.- Returns:
- This builder.
- Throws:
IllegalArgumentException- ifconfigis null.
-
outputGuardrailsConfig
Configures the output guardrails of every tool.- Parameters:
config- The configuration for the output guardrails. Must not be null.- Returns:
- This builder.
- Throws:
IllegalArgumentException- ifconfigis null.
-
inputGuardrailClasses
<I extends ToolInputGuardrail> ToolGuardrailService.Builder inputGuardrailClasses(@Nullable List<Class<? extends I>> guardrailClasses) Sets the classes of the input guardrails that apply to every tool, replacing the ones set before.- Type Parameters:
I- The type of the input guardrails- Parameters:
guardrailClasses- The classes of the input guardrails. May benull.- Returns:
- This builder.
-
inputGuardrailClasses
default <I extends ToolInputGuardrail> ToolGuardrailService.Builder inputGuardrailClasses(Class<? extends I>... guardrailClasses) Sets the classes of the input guardrails that apply to every tool, replacing the ones set before.- Type Parameters:
I- The type of the input guardrails- Parameters:
guardrailClasses- The classes of the input guardrails. May benull.- Returns:
- This builder.
-
outputGuardrailClasses
<O extends ToolOutputGuardrail> ToolGuardrailService.Builder outputGuardrailClasses(@Nullable List<Class<? extends O>> guardrailClasses) Sets the classes of the output guardrails that apply to every tool, replacing the ones set before.- Type Parameters:
O- The type of the output guardrails- Parameters:
guardrailClasses- The classes of the output guardrails. May benull.- Returns:
- This builder.
-
outputGuardrailClasses
default <O extends ToolOutputGuardrail> ToolGuardrailService.Builder outputGuardrailClasses(Class<? extends O>... guardrailClasses) Sets the classes of the output guardrails that apply to every tool, replacing the ones set before.- Type Parameters:
O- The type of the output guardrails- Parameters:
guardrailClasses- The classes of the output guardrails. May benull.- Returns:
- This builder.
-
inputGuardrails
<I extends ToolInputGuardrail> ToolGuardrailService.Builder inputGuardrails(@Nullable List<I> guardrails) Sets the input guardrails that apply to every tool, replacing the ones set before.- Type Parameters:
I- The type of the input guardrails- Parameters:
guardrails- The input guardrails. May benull.- Returns:
- This builder.
-
inputGuardrails
default <I extends ToolInputGuardrail> ToolGuardrailService.Builder inputGuardrails(I... guardrails) Sets the input guardrails that apply to every tool, replacing the ones set before.- Type Parameters:
I- The type of the input guardrails- Parameters:
guardrails- The input guardrails. May benull.- Returns:
- This builder.
-
outputGuardrails
<O extends ToolOutputGuardrail> ToolGuardrailService.Builder outputGuardrails(@Nullable List<O> guardrails) Sets the output guardrails that apply to every tool, replacing the ones set before.- Type Parameters:
O- The type of the output guardrails- Parameters:
guardrails- The output guardrails. May benull.- Returns:
- This builder.
-
outputGuardrails
default <O extends ToolOutputGuardrail> ToolGuardrailService.Builder outputGuardrails(O... guardrails) Sets the output guardrails that apply to every tool, replacing the ones set before.- Type Parameters:
O- The type of the output guardrails- Parameters:
guardrails- The output guardrails. May benull.- Returns:
- This builder.
-
build
ToolGuardrailService build()Builds the service.- Returns:
- The service, configured with the guardrails and the configurations the builder was given.
-