类 AgentSkill.Builder
java.lang.Object
io.agentscope.core.skill.AgentSkill.Builder
- 封闭类:
AgentSkill
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();
-
方法概要
修饰符和类型方法说明addResource(String path, String content) Adds or updates a single resource.build()Builds the AgentSkill instance.Clears all resources.description(String description) Sets the skill description.Replaces all metadata with a new map.Sets the skill name.putMetadata(String key, Object value) Adds or updates a single metadata entry.removeMetadata(String key) Removes a metadata entry.removeResource(String path) Removes a resource.Replaces all resources with a new map.skillContent(String skillContent) Sets the skill content.Sets the source identifier.
-
方法详细资料
-
name
Sets the skill name.- 参数:
name- The skill name- 返回:
- This builder
-
description
Sets the skill description.- 参数:
description- The skill description- 返回:
- This builder
-
metadata
Replaces all metadata with a new map.- 参数:
metadata- The new metadata map- 返回:
- This builder
-
putMetadata
Adds or updates a single metadata entry.- 参数:
key- The metadata keyvalue- The metadata value- 返回:
- This builder
-
removeMetadata
Removes a metadata entry.- 参数:
key- The metadata key to remove- 返回:
- This builder
-
skillContent
Sets the skill content.- 参数:
skillContent- The skill content/instructions- 返回:
- This builder
-
resources
Replaces all resources with a new map.- 参数:
resources- The new resources map- 返回:
- This builder
-
addResource
Adds or updates a single resource.- 参数:
path- The resource pathcontent- The resource content- 返回:
- This builder
-
removeResource
Removes a resource.- 参数:
path- The resource path to remove- 返回:
- This builder
-
clearResources
Clears all resources.- 返回:
- This builder
-
source
Sets the source identifier.- 参数:
source- The source identifier- 返回:
- This builder
-
build
Builds the AgentSkill instance.- 返回:
- A new AgentSkill instance
- 抛出:
IllegalArgumentException- if required fields are missing
-