Enum Class RunConfig.ToolExecutionMode

java.lang.Object
java.lang.Enum<RunConfig.ToolExecutionMode>
com.google.adk.agents.RunConfig.ToolExecutionMode
All Implemented Interfaces:
Serializable, Comparable<RunConfig.ToolExecutionMode>, Constable
Enclosing class:
RunConfig

public static enum RunConfig.ToolExecutionMode extends Enum<RunConfig.ToolExecutionMode>
当模型请求使用多个工具时,应采用的执行模式。

NONE:默认值为 PARALLEL。

**SEQUENTIAL(顺序执行模式):** 这些工具会严格按照请求的顺序在调用者的线程上执行;每个工具都必须完成自己的任务(包括所有异步操作),才能让下一个工具开始执行。

**PARALLEL:** 所有相关工具都会在调用线程上被立即启动(即所有工具都会同时开始执行),但不会创建任何额外的工作线程。那些真正具有异步特性的工具(例如那些在完成处理后才会返回结果的工具)也会在调用线程上被立即执行。 Single 由 I/O 操作或其他调度器支持的进程将同时运行;而那些会阻塞订阅线程的工具(例如……)则会影响进程的并发执行。 Single.fromCallable (即那些执行阻塞性操作的任务)仍然会按顺序执行。这保持了系统原有的默认行为。

PARALLEL_SUBSCRIBE: 类似于 PARALLEL不过,每个工具都会被分配到一个单独的工作线程(worker thread)上运行;因此,即使某些工具需要阻塞操作,它们也能与其他工具同时执行。工具的实现必须具备线程安全性(thread-safe)。当设置了“worker”参数时,该线程就成为了代理(agent)的执行器;否则,调用任务的调度器(scheduler)将负责执行相关操作。Runner.Builder#scheduler默认情况下,使用的是 RxJava 的 IO 调度器。

  • 枚举常量详细信息

  • 方法详细信息(Method Details)

    • values

      public static RunConfig.ToolExecutionMode[] values()
      返回一个数组,其中包含该枚举类中的所有常量,并按照它们被声明的顺序排列。
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static RunConfig.ToolExecutionMode valueOf(String name)
      返回该类中具有指定名称的枚举常量。 该字符串必须与指定的名称完全匹配。 确切地;准确地 这是一个用于在该类中声明枚举常量的标识符。(不允许使用多余的空白字符。)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null