View Source Store.Prompt (fnord v0.5.4)

The ask subcommand saves useful prompts to the store. Saved prompts are accompanied by a title and a list of example questions for which the prompt is appropriate.

When a prompt is saved, an embedding is generated from it to make the prompt (and the questions to which it applies) searchable.

Whenever a prompt is modified or refined, the previous version is archived to the prompt's store dir with a version number:

<$STORE>/prompts/<$PROMPT_ID>./v<$VERSION>/

File structure:

$HOME/
  -> .fnord/
    -> prompts/
      -> <$PROMPT_ID>/
        -> v1
          -> title.md
          -> prompt.md
          -> questions.md
          -> embeddings.json
        -> v2
          -> title.md
          -> prompt.md
          -> questions.md
          -> embeddings.json

There are a number of initial prompts that are installed the first time the prompt store is searched. These prompts are defined in data/prompts.yaml. When a new version of fnord is installed, the next time the prompt store is searched, the prompts will be updated to the latest versions. "Default" prompts can be distinguished by using a title slug for its id, rather than a UUID.

Summary

Functions

Returns true if the prompt has been written to the store.

Create a new prompt with a random UUID.

Create a new prompt with the given ID. This is used to access an existing prompt. If id is nil, acts as an alias for new/0.

Reads the prompt from the store. If the prompt does not exist, an error will be returned ({:error, :not_found}). Returns an :ok tuple with the prompt's title, prompt text, questions, and embeddings

Reads the prompt from the store at the given version. Returns the same information as read/1.

Returns the current version of the prompt. Prompts are automatically versioned with incremental numbers for tracking.

Saves the prompt to the store. If the prompt already exists but thew title, prompt_text, or questions have changed, it will be given an incremented version number. If they have not changed, an error will be returned ({:error, {:prompt_exists, id}}).

Functions

exists?(prompt)

Returns true if the prompt has been written to the store.

install_initial_strategies()

list_versions(prompt)

new()

Create a new prompt with a random UUID.

new(id)

Create a new prompt with the given ID. This is used to access an existing prompt. If id is nil, acts as an alias for new/0.

read(prompt)

Reads the prompt from the store. If the prompt does not exist, an error will be returned ({:error, :not_found}). Returns an :ok tuple with the prompt's title, prompt text, questions, and embeddings:

{:ok,
 %{
   title: title,
   prompt: prompt_text,
   questions: questions,
   embeddings: embeddings,
   version: version
 }}

read(prompt, version)

Reads the prompt from the store at the given version. Returns the same information as read/1.

read_embeddings(prompt)

read_embeddings(prompt, version)

read_prompt(prompt)

read_prompt(prompt, version)

read_questions(prompt)

read_questions(prompt, version)

read_title(prompt)

read_title(prompt, version)

version(prompt)

Returns the current version of the prompt. Prompts are automatically versioned with incremental numbers for tracking.

write(prompt, title, prompt_text, questions, indexer \\ Indexer)

Saves the prompt to the store. If the prompt already exists but thew title, prompt_text, or questions have changed, it will be given an incremented version number. If they have not changed, an error will be returned ({:error, {:prompt_exists, id}}).