what_is_a_prompt_id - MadBomber/aia GitHub Wiki

What is a Prompt ID?

A prompt ID is the basename of a text file (extension *.txt) located in a prompts directory. The prompts directory is specified by the environment variable "AIA_PROMPTS_DIR". If this variable is not set, the default is in your HOME directory named ".prompts". It can also be set on the command line with the --prompts-dir option.

This file contains the context and instructions for the LLM to follow. The prompt ID is what you use as an option on the command line to specify which prompt text file to use. Prompt files can have comments, parameters, directives and ERB blocks along with the instruction text to feed to the LLM. It can also have shell commands and use system environment variables. Consider the following example:

#!/usr/bin/env aia run
# ~/.prompts/example.txt
# Desc: Be an example prompt with all? the bells and whistles

# Set the configuration for this prompt

//config model = gpt-4
//config temperature = 0.7
//config shell = true
//config erb = true
//config out_file = path/to/output.md

# Add some file content to the context/instructions

//include path/to/file
//shell cat path/to/file
$(cat path/to/file)

# Setup some workflows

//next next_prompt_id
//pipeline prompt_id_1, prompt_ie_2, prompt_id_3

# Execute some Ruby code

//ruby require 'some_library' # inserts into the context/instructions
<% some_ruby_things # not inserted into the context %>
<%= some_other_ruby_things # that are part of the context/instructions %>

Tell me how to do something for a $(uname -s) platform that would rename all
of the files in the directory $MY_DIRECTORY to have a prefix of for its filename
that is [PREFIX] and a ${SUFFIX}

<!--
  directives, ERB blocks and other junk can be used
  anywhere in the file mixing dynamic context/instructions with
  the static stuff.
-->

  ```markdown
  # Header 1 -- not a comment
  ## Header 2 -- not a comment
  ### Header 3, etc -- not a comment

    ```ruby
    # this is a comment; but it stays in the prompt
    puts "hello world" <!-- this is also a comment; but it gets removed -->
    ```
  Kewl!

END

Everything after the "END" line is not part of the context or instructions to the LLM.


Comments in a prompt text file are just there to document the prompt.  They are removed before the completed prompt is processed by the LLM.  This reduces token counts; but, more importantly it helps you remember why you structured your prompt they way you did - if you remembered to document your prompt.

That is just about everything including the kitchen sink that a pre-compositional parameterized prompt file can have.  It can be an executable with a she-bang line and a special system prompt name `run` as shown in the example.  It has line comments that use the `#` symbol. It had end of file block comments that appear after the "__END__" line.  It has directive command that begin with the double slash `//` - an homage to IBM JCL.  It has shell variables in both forms.  It has shell commands. It has parameters that default to a regex that uses square brackets and all uppercase characeters to define the parameter name whose value is to be given in a Q&A session before the prompt is sent to the LLM for processing.

AIA has the ability to define a workflow of prompt IDs with either the //next or //pipeline directives.

You could say that instead of the prompt being part of a program, a program can be part of the prompt. **The prompt is the code!**

By using ERB you can make parts of the context/instructions conditional. You can also use ERB to make parts of the context/instructions dynamic for example to pull information from a database or an API.

### Related Topics
- [Usage](usage)
- [Embedded Parameters](embedded_parameters)
- [Directive Syntax](directive_syntax)
- [Shell Integration](../shell)
- [Embedded Ruby](../erb)
- [Executable Prompts](../executable_prompts)
- [My Most Powerful Prompt](my_most_powerful_prompt) - See a simple but effective prompt example
⚠️ **GitHub.com Fallback** ⚠️