`LlmAgent` 类

All Implemented Interfaces:
Node

public class LlmAgent extends BaseAgent
这个基于大型语言模型(LLM)的智能代理。
  • 构造函数详细信息

  • 方法详细信息(Method Details)

    • builder

      public static LlmAgent.Builder builder()
      返回一个 LlmAgent.Builder for LlmAgent.
    • determineLlmFlow

      protected BaseLlmFlow determineLlmFlow()
    • runAsyncImpl

      protected io.reactivex.rxjava3.core.Flowable<Event> runAsyncImpl(InvocationContext invocationContext)
      描述内容复制自相关类: BaseAgent
      与特定代理(Agent)相关的异步逻辑(Agent-specific asynchronous logic)。
      Specified by:
      runAsyncImpl in class BaseAgent
      Parameters:
      invocationContext - Current invocation context.
      Returns:
      stream of agent-generated events.
    • runNode

      @Experimental public io.reactivex.rxjava3.core.Flowable<Event> runNode(Context context, @Nullable Object nodeInput)
      将此代理作为工作流节点来运行。 AgentMode.SINGLE_TURN 代理无法查看任何历史记录(即没有相关的数据或信息),除非…… LlmAgent.Builder.includeContents 该节点被设置为“用户轮次”(即当前轮次由用户控制),会接收用户的输入作为输入数据,并将其生成的第一个最终模型结果作为输出结果。如果没有指定具体的“模式”(mode),该代理会以默认方式运行。 BaseAgent.runNode(Context, Object) 然后运行它。
      Specified by:
      runNode in interface Node
      Overrides:
      runNode in class BaseAgent
    • runLiveImpl

      protected io.reactivex.rxjava3.core.Flowable<Event> runLiveImpl(InvocationContext invocationContext)
      描述内容复制自相关类: BaseAgent
      与特定代理相关的同步逻辑(Agent-specific synchronous logic)。
      Specified by:
      runLiveImpl in class BaseAgent
      Parameters:
      invocationContext - Current invocation context.
      Returns:
      stream of agent-generated events.
    • canonicalInstruction

      public io.reactivex.rxjava3.core.Single<Map.Entry<String,Boolean>> canonicalInstruction(ReadonlyContext context)
      根据……为该代理构建文本指令。 instruction 该字段还会返回一个布尔值,用于指示在构建相关指令时是否应跳过状态注入(state injection)操作。 Instruction.Provider.

      此方法仅适用于代理开发工具包(Agent Development Kit)。

      Parameters:
      context - The context to retrieve the session state.
      Returns:
      The resolved instruction as a Single wrapped Map.Entry. The key is the instruction string and the value is a boolean indicating if state injection should be bypassed.
    • canonicalGlobalInstruction

      public io.reactivex.rxjava3.core.Single<Map.Entry<String,Boolean>> canonicalGlobalInstruction(ReadonlyContext context)
      根据……为该代理构建全局文本指令。 globalInstruction 该字段还会返回一个布尔值,用于指示在构建相关指令时是否应跳过状态注入(state injection)机制。 Instruction.Provider.

      此方法仅适用于代理开发工具包(Agent Development Kit)。

      Parameters:
      context - The context to retrieve the session state.
      Returns:
      The resolved global instruction as a Single wrapped Map.Entry. The key is the instruction string and the value is a boolean indicating if state injection should be bypassed.
    • canonicalTools

      public io.reactivex.rxjava3.core.Flowable<BaseTool> canonicalTools()
      根据……构建该代理所需的工具列表。 tools() `field`。
      Returns:
      The resolved list of tools as a Single wrapped list of BaseTool.
    • canonicalTools

      public io.reactivex.rxjava3.core.Flowable<BaseTool> canonicalTools(@Nullable ReadonlyContext context)
      根据……构建该代理所需的工具列表。 tools() `field`。
      Parameters:
      context - The context to retrieve the session state.
      Returns:
      The resolved list of tools as a Single wrapped list of BaseTool.
    • instruction

      public Instruction instruction()
    • globalInstruction

      public Instruction globalInstruction()
    • model

      public Optional<Model> model()
    • planning

      public boolean planning()
    • maxSteps

      public Optional<Integer> maxSteps()
    • generateContentConfig

      public Optional<com.google.genai.types.GenerateContentConfig> generateContentConfig()
    • includeContents

      public LlmAgent.IncludeContents includeContents()
      返回已配置的历史记录设置。 LlmAgent.IncludeContents.DEFAULT 当该属性未被设置时(即其值为 `undefined` 时),系统会使用默认值 “A”。 SINGLE_TURN 工作流节点会覆盖那些尚未被设置的属性/值;详情请参见…… includeContentsExplicit().
    • includeContentsExplicit

      @Experimental public boolean includeContentsExplicit()
      返回一个布尔值,表示是否…… LlmAgent.Builder.includeContents(IncludeContents) 该值已被设置为 “a”。 SINGLE_TURN 工作流节点会使用该选项,而不是在没有任何记录(即“历史数据”)的情况下直接运行程序。

      此方法仅适用于代理开发工具包(Agent Development Kit)。

    • mode

      该参数用于指示该代理在作为工作流节点运行时的对话方式;如果没有指定具体的对话模式,则返回空值。
    • tools

      public io.reactivex.rxjava3.core.Single<List<BaseTool>> tools()
    • toolsUnion

      public List<Object> toolsUnion()
    • toolsets

      public List<BaseToolset> toolsets()
    • disallowTransferToParent

      public boolean disallowTransferToParent()
    • disallowTransferToPeers

      public boolean disallowTransferToPeers()
    • beforeModelCallback

      public List<? extends Callbacks.BeforeModelCallback> beforeModelCallback()
    • afterModelCallback

      public List<? extends Callbacks.AfterModelCallback> afterModelCallback()
    • beforeToolCallback

      public List<? extends Callbacks.BeforeToolCallback> beforeToolCallback()
    • afterToolCallback

      public List<? extends Callbacks.AfterToolCallback> afterToolCallback()
    • onModelErrorCallback

      public List<? extends Callbacks.OnModelErrorCallback> onModelErrorCallback()
    • onToolErrorCallback

      public List<? extends Callbacks.OnToolErrorCallback> onToolErrorCallback()
    • canonicalBeforeModelCallbacks

      public List<? extends Callbacks.BeforeModelCallback> canonicalBeforeModelCallbacks()
      `beforeModelCallback` 字段的解析结果以列表的形式返回。

      此方法仅适用于代理开发工具包(Agent Development Kit)。

    • canonicalAfterModelCallbacks

      public List<? extends Callbacks.AfterModelCallback> canonicalAfterModelCallbacks()
      `afterModelCallback` 字段的返回值是一个列表。

      此方法仅适用于代理开发工具包(Agent Development Kit)。

    • canonicalOnModelErrorCallbacks

      public List<? extends Callbacks.OnModelErrorCallback> canonicalOnModelErrorCallbacks()
      `modelErrorCallback` 字段的值被解析为一个列表。

      此方法仅适用于代理开发工具包(Agent Development Kit)。

    • canonicalBeforeToolCallbacks

      public List<? extends Callbacks.BeforeToolCallback> canonicalBeforeToolCallbacks()
      `beforeToolCallback` 字段的解析结果以列表的形式返回。

      此方法仅适用于代理开发工具包(Agent Development Kit)。

    • canonicalAfterToolCallbacks

      public List<? extends Callbacks.AfterToolCallback> canonicalAfterToolCallbacks()
      `afterToolCallback` 字段的值被解析为一个列表。

      此方法仅适用于代理开发工具包(Agent Development Kit)。

    • canonicalOnToolErrorCallbacks

      public List<? extends Callbacks.OnToolErrorCallback> canonicalOnToolErrorCallbacks()
      `onToolErrorCallback` 字段的值被解析为一个列表。

      此方法仅适用于代理开发工具包(Agent Development Kit)。

    • inputSchema

      public Optional<com.google.genai.types.Schema> inputSchema()
      描述内容复制自接口文档: Node
      返回该节点的输入数据必须匹配的规范(即数据结构)。当某个边的源数据的输出规范中包含某个键或类型,而该节点不接受这些键或类型时,构建该边的操作将会失败。因此,像映射(map)这样的“开放型生产者”(即可以生成任意类型数据的生成器)在构建数据时可能会出现问题。 FunctionNode 在……的时候;当……的情况下 Content `port` 检查边缘设备(edge device)与……之间的连接是否正常。 Content 在某种数据结构(或模式)中,如果一个节点要求其所有前置节点(predecessors)都必须满足某些条件,那么该节点会将其要求应用于每个前置节点的输出结果中,而不是应用于所有前置节点共同生成的最终结果(即“合并后的数据”)。
      Specified by:
      inputSchema in interface Node
      Overrides:
      inputSchema in class BaseNode
    • outputSchema

      public Optional<com.google.genai.types.Schema> outputSchema()
      描述内容复制自接口文档: Node
      返回一个规范(schema),该规范规定了节点的输出值必须符合的要求。不过,作为输出的消息(message-as-output)的内容并不会被用来验证是否满足这个规范。
      Specified by:
      outputSchema in interface Node
      Overrides:
      outputSchema in class BaseNode
    • rerunOnResume

      @Experimental public boolean rerunOnResume()
      返回值 true这样,当工作流程重新使用该代理作为节点时,它就会再次执行该代理;同时,该代理的模型也会收到其长时间执行的请求所获得的响应结果。
      Specified by:
      rerunOnResume in interface Node
      Overrides:
      rerunOnResume in class BaseNode
    • executor

      public Optional<Executor> executor()
    • outputKey

      public Optional<String> outputKey()
    • codeExecutor

      public Optional<BaseCodeExecutor> codeExecutor()
    • resolvedModel

      public Model resolvedModel()
    • fromConfig

      public static LlmAgent fromConfig(LlmAgentConfig config, String configAbsPath) throws ConfigAgentUtils.ConfigurationException
      根据配置创建一个 LLMAgent,该 LLMAgent 支持完整的子代理功能(full subagent support)。
      Parameters:
      config - the agent configuration
      configAbsPath - The absolute path to the agent config file. This is needed for resolving relative paths for e.g. tools and subagents.
      Returns:
      the configured LlmAgent
      Throws:
      ConfigAgentUtils.ConfigurationException - if the configuration is invalid
    • close

      public io.reactivex.rxjava3.core.Completable close()
      描述内容复制自相关类: BaseAgent
      关闭所有子代理(sub-agents)。
      Overrides:
      close in class BaseAgent
      Returns:
      a Completable that completes when all sub-agents are closed.