|
| 1 | + |
| 2 | +## Running Prompts |
| 3 | + |
| 4 | +To generate prompts for a project, clone a repo into `$PWD` and run the |
| 5 | +following command. |
| 6 | + |
| 7 | +```sh |
| 8 | +docker run --rm \ |
| 9 | + -v /var/run/docker.sock:/var/run/docker.sock \ |
| 10 | + --mount type=volume,source=docker-prompts,target=/prompts \ |
| 11 | + vonwig/prompts:latest $PWD \ |
| 12 | + jimclark106 \ |
| 13 | + darwin \ |
| 14 | + "github:docker/labs-make-runbook?ref=main&path=prompts/lazy_docker" |
| 15 | +``` |
| 16 | + |
| 17 | +The four arguments are |
| 18 | +* `project root dir on host`, |
| 19 | +* `docker login username`, |
| 20 | +* `platform`, |
| 21 | +* `github ref` for prompt files. |
| 22 | + |
| 23 | +If you need to test prompts before you push, you can bind a local prompt directory instead of using |
| 24 | +a GitHub ref. For example, to test some local prompts in a directory named `my_prompts`, run: |
| 25 | + |
| 26 | +```sh |
| 27 | +docker run --rm \ |
| 28 | + -v /var/run/docker.sock:/var/run/docker.sock \ |
| 29 | + --mount type=bind,source=$PWD,target=/app/my_prompts \ |
| 30 | + --workdir /app |
| 31 | + vonwig/prompts:latest $PWD \ |
| 32 | + jimclark106 \ |
| 33 | + darwin \ |
| 34 | + my_prompts |
| 35 | +``` |
| 36 | + |
| 37 | +## Running a Conversation Loop |
| 38 | + |
| 39 | +```sh |
| 40 | +docker run --rm \ |
| 41 | + -it \ |
| 42 | + -v /var/run/docker.sock:/var/run/docker.sock \ |
| 43 | + --mount type=volume,source=docker-prompts,target=/prompts \ |
| 44 | + --mount type=bind,source=$HOME/.openai-api-key,target=/root/.openai-api-key \ |
| 45 | + vonwig/prompts:latest \ |
| 46 | + run \ |
| 47 | + $PWD \ |
| 48 | + $USER \ |
| 49 | + "$(uname -o)" \ |
| 50 | + "github:docker/labs-githooks?ref=main&path=prompts/git_hooks" |
| 51 | +``` |
| 52 | + |
| 53 | +### Running a Conversation Loop with Local Prompts |
| 54 | + |
| 55 | +If you want to run a conversation loop with local prompts then you need to think about two different directories, the one that the root of your project ($PWD above), |
| 56 | +and the one that contains your prompts (let's call that $PROMPTS_DIR). Here's a command line for running the prompts when our $PWD is the project root and we've set the environment variable |
| 57 | +$PROMPTS_DIR to point at the directory containing our prompts. |
| 58 | + |
| 59 | +```sh |
| 60 | +docker run --rm \ |
| 61 | + -it \ |
| 62 | + -v /var/run/docker.sock:/var/run/docker.sock \ |
| 63 | + --mount type=bind,source=$PROMPTS_DIR,target=/app/my_prompts \ |
| 64 | + --workdir /app |
| 65 | + --mount type=volume,source=docker-prompts,target=/prompts \ |
| 66 | + --mount type=bind,source=$HOME/.openai-api-key,target=/root/.openai-api-key \ |
| 67 | + vonwig/prompts:latest \ |
| 68 | + run \ |
| 69 | + $PWD \ |
| 70 | + $USER \ |
| 71 | + "$(uname -o)" \ |
| 72 | + my_prompts |
| 73 | +``` |
| 74 | + |
| 75 | +## GitHub refs |
| 76 | + |
| 77 | +Prompts are fetched from a GitHub repository. The mandatory parts of the ref are `github:{owner}/{repo}` |
| 78 | +but optional `path` and `ref` can be added to pull prompts from branches, and to specify a subdirectory |
| 79 | +where the prompt files are located in the repo. |
| 80 | + |
| 81 | +### Prompt file layout |
| 82 | + |
| 83 | +Each prompt directory should contain a README.md describing the prompts and their purpose. Each prompt file |
| 84 | +is a markdown document that supports moustache templates for subsituting context extracted from the project. |
| 85 | + |
| 86 | +``` |
| 87 | +prompt_dir/ |
| 88 | +├── 010_system_prompt.md |
| 89 | +├── 020_user_prompt.md |
| 90 | +└── README.md |
| 91 | +``` |
| 92 | + |
| 93 | +* ordering of messages is determined by filename sorting |
| 94 | +* the role is encoded in the name of the file |
| 95 | + |
| 96 | +### Moustache Templates |
| 97 | + |
| 98 | +The prompt templates can contain expressions like {{dockerfiles}} to add information |
| 99 | +extracted from the current project. Examples of facts that can be added to the |
| 100 | +prompts are: |
| 101 | + |
| 102 | +* `{{platform}}` - the platform of the current development environment. |
| 103 | +* `{{username}}` - the DockerHub username (and default namespace for image pushes) |
| 104 | +* `{{languages}}` - names of languages discovered in the project. |
| 105 | +* `{{project.dockerfiles}}` - the relative paths to local DockerFiles |
| 106 | +* `{{project.composefiles}}` - the relative paths to local Docker Compose files. |
| 107 | + |
| 108 | +The entire `project-facts` map is also available using dot-syntax |
| 109 | +forms like `{{project-facts.project-root-uri}}`. All moustache template |
| 110 | +expressions documented [here](https://github.com/yogthos/Selmer) are supported. |
| 111 | + |
| 112 | +## Building |
| 113 | + |
| 114 | +```sh |
| 115 | +#docker:command=build |
| 116 | + |
| 117 | +docker build -t vonwig/prompts:local -f Dockerfile . |
| 118 | +``` |
| 119 | + |
0 commit comments