PtcRunner.Lisp.Prompts (PtcRunner v0.4.1)

View Source

Prompt loader for PTC-Lisp language references.

Loads prompt snippets from priv/prompts/ directory at compile time and provides compositions for common use cases.

Available Prompts

KeyDescription
:single_shotBase + single-shot rules
:multi_turnBase + multi-turn rules (return/fail, memory)

Raw Snippets

KeyFileDescription
:baselisp-base.mdCore language reference
:addon_single_shotlisp-addon-single_shot.mdSingle-shot mode rules
:addon_multi_turnlisp-addon-multi_turn.mdMulti-turn mode rules

Version Metadata

Prompt files can include optional 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.Prompts.get(:single_shot)

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

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

# Use in SubAgent
SubAgent.new(
  prompt: "...",
  system_prompt: %{language_spec: PtcRunner.Lisp.Prompts.get(:single_shot)}
)

Summary

Functions

Check if a prompt is archived.

Get a prompt by key.

Get a prompt by key, raising if not found.

List all available prompt keys (compositions, snippets, and archived).

List only current (non-archived) prompt keys.

List all prompts with descriptions.

Get full metadata for a prompt.

Get the version number for a prompt.

Functions

archived?(key)

@spec archived?(atom()) :: boolean()

Check if a prompt is archived.

Compositions are never archived.

Examples

iex> PtcRunner.Lisp.Prompts.archived?(:single_shot)
false

get(key)

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

Get a prompt by key.

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

Parameters

  • key - Atom identifying the prompt

Returns

The prompt content as a string, or nil if not found.

Examples

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

iex> prompt = PtcRunner.Lisp.Prompts.get(:multi_turn)
iex> String.contains?(prompt, "State Persistence")
true

get!(key)

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

Get a prompt by key, raising if not found.

Examples

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

list()

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

List all available prompt keys (compositions, snippets, and archived).

Examples

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

list_current()

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

List only current (non-archived) prompt keys.

Examples

iex> keys = PtcRunner.Lisp.Prompts.list_current()
iex> :single_shot in keys
true
iex> :base 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 for all available prompts. Archived prompts have "[archived]" appended to their description.

Examples

iex> list = PtcRunner.Lisp.Prompts.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.Prompts.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.