View Source Store.Strategy (fnord v0.5.6)

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 research strategy prompt is saved, an embedding is generated from it to make the prompt (and the questions to which it applies) searchable.

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

File structure:

$HOME/
  -> .fnord/
    -> prompts/
      -> <$PROMPT_ID>/
        -> 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.

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

Saves the prompt to the store. If the prompt already exists but thew title, prompt_text, or questions have changed, it will be replaced by the new version. If they have not changed, an error will be returned: {:error, {:strategy_exists, id}}

Functions

exists?(prompt)

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

install_initial_strategies()

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,
 }}

read_embeddings(prompt)

read_prompt(prompt)

read_questions(prompt)

read_title(prompt)

write(prompt, title, prompt_text, questions)

Saves the prompt to the store. If the prompt already exists but thew title, prompt_text, or questions have changed, it will be replaced by the new version. If they have not changed, an error will be returned: {:error, {:strategy_exists, id}}