Class ClassifierNode
java.lang.Object
com.google.adk.workflow.BaseNode
com.google.adk.classifiers.ClassifierNode
- All Implemented Interfaces:
Node
A workflow node that routes on a classifier's answer to one question about the node's input: the
label a
Question.Choice answer chose, or true or false for a Question.Binary answer, decided by threshold(). The node's output is its unchanged
input, so the node it routes to receives what the classifier saw.
If the node has routed outgoing edges, building the workflow checks that every route is a possible answer and that every possible answer has an edge, unless a default or unconditional edge catches the rest.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionReturns the state key under which the node stores the answer, in its JSON form as a map, if set.static ClassifierNode.Builderbuilder()Returns the classifier that answersquestion().question()Returns theQuestion.ChoiceorQuestion.Binaryquestion whose answer picks the route.io.reactivex.rxjava3.core.Flowable<?> ClassifiesnodeInputand outputs it with the route.doubleReturns the probability at or above which aQuestion.Binaryquestion routestrue.protected voidvalidateOutgoingEdges(Collection<Edge> edges) ThrowsGraphValidationExceptionif this node cannot serve theedgesthat leave it, such as an edge for a route it never emits.Methods inherited from class BaseNode
config, description, inputSchema, name, outputSchema, rerunOnResume, stateSchema, waitForOutputModifier and TypeMethodDescriptionconfig()Returns the node's retry policy and execution timeout.Returns what the node does, for humans and for a model that may call it.Optional<com.google.genai.types.Schema> Returns the schema the node's input must match.final Stringname()Returns the name that identifies the node within its graph.Optional<com.google.genai.types.Schema> Returns the schema that the node's output value must match.booleanReturnstrueif a resumed node runs again from scratch, rather than completing with the resuming answer as its output.Optional<com.google.genai.types.Schema> Returns the schema declaring the state keys the node uses.booleanReturnstrueif the node stays re-triggerable until it produces an output or a route, instead of completing when its run completes.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Node
requiresAllPredecessorsModifier and TypeMethodDescriptiondefault booleanReturnstrueif the node runs only once every predecessor has completed, receiving all their outputs keyed by node name, as a fan-in node does.
-
Method Details
-
builder
-
classifier
Returns the classifier that answersquestion(). -
question
Returns theQuestion.ChoiceorQuestion.Binaryquestion whose answer picks the route. -
threshold
public double threshold()Returns the probability at or above which aQuestion.Binaryquestion routestrue. -
answerKey
-
runNode
ClassifiesnodeInputand outputs it with the route. Fails withNodeInputValidationExceptionif the input is missing or not a kind the node can classify, and withWorkflowDataExceptionif the answer is missing, a refusal, a label outside the question's labels, or of the wrong type. -
validateOutgoingEdges
Description copied from class:BaseNodeThrowsGraphValidationExceptionif this node cannot serve theedgesthat leave it, such as an edge for a route it never emits. The default accepts any edges. Building the workflow graph calls it after its own checks.- Overrides:
validateOutgoingEdgesin classBaseNode
-