Interface ToolGuardrailService.Builder

Enclosing interface:
ToolGuardrailService

@Experimental public static interface ToolGuardrailService.Builder
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 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 - if config is 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 - if config is 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 be null.
      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 be null.
      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 be null.
      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 be null.
      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 be null.
      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 be null.
      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 be null.
      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 be null.
      Returns:
      This builder.
    • build

      Builds the service.
      Returns:
      The service, configured with the guardrails and the configurations the builder was given.