View Source Store.Prompt (fnord v0.5.3)
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.jsonThere 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
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:
{:ok,
%{
title: title,
prompt: prompt_text,
questions: questions,
embeddings: embeddings,
version: version
}}
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}}).