分类器(Classifier)Node

class ClassifierNode @JvmOverloads constructor(name: String, val classifier: Classifier, val question: Question, threshold: Double? = null, val answerKey: String? = null, description: String = "", rerunOnResume: Boolean = false, waitForOutput: Boolean = false, config: NodeConfig = NodeConfig(), inputSchema: Schema? = null, outputSchema: Schema? = null, stateSchema: Schema? = null) : BaseNode

Routes a workflow by asking a classifier one question about the node's input and emitting the answer as the route: the chosen label of a Choice, or true or false for a Binary, decided by threshold. The output is the unchanged input, or the underlying value unwrapped from a ClassifierInput, so the routed-to node receives what the classifier saw.

When the node has routed outgoing edges, graph validation 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.

Parameters

threshold

For a Binary, the probability in [0, 1] at or above which the route is true, or null for 0.5. Setting it for a Choice is an error.

Throws

if name is empty or contains '/', '@', or '.'.

if question is a Score or uses Route.DEFAULT_ROUTE_SENTINEL, or if threshold is set on a Choice or lies outside [0, 1].

构造函数(Constructors)

Link copied to clipboard
constructor(name: String, classifier: Classifier, question: Question, threshold: Double? = null, answerKey: String? = null, description: String = "", rerunOnResume: Boolean = false, waitForOutput: Boolean = false, config: NodeConfig = NodeConfig(), inputSchema: Schema? = null, outputSchema: Schema? = null, stateSchema: Schema? = null)

类型

Link copied to clipboard
class Builder

Fluent Builder for ClassifierNode该功能主要为 Java 语言的调用者提供支持;如果某个属性未被设置,其值将默认使用构造函数中指定的默认值。

Link copied to clipboard
object Companion

属性(Properties)

Link copied to clipboard

该序列化数据存储的状态键(state key)…… 答案 以 JSON 映射的形式存储;或者 null 用于存储“没有任何数据”的情况。

Link copied to clipboard

The 分类器(Classifier) 这个回答正好符合要求。 问题.

Link copied to clipboard
open override val config: NodeConfig

该节点的重试策略以及执行超时设置。

Link copied to clipboard
open override val description: String

这个节点的作用是什么?对于人类来说,以及对于可能会调用它的模型来说,它的功能又是什么?

Link copied to clipboard
open override val inputSchema: Schema?

该节点会检查输入数据是否为 JSON 格式;如果节点没有明确指定其他要求,那么它就会接收经过验证后的数据(即已通过 JSON 格式检查的数据)。 Content当某个边的前驱(predecessor)的输出模式包含某些该边所拒绝接受的值时,该边就无法被正确构建。这种输出模式中存在的“不确定性”(例如:没有明确的类型定义、某些键未被声明、某些字段的属性未被描述等)会导致构建失败。 ARRAY (items)会在运行时进行检查。

Link copied to clipboard
override val name: String

用于在图中识别特定的节点。

Link copied to clipboard
open override val outputSchema: Schema?

该节点会使用相同的规则来验证其输出的数值;经过验证后的数值即为最终的输出结果。这个数值是通过某种方式(例如配置或编程)被设置的。 Context.setOutput “message-as-output”事件的内容也不会被检查。

Link copied to clipboard

The Choice (不使用……) Route.DEFAULT_ROUTE_SENTINEL) 或 二进制(Binary) “谁的答案会决定最终的路线(即选择哪条路径)?”

Link copied to clipboard
open override val requiresAllPredecessors: Boolean

该节点是否仅在所有前置节点完成执行并接收到它们各自输出的数据(这些数据均以节点名称作为键)之后才运行?如果该节点属于“扇入型”(fan-in)节点,那么其默认行为会被设置为“true”(即该节点会在所有前置节点完成执行后立即运行)。

Link copied to clipboard
open override val rerunOnResume: Boolean

简而言之,问题是:是否应该从头开始重新运行该节点,而不是使用“恢复”操作的结果作为最终输出来完成整个流程。

Link copied to clipboard
open override val stateSchema: Schema?

声明了该节点使用的状态键(state keys);包含冒号(:)的键不会被检查。子节点会继承这些状态键,除非它们自己声明了新的状态键。

Link copied to clipboard

“该事件发生的概率达到或超过……的概率值。” 二进制(Binary) routes true.

Link copied to clipboard
open override val waitForOutput: Boolean

该节点是否会在产生输出或找到路由之前一直保持可重新触发的状态(即不会在完成相应操作后立即停止工作)? runNode `returns`:这是一个永远不会产生任何结果的节点;如果它永远不产生任何结果,那么它就会永远处于“等待”状态,这属于图生成过程中的错误(即图生成算法的错误)。

函数

Link copied to clipboard
fun run(context: Context, nodeInput: Any?): Flow<Event>

运行该节点,并对每个原始排放数据(raw emission)进行标准化处理。 runNode 进入……状态;转变为……形式 事件: null 和 Unit 被跳过了;a RequestInput 成为 adk_request_input 中断事件(Interrupt Event)。 事件 保留了其内容,并且……(此处“has its”后应补充具体信息,但原文未提供。) output 如果输入的值被验证为有效(即符合预设的条件),那么该值就会被作为输出结果;否则,任何其他输入的值都会被作为输出结果。

Link copied to clipboard
open override fun runNode(context: Context, nodeInput: Any?): Flow<Any?>

对……进行分类;对……进行归类 nodeInput 然后通过指定的路由将该数据发送出去。如果发送过程中发生错误,会抛出异常(throws an exception)。 NodeExecutionException 如果输入内容不符合要求(即输入内容不是某种预期的格式或类型),则应执行相应的处理逻辑。 ClassifierInput`, text`:一个 JSON 对象或数组(作为参数)。 Map/List 或者 JsonElement),或 内容或者,如果答案缺失、被拒绝、被标记为“未知”,或者属于错误的数据类型。