Prompt

Prompt logo

Prompt is a programming language based on relational ai prompts.

It's useful because it helps you chain multiple ai sessions together (REPL loops in programming lingo), and weave them into the programming tools you already know.

Prompt is a tiny language, you can learn it in less than fifteen minutes.

Download

Examples

                    
table
    direction: >
        Answer this question with a yes or no answer. Is this input valid JSON
        that can be used with Nodes console.table method cleanly?
{
    match $AI {
        (?i:^yes) => `node --eval "console.table(JSON.parse('$USER'))"`
    }
}
                    
                    

Example Output
    USER: {"foo":[ 1, 2, 3, 4]}
    ┌─────────┬───┬───┬───┬───┐
    │ (index) │ 0 │ 1 │ 2 │ 3 │
    ├─────────┼───┼───┼───┼───┤
    │   foo   │ 1 │ 2 │ 3 │ 4 │
    └─────────┴───┴───┴───┴───┘
                        

Releases

You can find all the releases on Github. It's licensed under the MIT license, you can find the source code here.

Using Prompt

Prompt files consist of a series of prompt declarations. Prompt declarations are just the following:

Names

    table
        direction: >
            Answer this question with a yes or no answer. Is this input valid JSON
            that can be used with Nodes console.table method cleanly?
    {
        match $AI {
            (?i:^yes) => `node --eval "console.table(JSON.parse('$USER'))"`
        }
    }
                
The names of prompts consist of alphanumeric characters or an underscore.

Options

    table
        direction: >
            Answer this question with a yes or no answer. Is this input valid JSON
            that can be used with Nodes console.table method cleanly?
    
    {
        match $AI {
            (?i:^yes) => `node --eval "console.table(JSON.parse('$USER'))"`
        }
    }
                

Options specified to a prompt are given as YAML. The following options are supported:

Bodies

This is where the magic happens. Prompt has a few statements you can use to stitch it together with with other prompts and your CLI programs.

The CLI Program

For now, executing prompt files is done from the Command Line. After getting prompt you can run prompts with

    OPEN_AI_API_KEY="INSERT_OPEN_AI_API_KEY_HERE" ./prompt ./path-to-prompt-file.pr
                    

Here's the --help

    ./prompt --help

    Usage: prompt [OPTIONS] 

    Arguments:
      (PATH)  Path to the main prompt file

    Options:
      -w, --watch (WATCH)  What session file to watch, if any
      -q, --quiet          By default, we output the result of commands in a
                            final position to stdout (the terminal). This will
                            suppress that output
      -h, --help           Print help
      -V, --version        Print version