Class FunctionNodes

java.lang.Object
com.google.adk.workflow.FunctionNodes

@Experimental public final class FunctionNodes extends Object
创建 FunctionNode每个端口都有一个对应的类型(type),形式如下: Class 或者,对于一个通用类型(如……)来说: List<Order>, a TypeReference可以读写(即可以进行数据的读取和写入操作)。 FunctionNode 该描述说明了节点的功能。节点的“主体部分”(即用于显示信息的区域)会向用户请求输入数据。 requestInput(String, String, Object, Schema).
  • 方法详细信息(Method Details)

    • of

      public static <I,O> FunctionNode<I,O> of(String name, Class<I> inputType, Class<O> outputType, NodeBody<? super I, ? extends O> body)
      返回一个名为……的节点。 name 那个可以运行的程序/系统…… body 在每次读取输入数据时…… inputType 并将自己的内容写入其中。 outputType 输出结果以 JSON 格式呈现。数据主体中可能包含事件信息;这些事件信息会首先被发送出来。 Context.emit(Event).
      Throws:
      WorkflowConfigurationException - if Jackson cannot read and write inputType or write outputType, or if a port type has no single concrete JSON shape or is an interface or abstract class without a Jackson creator, such as ZoneId; a field type Jackson cannot handle fails on the first value instead
    • of

      public static <I,O> FunctionNode<I,O> of(String name, com.fasterxml.jackson.core.type.TypeReference<I> inputType, com.fasterxml.jackson.core.type.TypeReference<O> outputType, NodeBody<? super I, ? extends O> body)
      喜欢 of(String, Class, Class, NodeBody)适用于所有通用的端口类型。
    • of

      public static <I,O> FunctionNode<I,O> of(String name, Class<I> inputType, com.fasterxml.jackson.core.type.TypeReference<O> outputType, NodeBody<? super I, ? extends O> body)
      喜欢 of(String, Class, Class, NodeBody)(用于表示通用输出类型。)
    • of

      public static <I,O> FunctionNode<I,O> of(String name, com.fasterxml.jackson.core.type.TypeReference<I> inputType, Class<O> outputType, NodeBody<? super I, ? extends O> body)
      喜欢 of(String, Class, Class, NodeBody)用于表示通用输入类型。
    • builder

      public static <I,O> FunctionNode.Builder<I,O> builder(Class<I> inputType, Class<O> outputType)
      返回一个用于创建节点的构建器(builder),该节点具有指定的端口类型(port types)及相关属性(properties)。 of(String, Class, Class, NodeBody) 不接受(该输入/参数)。
      Throws:
      WorkflowConfigurationException - as of(String, Class, Class, NodeBody) does
    • builder

      public static <I,O> FunctionNode.Builder<I,O> builder(com.fasterxml.jackson.core.type.TypeReference<I> inputType, com.fasterxml.jackson.core.type.TypeReference<O> outputType)
      喜欢 builder(Class, Class)适用于所有通用的端口类型。
    • builder

      public static <I,O> FunctionNode.Builder<I,O> builder(Class<I> inputType, com.fasterxml.jackson.core.type.TypeReference<O> outputType)
      喜欢 builder(Class, Class)(用于表示通用输出类型。)
    • builder

      public static <I,O> FunctionNode.Builder<I,O> builder(com.fasterxml.jackson.core.type.TypeReference<I> inputType, Class<O> outputType)
      喜欢 builder(Class, Class)用于表示通用输入类型。
    • requestInput

      public static <T> T requestInput(String interruptId, @Nullable String message, @Nullable Object payload, @Nullable com.google.genai.types.Schema responseSchema)
      该功能会向用户请求输入数据,但永远不会返回任何结果。除非该节点在恢复运行后被重新执行,否则用户输入的数据将无法被使用(即无法被任何程序或系统读取或处理)。 responseSchema该内容会成为节点的输出结果,但不会被当作节点的输出类型来处理;如果程序重新运行,相关代码段会再次被执行,此时只需要在适当的时候进行相应的处理即可。 ctx.resumeInputs() “缺乏答案”:
      if (!ctx.resumeInputs().containsKey("q")) {
        return FunctionNodes.requestInput("q", "How many?");
      }
      Object answer = ctx.resumeInputs().get("q");
      

      可以将其放在代码的主体部分(即 `body` 部分)中执行:它会通过抛出一个内部异常(internal exception)来终止代码的主体部分。 Error,其中 catch (Exception e) “让……通过”;“允许……进入” catch (Throwable t) stops.

      Parameters:
      interruptId - the ID the answer carries; keep it stable across reruns
      message - the text to show the user, or null
      payload - data for rendering the request, written in JSON form as a node output is, or null
      responseSchema - the schema the answer must match, or null
      Throws:
      IllegalArgumentException - if the payload has no JSON form
    • requestInput

      public static <T> T requestInput(String interruptId, @Nullable String message, @Nullable Object payload)
      喜欢 requestInput(String, String, Object, Schema)(该内容似乎是关于某种数据传输或通信协议的描述,其中提到了“response schema”这一术语,但后续内容并未提供关于该“schema”的具体信息。)
    • requestInput

      public static <T> T requestInput(String interruptId, @Nullable String message)
      喜欢 requestInput(String, String, Object, Schema)其中只包含一条消息。
    • requestInput

      public static <T> T requestInput(String interruptId)
      喜欢 requestInput(String, String, Object, Schema)既没有消息,也没有数据。
    • requestInput

      public static <T> T requestInput()
      喜欢 requestInput(String, String, Object, Schema)其中包含一个随机生成的中断ID(interrupt ID)。
    • requestInput

      public static <T> T requestInput(RequestInput request)
      喜欢 requestInput(String, String, Object, Schema)(用于说明某个组件或功能是如何被“内置”到系统中的) request.