A2UIAgent.SkillGenerator (A2UIAgent v0.1.1)

Copy Markdown View Source

Packages an inference format's prompt as skills (A2UIAgent.Skill).

{:ok, format} = A2UIAgent.Express.new([catalog])

{:ok, skill} = A2UIAgent.SkillGenerator.skill(format, name: "a2ui")
{:ok, skills} = A2UIAgent.SkillGenerator.skill_set(format)
Enum.map(skills, & &1.filename)
#=> ["a2ui-core/SKILL.md", "a2ui-basic/SKILL.md"]

A monolithic skill (skill/2) holds the whole prompt: the format's rules, each catalog's instructions and the examples. A skill set (skill_set/2) splits it into a core skill with the rules (core_skill/2) and one skill per catalog (catalog_skill/3), named after the catalog: a2ui-<name>, where the name is the last part of the catalog id that is not a file or a version.

The format must implement the optional A2UIAgent.Format callbacks that give its prompt's pieces, as A2UIAgent.Express does.

Summary

Functions

The skill of one catalog (default: the format's first): its instructions and, unless include_examples: false, the examples. Options: :name (default "a2ui-<name>"), :description and :include_examples.

The name a catalog's skill takes after: the last part of its id that is not a file name or a version, in lower case.

The skill with the format's rules. Options: :name (default "a2ui-core") and :description.

One skill with the whole prompt. Options: :name (default "a2ui"), :description and :catalogs (default: the format's).

The core skill and one skill per catalog (default: the format's catalogs). Examples a format gives every catalog go only into the first catalog's skill. Options: :catalogs and :core_name.

Functions

catalog_skill(format, catalog \\ nil, options \\ [])

(since 0.1.0)
@spec catalog_skill(struct(), A2UICore.Catalog.t() | nil, keyword()) ::
  {:ok, A2UIAgent.Skill.t()} | {:error, A2UICore.Error.t()}

The skill of one catalog (default: the format's first): its instructions and, unless include_examples: false, the examples. Options: :name (default "a2ui-<name>"), :description and :include_examples.

clean_name(catalog_id)

(since 0.1.0)
@spec clean_name(String.t() | nil) :: String.t()

The name a catalog's skill takes after: the last part of its id that is not a file name or a version, in lower case.

iex> A2UIAgent.SkillGenerator.clean_name("https://a2ui.org/specification/v1_0/catalogs/basic/catalog.json")
"basic"
iex> A2UIAgent.SkillGenerator.clean_name("acme/widgets/v2")
"widgets"

core_skill(format, options \\ [])

(since 0.1.0)
@spec core_skill(struct(), keyword()) :: A2UIAgent.Skill.t()

The skill with the format's rules. Options: :name (default "a2ui-core") and :description.

skill(format, options \\ [])

(since 0.1.0)
@spec skill(struct(), keyword()) ::
  {:ok, A2UIAgent.Skill.t()} | {:error, A2UICore.Error.t()}

One skill with the whole prompt. Options: :name (default "a2ui"), :description and :catalogs (default: the format's).

skill_set(format, options \\ [])

(since 0.1.0)
@spec skill_set(struct(), keyword()) ::
  {:ok, [A2UIAgent.Skill.t()]} | {:error, A2UICore.Error.t()}

The core skill and one skill per catalog (default: the format's catalogs). Examples a format gives every catalog go only into the first catalog's skill. Options: :catalogs and :core_name.