Package com.google.genkit.ai
Class InterruptConfig<I,O>
java.lang.Object
com.google.genkit.ai.InterruptConfig<I,O>
- Type Parameters:
I- the input typeO- the output type (response type)
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();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for InterruptConfig. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <I,O> InterruptConfig.Builder <I, O> builder()Creates a new builder.Gets the description.Gets the input schema.Gets the input type class.getName()Gets the interrupt name.Gets the output schema.Gets the output type class.Gets the request metadata function.voidsetDescription(String description) Sets the description.voidsetInputSchema(Map<String, Object> inputSchema) Sets the input schema.voidsetInputType(Class<I> inputType) Sets the input type class.voidSets the interrupt name.voidsetOutputSchema(Map<String, Object> outputSchema) Sets the output schema.voidsetOutputType(Class<O> outputType) Sets the output type class.voidSets the request metadata function.
-
Constructor Details
-
InterruptConfig
public InterruptConfig()Default constructor.
-
-
Method Details
-
getName
Gets the interrupt name.- Returns:
- the name
-
setName
Sets the interrupt name.- Parameters:
name- the name
-
getDescription
Gets the description.- Returns:
- the description
-
setDescription
Sets the description.- Parameters:
description- the description
-
getInputType
Gets the input type class.- Returns:
- the input type class
-
setInputType
Sets the input type class.- Parameters:
inputType- the input type class
-
getOutputType
Gets the output type class.- Returns:
- the output type class
-
setOutputType
Sets the output type class.- Parameters:
outputType- the output type class
-
getInputSchema
Gets the input schema.- Returns:
- the input schema
-
setInputSchema
Sets the input schema.- Parameters:
inputSchema- the input schema
-
getOutputSchema
Gets the output schema.- Returns:
- the output schema
-
setOutputSchema
Sets the output schema.- Parameters:
outputSchema- the output schema
-
getRequestMetadata
Gets the request metadata function.- Returns:
- the request metadata function
-
setRequestMetadata
Sets the request metadata function.- Parameters:
requestMetadata- the request metadata function
-
builder
Creates a new builder.- Type Parameters:
I- the input typeO- the output type- Returns:
- a new builder
-