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:
LocalSkillSource
Abstract base class for SkillSource implementations that load skills from path like object.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected final classA container class that holds a skill's name and the path to its SKILL.md file. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract io.reactivex.rxjava3.core.Single<PathT> findResourcePath(String skillName, String resourcePath) Returns the path to the resource for the given skill.protected abstract io.reactivex.rxjava3.core.Single<PathT> findSkillMdPath(String skillName) Returns the path to the SKILL.md file for the given skill.io.reactivex.rxjava3.core.Single<com.google.common.collect.ImmutableMap<String, Frontmatter>> Lists all availableFrontmatters for discovered skills.protected abstract io.reactivex.rxjava3.core.Flowable<AbstractSkillSource<PathT>.SkillMdPath> Returns aFlowableof skills as a pair of skill name and the path to the SKILL.md file.io.reactivex.rxjava3.core.Single<Frontmatter> loadFrontmatter(String skillName) Loads theFrontmatterfor a specific skill.io.reactivex.rxjava3.core.Single<String> loadInstructions(String skillName) Loads the instructions (body of SKILL.md) for a specific skill.io.reactivex.rxjava3.core.Single<com.google.common.io.ByteSource> loadResource(String skillName, String resourcePath) Loads a specific resource file content.protected abstract ReadableByteChannelopenChannel(PathT path) Opens aInputStreamfor reading the content of the given path.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface SkillSource
listResourcesModifier and TypeMethodDescriptionio.reactivex.rxjava3.core.Single<com.google.common.collect.ImmutableList<String>> listResources(String skillName, String resourceDirectory) Lists all resource files for a specific skill within a given directory.
-
Constructor Details
-
AbstractSkillSource
public AbstractSkillSource()
-
-
Method Details
-
listFrontmatters
public io.reactivex.rxjava3.core.Single<com.google.common.collect.ImmutableMap<String, Frontmatter>> listFrontmatters()Description copied from interface:SkillSourceLists all availableFrontmatters for discovered skills.If the source is misconfigured, such as directory doesn't exist, or having malformed skill, the returned
Singlewill terminate with aSkillSourceExceptionwith the reason in the message.- Specified by:
listFrontmattersin interfaceSkillSource- Returns:
- a
Singleemitting a map where keys are skill names and values are theirFrontmatter
-
loadFrontmatter
Description copied from interface:SkillSourceLoads theFrontmatterfor a specific skill.If the skill is not found or its frontmatter is malformed, the returned
Singlewill terminate with aSkillSourceExceptionor parsing error.- Specified by:
loadFrontmatterin interfaceSkillSource- Parameters:
skillName- the name of the skill- Returns:
- a
Singleemitting theFrontmatterfor the skill
-
loadInstructions
Description copied from interface:SkillSourceLoads the instructions (body of SKILL.md) for a specific skill.If the skill is not found or its file structure is invalid (e.g., unclosed frontmatter blocks), the returned
Singlewill terminate with aSkillSourceException.- Specified by:
loadInstructionsin interfaceSkillSource- Parameters:
skillName- the name of the skill- Returns:
- a
Singleemitting the instructions as a String
-
loadResource
public io.reactivex.rxjava3.core.Single<com.google.common.io.ByteSource> loadResource(String skillName, String resourcePath) Description copied from interface:SkillSourceLoads a specific resource file content.If the skill or the specific resource path cannot be found, the returned
Singlewill terminate with aSkillSourceException.- Specified by:
loadResourcein interfaceSkillSource- Parameters:
skillName- the name of the skillresourcePath- the path to the resource file relative to the skill directory- Returns:
- a
Singleemitting theByteSourcefor the resource content
-
listSkills
protected abstract io.reactivex.rxjava3.core.Flowable<AbstractSkillSource<PathT>.SkillMdPath> listSkills()Returns aFlowableof skills as a pair of skill name and the path to the SKILL.md file. -
findSkillMdPath
-
findResourcePath
-
openChannel
Opens aInputStreamfor reading the content of the given path.- Throws:
IOException
-