PtcRunner.Lisp.LanguageSpec (PtcRunner v0.9.0)

Copy Markdown View Source

Language specification compositions for PTC-Lisp.

Provides pre-composed language specs for common use cases. Raw prompts are loaded via PtcRunner.Prompts.

Available Specs

KeyDescription
:single_shotBase + single-shot rules
:multi_turnBase + multi-turn rules (return/fail, memory)
:multi_turn_journalBase + multi-turn + journal (task/step-done)

Raw Snippets

KeyDescription
:baseCore language reference
:addon_single_shotSingle-shot mode rules
:addon_multi_turnMulti-turn mode rules
:addon_journalJournal, task caching, semantic progress

Version Metadata

Spec files include metadata headers:

<!-- version: 2 -->
<!-- date: 2025-01-15 -->
<!-- changes: Removed threading examples -->

Access metadata via version/1 and metadata/1.

Usage

# For single-turn queries
PtcRunner.Lisp.LanguageSpec.get(:single_shot)

# For multi-turn conversations
PtcRunner.Lisp.LanguageSpec.get(:multi_turn)

# Raw snippets for custom compositions
PtcRunner.Lisp.LanguageSpec.get(:base) <> my_custom_addon

Summary

Functions

Get a prompt by key.

Get a prompt by key, raising if not found.

List all available prompt keys.

List all prompts with descriptions.

Get full metadata for a prompt.

Get the version number for a prompt.

Functions

get(key)

@spec get(atom()) :: String.t() | nil

Get a prompt by key.

Supports both raw snippets (:base, :addon_single_shot) and compositions (:single_shot, :multi_turn).

Examples

iex> prompt = PtcRunner.Lisp.LanguageSpec.get(:single_shot)
iex> is_binary(prompt)
true

iex> prompt = PtcRunner.Lisp.LanguageSpec.get(:multi_turn)
iex> String.contains?(prompt, "<state>")
true

get!(key)

@spec get!(atom()) :: String.t()

Get a prompt by key, raising if not found.

Examples

iex> prompt = PtcRunner.Lisp.LanguageSpec.get!(:single_shot)
iex> is_binary(prompt)
true

list()

@spec list() :: [atom()]

List all available prompt keys.

Examples

iex> keys = PtcRunner.Lisp.LanguageSpec.list()
iex> :single_shot in keys
true
iex> :multi_turn in keys
true

list_with_descriptions()

@spec list_with_descriptions() :: [{atom(), String.t()}]

List all prompts with descriptions.

Returns a list of {key, description} tuples.

Examples

iex> list = PtcRunner.Lisp.LanguageSpec.list_with_descriptions()
iex> Enum.any?(list, fn {k, _} -> k == :single_shot end)
true

metadata(key)

@spec metadata(atom()) :: map()

Get full metadata for a prompt.

Returns a map with metadata keys like :version, :date, :changes. For compositions, returns metadata of the first component.

Examples

iex> meta = PtcRunner.Lisp.LanguageSpec.metadata(:base)
iex> is_map(meta)
true

version(key)

@spec version(atom()) :: pos_integer()

Get the version number for a prompt.

Returns the version from the prompt's metadata, or 1 if not specified. For compositions, returns the version of the first component.