Class ClassifierNode

java.lang.Object
com.google.adk.workflow.BaseNode
com.google.adk.classifiers.ClassifierNode
All Implemented Interfaces:
Node

@Experimental public final class ClassifierNode extends BaseNode
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.

  • Method Details

    • builder

      public static ClassifierNode.Builder builder()
    • classifier

      public Classifier classifier()
      Returns the classifier that answers question().
    • question

      public Question question()
      Returns the Question.Choice or Question.Binary question whose answer picks the route.
    • threshold

      public double threshold()
      Returns the probability at or above which a Question.Binary question routes true.
    • answerKey

      public Optional<String> answerKey()
      Returns the state key under which the node stores the answer, in its JSON form as a map, if set.
    • runNode

      public io.reactivex.rxjava3.core.Flowable<?> runNode(Context context, @Nullable Object nodeInput)
      Classifies nodeInput and outputs it with the route. Fails with NodeInputValidationException if the input is missing or not a kind the node can classify, and with WorkflowDataException if the answer is missing, a refusal, a label outside the question's labels, or of the wrong type.
    • validateOutgoingEdges

      protected void validateOutgoingEdges(Collection<Edge> edges)
      Description copied from class: BaseNode
      Throws GraphValidationException if this node cannot serve the edges that 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:
      validateOutgoingEdges in class BaseNode