类名:ConfigAgentLoader
java.lang.Object
com.google.adk.maven.ConfigAgentLoader
- All Implemented Interfaces:
AgentLoader
这是一个基于配置的 AgentLoader,它可以从 YAML 配置文件中加载代理程序(agents)。
该加载器会监控配置好的源目录,寻找包含 `root_agent.yaml` 文件的文件夹;当这些文件发生变化时(如果启用了热重载功能),系统会自动重新加载相应的代理程序。
加载器会将每个包含 `root_agent.yaml` 文件的子目录视为一个代理(agent),并使用该子目录的名称作为代理的标识符。这些代理会在首次被请求时才被加载(即按需加载)。
预期的目录结构如下:
source-dir/ ├── agent1/ │ └── root_agent.yaml ├── agent2/ │ └── root_agent.yaml └── ...
可以通过将 `hotReloadingEnabled` 的值设置为 `false` 来禁用热重载功能。
TODO:配置代理(Config Agent)的相关功能尚未准备好供公众使用。
-
构造函数概述
ConstructorsConstructorDescriptionConfigAgentLoader(String sourceDir) 创建一个新的 `ConfigAgentLoader`,并启用热重载(hot-reloading)功能。ConfigAgentLoader(String sourceDir, boolean hotReloadingEnabled) 创建一个新的 ConfigAgentLoader。 -
方法概述
-
构造函数详细信息
-
ConfigAgentLoader
创建一个新的 ConfigAgentLoader。- Parameters:
sourceDir- The directory to scan for agent configuration fileshotReloadingEnabled- Controls whether hot-reloading is enabled
-
ConfigAgentLoader
创建一个新的 `ConfigAgentLoader`,并启用热重载(hot-reloading)功能。- Parameters:
sourceDir- The directory to scan for agent configuration files
-
-
方法详细信息(Method Details)
-
listAgents
描述内容复制自接口文档:AgentLoader返回一个包含所有可用代理名称的列表。- Specified by:
listAgentsin interfaceAgentLoader- Returns:
- ImmutableList of agent names. Must not return null - return an empty list if no agents are available.
-
loadAgent
描述内容复制自接口文档:AgentLoader加载指定代理名称对应的 BaseAgent 实例。- Specified by:
loadAgentin interfaceAgentLoader- Parameters:
name- the name of the agent to load- Returns:
- BaseAgent instance for the given name
-
stop
public void stop()停止热加载(hot-loading)服务。
-