README.md in prompt_manager-0.4.0 vs README.md in prompt_manager-0.4.1
- old
+ new
@@ -13,10 +13,14 @@
- [Usage](#usage)
- [Overview](#overview)
- [Generative AI (gen-AI)](#generative-ai-gen-ai)
- [What does a keyword look like?](#what-does-a-keyword-look-like)
- [All about directives](#all-about-directives)
+ - [Example Prompt with Directives](#example-prompt-with-directives)
+ - [Accessing Directives](#accessing-directives)
+ - [Dynamic Directives](#dynamic-directives)
+ - [Executing Directives](#executing-directives)
- [Comments Are Ignored](#comments-are-ignored)
- [Storage Adapters](#storage-adapters)
- [FileSystemAdapter](#filesystemadapter)
- [Configuration](#configuration)
- [prompts_dir](#prompts_dir)
@@ -72,14 +76,16 @@
#### All about directives
A directive is a line in the prompt text that starts with the two characters '//' - slash slash - just like in the old days of IBM JCL - Job Control Language. A prompt can have zero or more directives. Directives can have parameters and can make use of keywords.
-The `prompt_manager` only collections directives. It extracts keywords from directive lines and provides the substitution of those keywords with other text just like it does for the prompt. Remember a directive is part of the prompt.
+The `prompt_manager` only collects directives. It extracts keywords from directive lines and provides the substitution of those keywords with other text just like it does for the prompt.
-Here is an example problem with comments, directives and keywords:
+##### Example Prompt with Directives
+Here is an example prompt text file with comments, directives and keywords:
+
```
# prompts/sing_a_song.txt
# Desc: Has the computer sing a song
//TextToSpeech [LANGUAGE] [VOICE NAME]
@@ -88,26 +94,52 @@
__END__
Computers will never replace Frank Sinatra
```
+##### Accessing Directives
+
Getting directives from a prompt is as easy as getting the kewyords:
```ruby
prompt = PromptManager::Prompt.new(...)
prompt.keywords #=> an Array
-prompt.directives #=> a Hash
+prompt.directives #=> an Array of entries like: ['directive', 'parameters']
# to_s builds the prompt by substituting
# values for keywords amd removing comments.
# The resulting text contains directives and
# prompt text ready for the LLM process.
puts prompt.to_s
```
-The Hash returned by the `prompt.directives` method has as its key the directive name (without the double-slash). Its also case-sensitive. So any typo made in editing the prompt with regard to the case of the directive's name will impact the backend processing of the prompt.
+The entries in the Array returned by the `prompt.directives` method is in the order that the directives were defined within the prompt. Each entry has two elements:
-The value for each key is a String exactly as entered in the prompt file.
+- directive name (without the // characters)
+- parameter string for the directive
+
+##### Dynamic Directives
+
+Since directies are collected after the keywords in the prompt have been substituted for their values, it is possible to have dynamically generated directives as part of a prompt. For example:
+
+```
+//[COMMAND] [OPTIONS]
+# or
+[SOMETHING]
+```
+... where [COMMAND] gets replaced by some directive name. [SOMETHING] could be replaced by "//directive options"
+
+##### Executing Directives
+
+The `prompt_manager` gem only collects directives. Executing those directives is left up to some down stream process. Here are some ideas on how directives could be used in prompt downstream process:
+
+- "//model gpt-5" could be used to set the LLM model to be used for a specific prompt.
+- "//backend mods" could be used to set the backend prompt processor on the command line to be the `mods` utility.
+- "//include path_to_file" could be used to add the contents of a file to the prompt.
+- "//chat" could be used to send the prompts and then start up a chat session about the prompt and its response.
+
+Its all up to how your application wants to support directives or not.
+
#### Comments Are Ignored
The `prompt_manager` gem ignores comments. A line that begins with the '#' - pound (aka hash) character - is a line comment. Any lines that follow a line that is '__END__ at the end of a file are considered comments. Basically the '__END__' the end of the file. Nothing is process following that line.