类:ConfigAgentUtils

java.lang.Object
com.google.adk.agents.ConfigAgentUtils

public final class ConfigAgentUtils extends Object
这是一个用于从 YAML 文件中加载代理配置的实用类。

TODO:配置代理(Config Agent)的相关功能尚未准备好供公众使用。

  • 方法详细信息(Method Details)

    • resolveAndSetCommonAgentFields

      public static void resolveAndSetCommonAgentFields(BaseAgent.Builder<?> builder, BaseAgentConfig config, String configAbsPath) throws ConfigAgentUtils.ConfigurationException
      根据配置文件来设置代理构建器(agent builder)的通用属性。
      Parameters:
      builder - The agent builder.
      config - The agent configuration.
      configAbsPath - The absolute path to the config file (for resolving relative paths).
      Throws:
      ConfigAgentUtils.ConfigurationException - if the configuration is invalid.
    • resolveAndSetCallback

      public static <T> void resolveAndSetCallback(@Nullable List<BaseAgentConfig.CallbackRef> refs, Class<T> callbackBaseClass, String callbackTypeName, Consumer<com.google.common.collect.ImmutableList<T>> builderSetter) throws ConfigAgentUtils.ConfigurationException
      根据配置解决相关问题并设置回调函数。
      Type Parameters:
      T - The type of the callback.
      Parameters:
      refs - The list of callback references from config.
      callbackBaseClass - The base class of the callback.
      callbackTypeName - The name of the callback type for error messages.
      builderSetter - The setter method on the builder to apply the resolved callbacks.
      Throws:
      ConfigAgentUtils.ConfigurationException - if a callback cannot be resolved.
    • setBaseAgentCallbacks

      public static void setBaseAgentCallbacks(BaseAgentConfig config, Consumer<com.google.common.collect.ImmutableList<com.google.adk.agents.Callbacks.BeforeAgentCallbackBase>> beforeSetter, Consumer<com.google.common.collect.ImmutableList<com.google.adk.agents.Callbacks.AfterAgentCallbackBase>> afterSetter) throws ConfigAgentUtils.ConfigurationException
      将配置文件中定义的通用代理回调函数(代理执行前/执行后的回调函数)设置到构建器的相应设置项中。
      Parameters:
      config - The agent configuration.
      beforeSetter - The setter for before-agent callbacks.
      afterSetter - The setter for after-agent callbacks.
      Throws:
      ConfigAgentUtils.ConfigurationException - if a callback cannot be resolved.
    • fromConfig

      public static BaseAgent fromConfig(String configPath) throws ConfigAgentUtils.ConfigurationException
      从 YAML 配置文件路径中加载代理程序。
      Parameters:
      configPath - the path to a YAML config file
      Returns:
      the created agent instance as a BaseAgent
      Throws:
      ConfigAgentUtils.ConfigurationException - if loading fails
    • resolveSubAgents

      public static com.google.common.collect.ImmutableList<BaseAgent> resolveSubAgents(List<BaseAgentConfig.AgentRefConfig> subAgentConfigs, String configAbsPath) throws ConfigAgentUtils.ConfigurationException
      将子代理的配置信息转换为实际的 BaseAgent 实例。具体代理实现会使用此方法来处理其内部的子代理。
      Parameters:
      subAgentConfigs - The list of subagent configurations
      configAbsPath - The absolute path to the parent config file for resolving relative paths
      Returns:
      A list of resolved BaseAgent instances
      Throws:
      ConfigAgentUtils.ConfigurationException - if any subagent fails to resolve