类 AgentSkill.Builder

java.lang.Object
io.agentscope.core.skill.AgentSkill.Builder
封闭类:
AgentSkill

public static class AgentSkill.Builder extends Object
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();
 
  • 方法详细资料

    • name

      public AgentSkill.Builder name(String name)
      Sets the skill name.
      参数:
      name - The skill name
      返回:
      This builder
    • description

      public AgentSkill.Builder description(String description)
      Sets the skill description.
      参数:
      description - The skill description
      返回:
      This builder
    • metadata

      public AgentSkill.Builder metadata(Map<String,Object> metadata)
      Replaces all metadata with a new map.
      参数:
      metadata - The new metadata map
      返回:
      This builder
    • putMetadata

      public AgentSkill.Builder putMetadata(String key, Object value)
      Adds or updates a single metadata entry.
      参数:
      key - The metadata key
      value - The metadata value
      返回:
      This builder
    • removeMetadata

      public AgentSkill.Builder removeMetadata(String key)
      Removes a metadata entry.
      参数:
      key - The metadata key to remove
      返回:
      This builder
    • skillContent

      public AgentSkill.Builder skillContent(String skillContent)
      Sets the skill content.
      参数:
      skillContent - The skill content/instructions
      返回:
      This builder
    • resources

      public AgentSkill.Builder resources(Map<String,String> resources)
      Replaces all resources with a new map.
      参数:
      resources - The new resources map
      返回:
      This builder
    • addResource

      public AgentSkill.Builder addResource(String path, String content)
      Adds or updates a single resource.
      参数:
      path - The resource path
      content - The resource content
      返回:
      This builder
    • removeResource

      public AgentSkill.Builder removeResource(String path)
      Removes a resource.
      参数:
      path - The resource path to remove
      返回:
      This builder
    • clearResources

      public AgentSkill.Builder clearResources()
      Clears all resources.
      返回:
      This builder
    • source

      public AgentSkill.Builder source(String source)
      Sets the source identifier.
      参数:
      source - The source identifier
      返回:
      This builder
    • build

      public AgentSkill build()
      Builds the AgentSkill instance.
      返回:
      A new AgentSkill instance
      抛出:
      IllegalArgumentException - if required fields are missing