SkillUtil
public class SkillUtil
io/agentscope/core/skill/util/SkillUtil.java:53–399技能 Util,让智能体以受控方式调用外部能力。位于 io.agentscope.core.skill.util 包。核心成员包括 createFrom、createFromZip。
Utility class for creating AgentSkill instances.
This class provides factory methods to create AgentSkill objects from various sources, particularly from markdown content with YAML frontmatter.
Usage example:
`// Create skill from markdown with default source
String skillMd = "---\nname: my_skill\ndescription: Does something\n---\nContent here";
Map<String, String> resources = Map.of("file1.txt", "content1");
AgentSkill skill = SkillUtil.createFrom(skillMd, resources);
// Create skill from markdown with custom source
AgentSkill skill2 = SkillUtil.createFrom(skillMd, resources, "github");
`
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static AgentSkill createFrom(String skillMd, Map<String, String> resources)static | 创建来自。 Creates an AgentSkill from markdown with YAML frontmatter. |
public static AgentSkill createFrom(String skillMd, Map<String, String> resources, String source)static | 创建来自。 Creates an AgentSkill from markdown with YAML frontmatter and custom source. |
public static AgentSkill createFromZip(byte[] zipBytes)static | 创建 `createFromZip`。 Creates an AgentSkill from a skill package zip. |
public static AgentSkill createFromZip(Path zipPath)static | 创建 `createFromZip`。 Creates an AgentSkill from a skill package zip file path. |
public static AgentSkill createFromZip(Path zipPath, Charset charset)static | 创建 `createFromZip`。 Creates an AgentSkill from a skill package zip file path using the given charset. |
public static AgentSkill createFromZip(InputStream zipStream)static | 创建 `createFromZip`。 Creates an AgentSkill from a skill package zip input stream. |
public static AgentSkill createFromZip(byte[] zipBytes, String source)static | 创建 `createFromZip`。 Creates an AgentSkill from a skill package zip with custom source. |
public static AgentSkill createFromZip(byte[] zipBytes, String source, Charset charset)static | 创建 `createFromZip`。 Creates an AgentSkill from a skill package zip with custom source and charset. |
public static AgentSkill createFromZip(Path zipPath, String source)static | 创建 `createFromZip`。 Creates an AgentSkill from a skill package zip file path with custom source. |
public static AgentSkill createFromZip(Path zipPath, String source, Charset charset)static | 创建 `createFromZip`。 Creates an AgentSkill from a skill package zip file path with custom source and charset. |
public static AgentSkill createFromZip(InputStream zipStream, String source)static | 创建 `createFromZip`。 Creates an AgentSkill from a skill package zip input stream with custom source. |
public static AgentSkill createFromZip(InputStream zipStream, String source, Charset charset)static | 创建 `createFromZip`。 Creates an AgentSkill from a skill package zip input stream with custom source and charset. |
方法详情Method Detail
createFrom
public static AgentSkill createFrom(String skillMd, Map<String, String> resources)
创建来自。
Creates an AgentSkill from markdown with YAML frontmatter.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
skillMd | String | 技能 Md(类型 `String`)。Markdown content with YAML frontmatter containing name and description |
resources | Map<String, String> | resources(类型 `Map`)。Supporting resources referenced by the skill (can be null) |
AgentSkillIllegalArgumentException可能抛出 `IllegalArgumentException`。if name or description is missing, or if content is empty
io/agentscope/core/skill/util/SkillUtil.java:74–76createFrom
public static AgentSkill createFrom(String skillMd, Map<String, String> resources, String source)
创建来自。
Creates an AgentSkill from markdown with YAML frontmatter and custom source.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
skillMd | String | 技能 Md(类型 `String`)。Markdown content with YAML frontmatter containing name and description |
resources | Map<String, String> | resources(类型 `Map`)。Supporting resources referenced by the skill (can be null) |
source | String | 来源(类型 `String`)。Source identifier for the skill (null defaults to "custom") |
AgentSkillIllegalArgumentException可能抛出 `IllegalArgumentException`。if name or description is missing, or if content is empty
io/agentscope/core/skill/util/SkillUtil.java:90–113createFromZip
public static AgentSkill createFromZip(byte[] zipBytes)
创建 createFromZip。
Creates an AgentSkill from a skill package zip.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
zipBytes | byte[] | zip 字节(类型 `byte[]`)。Zip content as bytes |
AgentSkillIllegalArgumentException可能抛出 `IllegalArgumentException`。if zipBytes is null/empty, if no SKILL.md is found, or if zip entries are invalid
io/agentscope/core/skill/util/SkillUtil.java:126–128createFromZip
public static AgentSkill createFromZip(Path zipPath)
创建 createFromZip。
Creates an AgentSkill from a skill package zip file path.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
zipPath | Path | zip 路径(类型 `Path`)。Zip file path |
AgentSkillIllegalArgumentException可能抛出 `IllegalArgumentException`。if zipPath is nullRuntimeException可能抛出 `RuntimeException`。if the zip file cannot be read
io/agentscope/core/skill/util/SkillUtil.java:141–143createFromZip
public static AgentSkill createFromZip(Path zipPath, Charset charset)
创建 createFromZip。
Creates an AgentSkill from a skill package zip file path using the given charset.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
zipPath | Path | zip 路径(类型 `Path`)。Zip file path |
charset | Charset | charset(类型 `Charset`)。Charset used to decode zip entry names and file contents (null defaults to UTF-8). Use this when the zip was created with a non-UTF-8 charset such as GBK/GB18030 and the default overload fails during zip entry decoding with errors like `malformed input` |
AgentSkillio/agentscope/core/skill/util/SkillUtil.java:158–160createFromZip
public static AgentSkill createFromZip(InputStream zipStream)
创建 createFromZip。
Creates an AgentSkill from a skill package zip input stream.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
zipStream | InputStream | zip 流(类型 `InputStream`)。Zip content stream |
AgentSkillIllegalArgumentException可能抛出 `IllegalArgumentException`。if zipStream is null
io/agentscope/core/skill/util/SkillUtil.java:172–174createFromZip
public static AgentSkill createFromZip(byte[] zipBytes, String source)
创建 createFromZip。
Creates an AgentSkill from a skill package zip with custom source.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
zipBytes | byte[] | zip 字节(类型 `byte[]`)。Zip content as bytes |
source | String | 来源(类型 `String`)。Source identifier for the skill (null defaults to "custom") |
AgentSkillIllegalArgumentException可能抛出 `IllegalArgumentException`。if zipBytes is null/empty, if no SKILL.md is found, or if zip entries are invalid
io/agentscope/core/skill/util/SkillUtil.java:188–190createFromZip
public static AgentSkill createFromZip(byte[] zipBytes, String source, Charset charset)
创建 createFromZip。
Creates an AgentSkill from a skill package zip with custom source and charset.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
zipBytes | byte[] | zip 字节(类型 `byte[]`)。Zip content as bytes |
source | String | 来源(类型 `String`)。Source identifier for the skill (null defaults to "custom") |
charset | Charset | charset(类型 `Charset`)。Charset used to decode zip entry names and file contents (null defaults to UTF-8). Use this when the zip was created with a non-UTF-8 charset such as GBK/GB18030 and the default overload fails during zip entry decoding with errors like `malformed input` |
AgentSkillIllegalArgumentException可能抛出 `IllegalArgumentException`。if zipBytes is null/empty, if no SKILL.md is found, or if zip entries are invalid
io/agentscope/core/skill/util/SkillUtil.java:208–213createFromZip
public static AgentSkill createFromZip(Path zipPath, String source)
创建 createFromZip。
Creates an AgentSkill from a skill package zip file path with custom source.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
zipPath | Path | zip 路径(类型 `Path`)。Zip file path |
source | String | 来源(类型 `String`)。Source identifier for the skill (null defaults to "custom") |
AgentSkillIllegalArgumentException可能抛出 `IllegalArgumentException`。if zipPath is nullRuntimeException可能抛出 `RuntimeException`。if the zip file cannot be read
io/agentscope/core/skill/util/SkillUtil.java:227–229createFromZip
public static AgentSkill createFromZip(Path zipPath, String source, Charset charset)
创建 createFromZip。
Creates an AgentSkill from a skill package zip file path with custom source and charset.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
zipPath | Path | zip 路径(类型 `Path`)。Zip file path |
source | String | 来源(类型 `String`)。Source identifier for the skill (null defaults to "custom") |
charset | Charset | charset(类型 `Charset`)。Charset used to decode zip entry names and file contents (null defaults to UTF-8). Use this when the zip was created with a non-UTF-8 charset such as GBK/GB18030 and the default overload fails during zip entry decoding with errors like `malformed input` |
AgentSkillIllegalArgumentException可能抛出 `IllegalArgumentException`。if zipPath is nullRuntimeException可能抛出 `RuntimeException`。if the zip file cannot be read
io/agentscope/core/skill/util/SkillUtil.java:247–256createFromZip
public static AgentSkill createFromZip(InputStream zipStream, String source)
创建 createFromZip。
Creates an AgentSkill from a skill package zip input stream with custom source.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
zipStream | InputStream | zip 流(类型 `InputStream`)。Zip content stream |
source | String | 来源(类型 `String`)。Source identifier for the skill (null defaults to "custom") |
AgentSkillIllegalArgumentException可能抛出 `IllegalArgumentException`。if zipStream is nullRuntimeException可能抛出 `RuntimeException`。if the zip content cannot be read
io/agentscope/core/skill/util/SkillUtil.java:270–272createFromZip
public static AgentSkill createFromZip(InputStream zipStream, String source, Charset charset)
创建 createFromZip。
Creates an AgentSkill from a skill package zip input stream with custom source and charset.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
zipStream | InputStream | zip 流(类型 `InputStream`)。Zip content stream |
source | String | 来源(类型 `String`)。Source identifier for the skill (null defaults to "custom") |
charset | Charset | charset(类型 `Charset`)。Charset used to decode zip entry names and file contents (null defaults to UTF-8). Use this when the zip was created with a non-UTF-8 charset such as GBK/GB18030 and the default overload fails during zip entry decoding with errors like `malformed input` |
AgentSkillIllegalArgumentException可能抛出 `IllegalArgumentException`。if zipStream is nullRuntimeException可能抛出 `RuntimeException`。if the zip content cannot be read
io/agentscope/core/skill/util/SkillUtil.java:290–355