`Class AbstractSkillSource<PathT>`

java.lang.Object
com.google.adk.skills.AbstractSkillSource<PathT>
Type Parameters:
PathT - the type of path object
All Implemented Interfaces:
SkillSource
Direct Known Subclasses:
ClassPathSkillSource, LocalSkillSource

public abstract class AbstractSkillSource<PathT> extends Object implements SkillSource
这是一个抽象基类,用于实现 `SkillSource` 接口;此类可以从类似对象的路径中加载技能数据。
  • 构造函数详细信息

    • AbstractSkillSource

      public AbstractSkillSource()
  • 方法详细信息(Method Details)

    • listFrontmatters

      public io.reactivex.rxjava3.core.Single<com.google.common.collect.ImmutableMap<String, Frontmatter>> listFrontmatters()
      描述内容复制自接口文档: SkillSource
      列出所有可用的选项。 Frontmatter“s”代表已发现的技能(discovered skills)。

      如果源配置错误(例如目录不存在,或者技能信息格式不正确),则返回的结果将会…… Single 程序将以……方式终止。 SkillSourceException 根据消息中的原因(with the reason in the message)。

      Specified by:
      listFrontmatters in interface SkillSource
      Returns:
      a Single emitting a map where keys are skill names and values are their Frontmatter
    • loadFrontmatter

      public io.reactivex.rxjava3.core.Single<Frontmatter> loadFrontmatter(String skillName)
      描述内容复制自接口文档: SkillSource
      加载…… Frontmatter 针对某项特定的技能(for a specific skill)。

      如果找不到该技能信息,或者其相关文档(frontmatter)的格式不正确,那么返回的结果将会是……(具体返回内容需要根据实际情况填写)。 Single 将以……结尾 SkillSourceException 或者是因为解析错误(parsing error)。

      Specified by:
      loadFrontmatter in interface SkillSource
      Parameters:
      skillName - the name of the skill
      Returns:
      a Single emitting the Frontmatter for the skill
    • loadInstructions

      public io.reactivex.rxjava3.core.Single<String> loadInstructions(String skillName)
      描述内容复制自接口文档: SkillSource
      加载特定技能的指令(即 SKILL.md 文件中的内容)。

      如果该技能未被找到,或者其文件结构无效(例如:前置内容(frontmatter)块未正确关闭),则返回的…… Single 程序将以……方式终止。 SkillSourceException.

      Specified by:
      loadInstructions in interface SkillSource
      Parameters:
      skillName - the name of the skill
      Returns:
      a Single emitting the instructions as a String
    • loadResource

      public io.reactivex.rxjava3.core.Single<com.google.common.io.ByteSource> loadResource(String skillName, String resourcePath)
      描述内容复制自接口文档: SkillSource
      加载特定的资源文件内容。

      如果找不到该技能或相应的资源路径,系统将返回以下内容: Single 将以……结尾 SkillSourceException.

      Specified by:
      loadResource in interface SkillSource
      Parameters:
      skillName - the name of the skill
      resourcePath - the path to the resource file relative to the skill directory
      Returns:
      a Single emitting the ByteSource for the resource content
    • listSkills

      protected abstract io.reactivex.rxjava3.core.Flowable<AbstractSkillSource.SkillMdPath<PathT>> listSkills()
      返回一个 Flowable 这些技能信息以“技能名称”与对应 SKILL.md 文件的路径的形式组合在一起进行存储。
    • findSkillMdPath

      protected abstract io.reactivex.rxjava3.core.Single<PathT> findSkillMdPath(String skillName)
      返回给定技能对应的 SKILL.md 文件的路径。
    • findResourcePath

      protected abstract io.reactivex.rxjava3.core.Single<PathT> findResourcePath(String skillName, String resourcePath)
      返回给定技能所对应资源的路径。
    • openChannel

      protected abstract ReadableByteChannel openChannel(PathT path) throws IOException
      打开一个 InputStream 用于读取指定路径下的内容。
      Throws:
      IOException