Class InterruptConfig<I,O>

java.lang.Object
com.google.genkit.ai.InterruptConfig<I,O>
Type Parameters:
I - the input type
O - the output type (response type)

public class InterruptConfig<I,O> extends Object
Configuration for defining an interrupt tool.

An interrupt is a special type of tool that pauses generation to request user input (human-in-the-loop pattern). When the model calls an interrupt tool, execution stops and the interrupt information is returned to the caller for handling.

Example usage:


 InterruptConfig<ConfirmInput, ConfirmOutput> config = InterruptConfig.<ConfirmInput, ConfirmOutput>builder()
 		.name("confirmAction").description("Ask user to confirm the action").inputType(ConfirmInput.class)
 		.outputType(ConfirmOutput.class).requestMetadata(input -> Map.of("action", input.getAction())).build();
 
  • Constructor Details

    • InterruptConfig

      public InterruptConfig()
      Default constructor.
  • Method Details

    • getName

      public String getName()
      Gets the interrupt name.
      Returns:
      the name
    • setName

      public void setName(String name)
      Sets the interrupt name.
      Parameters:
      name - the name
    • getDescription

      public String getDescription()
      Gets the description.
      Returns:
      the description
    • setDescription

      public void setDescription(String description)
      Sets the description.
      Parameters:
      description - the description
    • getInputType

      public Class<I> getInputType()
      Gets the input type class.
      Returns:
      the input type class
    • setInputType

      public void setInputType(Class<I> inputType)
      Sets the input type class.
      Parameters:
      inputType - the input type class
    • getOutputType

      public Class<O> getOutputType()
      Gets the output type class.
      Returns:
      the output type class
    • setOutputType

      public void setOutputType(Class<O> outputType)
      Sets the output type class.
      Parameters:
      outputType - the output type class
    • getInputSchema

      public Map<String,Object> getInputSchema()
      Gets the input schema.
      Returns:
      the input schema
    • setInputSchema

      public void setInputSchema(Map<String,Object> inputSchema)
      Sets the input schema.
      Parameters:
      inputSchema - the input schema
    • getOutputSchema

      public Map<String,Object> getOutputSchema()
      Gets the output schema.
      Returns:
      the output schema
    • setOutputSchema

      public void setOutputSchema(Map<String,Object> outputSchema)
      Sets the output schema.
      Parameters:
      outputSchema - the output schema
    • getRequestMetadata

      public Function<I,Map<String,Object>> getRequestMetadata()
      Gets the request metadata function.
      Returns:
      the request metadata function
    • setRequestMetadata

      public void setRequestMetadata(Function<I,Map<String,Object>> requestMetadata)
      Sets the request metadata function.
      Parameters:
      requestMetadata - the request metadata function
    • builder

      public static <I, O> InterruptConfig.Builder<I,O> builder()
      Creates a new builder.
      Type Parameters:
      I - the input type
      O - the output type
      Returns:
      a new builder