Package com.google.genkit.ai
Class Indexer
java.lang.Object
com.google.genkit.ai.Indexer
- All Implemented Interfaces:
Action<IndexerRequest,,IndexerResponse, Void> Registerable
Indexer is an action that indexes documents into a vector store.
Indexers are used for RAG (Retrieval Augmented Generation) workflows to store
documents that can later be retrieved.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionIndexer(String name, BiFunction<ActionContext, IndexerRequest, IndexerResponse> handler) Creates a new Indexer. -
Method Summary
Modifier and TypeMethodDescriptionstatic Indexer.Builderbuilder()Creates a builder for Indexer.getDesc()Returns the descriptor of the action containing metadata, schemas, etc.Returns the JSON schema for the action's input type.Returns additional metadata for the action.getName()Returns the name of the action.Returns the JSON schema for the action's output type.getType()Returns the type of the action.voidRegisters this primitive with the given registry.run(ActionContext ctx, IndexerRequest input) Runs the action with the given input.run(ActionContext ctx, IndexerRequest input, Consumer<Void> streamCallback) Runs the action with the given input and streaming callback.com.fasterxml.jackson.databind.JsonNoderunJson(ActionContext ctx, com.fasterxml.jackson.databind.JsonNode input, Consumer<com.fasterxml.jackson.databind.JsonNode> streamCallback) Runs the action with JSON input and returns JSON output.ActionRunResult<com.fasterxml.jackson.databind.JsonNode> runJsonWithTelemetry(ActionContext ctx, com.fasterxml.jackson.databind.JsonNode input, Consumer<com.fasterxml.jackson.databind.JsonNode> streamCallback) Runs the action with JSON input and returns the result with telemetry information.
-
Constructor Details
-
Indexer
Creates a new Indexer.- Parameters:
name- the indexer namehandler- the indexing function
-
-
Method Details
-
builder
Creates a builder for Indexer.- Returns:
- a new builder
-
getName
Description copied from interface:ActionReturns the name of the action.- Specified by:
getNamein interfaceAction<IndexerRequest,IndexerResponse, Void> - Returns:
- the action name
-
getType
Description copied from interface:ActionReturns the type of the action.- Specified by:
getTypein interfaceAction<IndexerRequest,IndexerResponse, Void> - Returns:
- the action type
-
getDesc
Description copied from interface:ActionReturns the descriptor of the action containing metadata, schemas, etc.- Specified by:
getDescin interfaceAction<IndexerRequest,IndexerResponse, Void> - Returns:
- the action descriptor
-
run
Description copied from interface:ActionRuns the action with the given input.- Specified by:
runin interfaceAction<IndexerRequest,IndexerResponse, Void> - Parameters:
ctx- the action contextinput- the input to the action- Returns:
- the output of the action
- Throws:
GenkitException- if the action fails
-
run
public IndexerResponse run(ActionContext ctx, IndexerRequest input, Consumer<Void> streamCallback) throws GenkitException Description copied from interface:ActionRuns the action with the given input and streaming callback.- Specified by:
runin interfaceAction<IndexerRequest,IndexerResponse, Void> - Parameters:
ctx- the action contextinput- the input to the actionstreamCallback- callback for receiving streaming chunks, may be null- Returns:
- the output of the action
- Throws:
GenkitException- if the action fails
-
runJson
public com.fasterxml.jackson.databind.JsonNode runJson(ActionContext ctx, com.fasterxml.jackson.databind.JsonNode input, Consumer<com.fasterxml.jackson.databind.JsonNode> streamCallback) throws GenkitException Description copied from interface:ActionRuns the action with JSON input and returns JSON output.- Specified by:
runJsonin interfaceAction<IndexerRequest,IndexerResponse, Void> - Parameters:
ctx- the action contextinput- the JSON inputstreamCallback- callback for receiving streaming JSON chunks, may be null- Returns:
- the JSON output
- Throws:
GenkitException- if the action fails
-
runJsonWithTelemetry
public ActionRunResult<com.fasterxml.jackson.databind.JsonNode> runJsonWithTelemetry(ActionContext ctx, com.fasterxml.jackson.databind.JsonNode input, Consumer<com.fasterxml.jackson.databind.JsonNode> streamCallback) throws GenkitException Description copied from interface:ActionRuns the action with JSON input and returns the result with telemetry information.- Specified by:
runJsonWithTelemetryin interfaceAction<IndexerRequest,IndexerResponse, Void> - Parameters:
ctx- the action contextinput- the JSON inputstreamCallback- callback for receiving streaming JSON chunks, may be null- Returns:
- the action result including telemetry data
- Throws:
GenkitException- if the action fails
-
getInputSchema
Description copied from interface:ActionReturns the JSON schema for the action's input type.- Specified by:
getInputSchemain interfaceAction<IndexerRequest,IndexerResponse, Void> - Returns:
- the input schema as a map, or null if not defined
-
getOutputSchema
Description copied from interface:ActionReturns the JSON schema for the action's output type.- Specified by:
getOutputSchemain interfaceAction<IndexerRequest,IndexerResponse, Void> - Returns:
- the output schema as a map, or null if not defined
-
getMetadata
Description copied from interface:ActionReturns additional metadata for the action.- Specified by:
getMetadatain interfaceAction<IndexerRequest,IndexerResponse, Void> - Returns:
- the metadata map
-
register
Description copied from interface:RegisterableRegisters this primitive with the given registry.- Specified by:
registerin interfaceRegisterable- Parameters:
registry- the registry to register with
-