Builder
public static class Builder
io/agentscope/core/skill/AgentSkill.java:341–514构建器,用于构建并配置目标实例。位于 io.agentscope.core.skill 包。核心成员包括 name、description、metadata、putMetadata、removeMetadata、skillContent。
Builder for creating AgentSkill instances.
This builder allows selective modification of skill fields to create new skill instances based on existing ones, or to create new skills from scratch.
Usage examples:
`// Create from scratch
AgentSkill skill = AgentSkill.builder()
.name("my_skill")
.description("Does something")
.skillContent("Instructions here")
.addResource("file.txt", "content")
.build();
// Modify existing skill
AgentSkill modified = existingSkill.toBuilder()
.description("Updated description")
.addResource("new_file.txt", "new content")
.build();
`
方法摘要Method Summary
方法详情Method Detail
name
public Builder name(String name)
设置技能名称。
Sets the skill name.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
name | String | 技能名称。The skill name |
Builderio/agentscope/core/skill/AgentSkill.java:375–378description
public Builder description(String description)
设置该配置项。
Sets the skill description.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
description | String | 描述(类型 `String`)。The skill description |
Builderio/agentscope/core/skill/AgentSkill.java:386–389metadata
public Builder metadata(Map<String, Object> metadata)
设置元数据。
Replaces all metadata with a new map.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
metadata | Map<String, Object> | 新的元数据映射。The new metadata map |
Builderio/agentscope/core/skill/AgentSkill.java:397–401putMetadata
public Builder putMetadata(String key, Object value)
设置该配置项。
Adds or updates a single metadata entry.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 元数据密钥。The metadata key |
value | Object | 元数据值。The metadata value |
Builderio/agentscope/core/skill/AgentSkill.java:410–413removeMetadata
public Builder removeMetadata(String key)
移除元数据。
Removes a metadata entry.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 元数据密钥到移除。The metadata key to remove |
Builderio/agentscope/core/skill/AgentSkill.java:421–424skillContent
public Builder skillContent(String skillContent)
设置技能内容。
Sets the skill content.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
skillContent | String | 技能内容/指令。The skill content/instructions |
Builderio/agentscope/core/skill/AgentSkill.java:432–435resources
public Builder resources(Map<String, String> resources)
设置该配置项。
Replaces all resources with a new map.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
resources | Map<String, String> | resources(类型 `Map`)。The new resources map |
Builderio/agentscope/core/skill/AgentSkill.java:443–446addResource
public Builder addResource(String path, String content)
添加资源。
Adds or updates a single resource.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
path | String | 资源路径。The resource path |
content | String | 资源内容。The resource content |
Builderio/agentscope/core/skill/AgentSkill.java:455–458removeResource
public Builder removeResource(String path)
移除资源。
Removes a resource.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
path | String | 资源路径到移除。The resource path to remove |
Builderio/agentscope/core/skill/AgentSkill.java:466–469clearResources
public Builder clearResources()
清空 clearResources。
Clears all resources.
Builderio/agentscope/core/skill/AgentSkill.java:476–479source
public Builder source(String source)
设置来源。
Sets the source identifier.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
source | String | 来源(类型 `String`)。The source identifier |
Builderio/agentscope/core/skill/AgentSkill.java:487–490originDir
public Builder originDir(Path originDir)
设置来源目录。
Sets the on-disk origin directory for this skill.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
originDir | Path | 来源目录(类型 `Path`)。absolute path to the skill's source directory, or `null` |
Builderio/agentscope/core/skill/AgentSkill.java:500–503build
public AgentSkill build()
构建AgentSkill 实例。
Builds the AgentSkill instance.
AgentSkillIllegalArgumentException可能抛出 `IllegalArgumentException`。if required fields are missing
io/agentscope/core/skill/AgentSkill.java:511–513