`Class InMemorySkillSource`

java.lang.Object
com.google.adk.skills.InMemorySkillSource
All Implemented Interfaces:
SkillSource

public final class InMemorySkillSource extends Object implements SkillSource
一种基于内存的实现方式(in-memory implementation) SkillSource.

所有内容都通过“构建器模式”在开发初期就被预先准备好了。

  • 嵌套类概述

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    “Builder for”是一个用于描述某种构建工具或框架的术语。它通常表示该工具/框架用于帮助开发者或系统管理员快速、高效地创建或构建特定类型的应用程序、系统或组件。例如:“Builder for Web Applications”(用于构建Web应用程序的工具)或“Builder for Cloud Services”(用于构建云服务的工具)。 InMemorySkillSource.
  • 方法概述

    Modifier and Type
    Method
    Description
     
    io.reactivex.rxjava3.core.Single<com.google.common.collect.ImmutableMap<String, Frontmatter>>
    列出所有可用的选项。 Frontmatter“s”代表已发现的技能(discovered skills)。
    io.reactivex.rxjava3.core.Single<com.google.common.collect.ImmutableList<String>>
    listResources(String skillName, String resourceDirectory)
    列出指定目录中某个特定技能所使用的所有资源文件。
    io.reactivex.rxjava3.core.Single<Frontmatter>
    加载…… Frontmatter 针对某项特定的技能(for a specific skill)。
    io.reactivex.rxjava3.core.Single<String>
    加载特定技能的指令(即 SKILL.md 文件中的内容)。
    io.reactivex.rxjava3.core.Single<com.google.common.io.ByteSource>
    loadResource(String skillName, String resourcePath)
    加载特定的资源文件内容。

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 方法详细信息(Method Details)

    • builder

      public static InMemorySkillSource.Builder builder()
    • 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
    • listResources

      public io.reactivex.rxjava3.core.Single<com.google.common.collect.ImmutableList<String>> listResources(String skillName, String resourceDirectory)
      描述内容复制自接口文档: SkillSource
      列出指定目录中某个特定技能所使用的所有资源文件。

      如果该技能或资源目录不存在,那么返回的结果将会是……(具体内容需要根据实际情况填写)。 Single 将以……结尾 SkillSourceException.

      Specified by:
      listResources in interface SkillSource
      Parameters:
      skillName - the name of the skill
      resourceDirectory - the relative directory within the skill to list (e.g., "assets", "scripts")
      Returns:
      a Single emitting a list of resource paths relative to the skill directory
    • 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