ToolGroup
public class ToolGroup
io/agentscope/core/tool/ToolGroup.java:42–257工具组,让智能体以受控方式调用外部能力。位于 io.agentscope.core.tool 包。核心成员包括 getName、getDescription、isActive、setActive、getScope、getTools。
Represents a named group of tools with activation state.
Tool groups allow organizing tools into logical categories and controlling their availability dynamically. Only tools from active groups are made available to agents.
Usage Example:
`ToolGroup adminGroup = ToolGroup.builder()
.name("admin")
.description("Administrative tools")
.active(false) // Start inactive
.build();
adminGroup.addTool("delete_user");
adminGroup.addTool("modify_permissions");
adminGroup.setActive(true); // Activate when needed
`
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Builder | 类class | 构建器,用于构建并配置目标实例。 Builder for constructing ToolGroup instances. |
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
protected ToolGroup(String name, String description, boolean active, ToolGroupScope scope, Set<String> tools) | 初始化 `ToolGroup` 实例。 Protected constructor for subclass use. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public String getName() | 获取名称的此工具组。 Gets the name of this tool group. |
public String getDescription() | 获取 `getDescription`。 Gets the description of this tool group. |
public boolean isActive() | 判断是否 `isActive`。 Checks if this tool group is currently active. |
public void setActive(boolean active) | 设置 `setActive`。 Sets the activation state of this tool group. |
public ToolGroupScope getScope() | 获取范围的此工具组。 Gets the scope of this tool group. |
public Set<String> getTools() | 获取工具。 Gets a defensive copy of the tools in this group. |
public void addTool(String toolName) | 添加工具。 Adds a tool to this group. |
public void removeTool(String toolName) | 移除工具。 Removes a tool from this group. |
public boolean containsTool(String toolName) | 设置该参数。 Checks if this group contains a specific tool. |
public ToolGroup copy() | 返回 `copy` 结果。 Creates a deep copy of this tool group, preserving the concrete type for subclasses. |
public static Builder builder()static | 返回构建器实例。 Creates a new builder for constructing ToolGroup instances. |
构造器详情Constructor Detail
ToolGroup
protected ToolGroup(String name, String description, boolean active, ToolGroupScope scope, Set<String> tools)
初始化 ToolGroup 实例。
Protected constructor for subclass use.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
name | String | 组名称(必填)。The group name (required) |
description | String | 描述(类型 `String`)。The group description |
active | boolean | active(类型 `boolean`)。Initial activation state |
scope | ToolGroupScope | 组范围。The group scope |
tools | Set<String> | 工具列表(类型 `Set`)。Initial set of tool names |
io/agentscope/core/tool/ToolGroup.java:59–70方法详情Method Detail
getName
public String getName()
获取名称的此工具组。
Gets the name of this tool group.
Stringio/agentscope/core/tool/ToolGroup.java:81–83getDescription
public String getDescription()
获取 getDescription。
Gets the description of this tool group.
Stringio/agentscope/core/tool/ToolGroup.java:90–92isActive
public boolean isActive()
判断是否 isActive。
Checks if this tool group is currently active.
booleanio/agentscope/core/tool/ToolGroup.java:99–101setActive
public void setActive(boolean active)
设置 setActive。
Sets the activation state of this tool group.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
active | boolean | active(类型 `boolean`)。true to activate, false to deactivate |
io/agentscope/core/tool/ToolGroup.java:108–110getScope
public ToolGroupScope getScope()
获取范围的此工具组。
Gets the scope of this tool group.
ToolGroupScopeio/agentscope/core/tool/ToolGroup.java:117–119getTools
public Set<String> getTools()
获取工具。
Gets a defensive copy of the tools in this group.
Set<String>io/agentscope/core/tool/ToolGroup.java:126–128addTool
public void addTool(String toolName)
添加工具。
Adds a tool to this group.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
toolName | String | 工具到添加的名称。The name of the tool to add |
io/agentscope/core/tool/ToolGroup.java:135–137removeTool
public void removeTool(String toolName)
移除工具。
Removes a tool from this group.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
toolName | String | 工具到移除的名称。The name of the tool to remove |
io/agentscope/core/tool/ToolGroup.java:144–146containsTool
public boolean containsTool(String toolName)
设置该参数。
Checks if this group contains a specific tool.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
toolName | String | 工具名称到检查。The tool name to check |
booleanio/agentscope/core/tool/ToolGroup.java:154–156copy
public ToolGroup copy()
返回 copy 结果。
Creates a deep copy of this tool group, preserving the concrete type for subclasses.
ToolGroupio/agentscope/core/tool/ToolGroup.java:163–171builder
public static Builder builder()
返回构建器实例。
Creates a new builder for constructing ToolGroup instances.
Builderio/agentscope/core/tool/ToolGroup.java:178–180嵌套类详情Nested Class Detail
Builder
public static class Builder构建器,用于构建并配置目标实例。位于 io.agentscope.core.tool 包。核心成员包括 name、description、active、scope、tools、build。
Builder for constructing ToolGroup instances.