-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
28 changed files
with
3,284 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
- Run some prompts checked in to GitHub against a project in the current working directory. | ||
id:: 66d779c7-c1b7-40c6-a635-fa712da492de | ||
```sh | ||
docker run | ||
--rm -it \ | ||
--pull=always \ | ||
-v /var/run/docker.sock:/var/run/docker.sock \ | ||
--mount type=volume,source=docker-prompts,target=/prompts \ | ||
--mount type=bind,source=$HOME/.openai-api-key,target=/root/.openai-api-key \ | ||
vonwig/prompts:latest \ | ||
run \ | ||
--host-dir $PWD \ | ||
--user jimclark106 \ | ||
--platform darwin \ | ||
--prompts "github:docker/labs-make-runbook?ref=main&path=prompts/lazy_docker" | ||
``` | ||
- Most of this is boiler plate except: | ||
- the `--user` option in line 10 requires a valid DOCKER_HUB user name | ||
- the `--prompts` option in line 12 requires a valid [github reference]([[GitHub Refs]]) to some markdown prompts | ||
- if the project is located somewhere other than $PWD then the `--host-dir` will need to be updated. | ||
- Run a local prompt markdown file against a project in the current working directory. In this example, the prompts are not pulled from GitHub. Instead, our prompts are being developed in a directory called `$PROMPTS_DIR`. In this example, the local prompt file is `$PROMPTS_DIR/myprompts.md`. | ||
id:: 66d77f1b-1684-480d-ad7b-5e9f53292fe4 | ||
```sh | ||
docker run | ||
--rm -it \ | ||
--pull=always \ | ||
-v /var/run/docker.sock:/var/run/docker.sock \ | ||
--mount type=volume,source=docker-prompts,target=/prompts \ | ||
--mount type=bind,source=$HOME/.openai-api-key,target=/root/.openai-api-key \ | ||
--mount type=bind,source=$PROMPTS_DIR,target=/app/workdir \ | ||
--workdir /app/workdir \ | ||
vonwig/prompts:latest \ | ||
run \ | ||
--host-dir $PWD \ | ||
--user jimclark106 \ | ||
--platform darwin \ | ||
--prompts-file myprompts.md | ||
``` | ||
- Most of this is boiler plate except: | ||
- the `--user` option in line 12 requires a valid DOCKER_HUB user name | ||
- the `--prompts-file` option in line 14 is a relative path to a prompts file (relative to $PROMPTS_DIR) | ||
- if the project being analyzed is located somewhere other than $PWD then the `--host-dir` will need to be updated. | ||
- [[Running the Prompt Engine]] | ||
- [[Authoring Prompts]] | ||
- Here is a prompt file with lots of non-default metadata (it uses [extractors]([[Prompt Extractors]]), a [[tool]], and uses a local llm in [[ollama]]). It uses one system prompt, and one user prompt. Note that the user prompt contains a moustache template to pull data in from an extractor. | ||
id:: 66d7f3ff-8769-40b3-b6b5-fc4fceea879e | ||
|
||
```md | ||
--- | ||
extractors: | ||
- name: linguist | ||
image: vonwig/go-linguist:latest | ||
command: | ||
- -json | ||
output-handler: linguist | ||
tools: | ||
- name: findutils-by-name | ||
description: find files in a project by name | ||
parameters: | ||
type: object | ||
properties: | ||
glob: | ||
type: string | ||
description: the glob pattern for files that should be found | ||
container: | ||
image: vonwig/findutils:latest | ||
command: | ||
- find | ||
- . | ||
- -name | ||
model: llama3.1 | ||
url: http://localhost/v1/chat/completions | ||
stream: false | ||
--- | ||
|
||
# Prompt system | ||
|
||
You are an expert on analyzing project content. | ||
|
||
# Prompt user | ||
|
||
{{#linguist}} | ||
This project contains {{language}} code. | ||
{{/linguist}} | ||
|
||
Can you find any language specific project files and list them? | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
- An extractor is a function that runs before prompts are sent to an LLM. It can _extract_ some data from a project directory in order inject context into a set of prompts. | ||
id:: 66d87dd3-efa2-4eb3-ba92-5cc4c2f9700b | ||
- Create a docker container that expects a project bind mounted at `/project` and that writes `application/json` encoded data to `stdout`. The data written to `stdout` is what will be made available to any subsequent prompt templates. | ||
id:: 66d8a36a-432f-4d1a-a48c-edbe0224b182 | ||
To test your extractor function, run | ||
```sh | ||
docker run \ | ||
--rm -it \ | ||
--mount type=bind,source=$PWD,target=/project \ | ||
--workdir /project \ | ||
image-name:latest arg1 arg2 .... | ||
``` | ||
- this would make your current working directory available to the extractor at `/project` | ||
- you can also arrange to pass arguments to the extractor function when you define the extractor metadata | ||
- Once you have defined an extractor image (eg `image-name:latest`), create an entry in the prompt file to reference it. | ||
id:: 66d8a4f3-656d-42bf-b22a-60bba2d1887f | ||
``` | ||
--- | ||
extractors: | ||
- name: my-extractor | ||
image: image-name:latest | ||
command: | ||
- arg1 | ||
- arg2 | ||
--- | ||
# Prompt user | ||
I can now inject context into the prompt using moustache template syntax. | ||
{{#my-extractor}} | ||
{{.}} | ||
{{/my-extractor}} | ||
``` | ||
Read more about [moustache templates](https://mustache.github.io/mustache.5.html) | ||
- #log working on [[Prompt Extractors]] | ||
#log working on [[Authoring Prompts]] | ||
- A very simple prompt file that contains no metadata, and just a single user prompt is | ||
id:: 66d8a396-9268-4917-882f-da4c52b7b5dd | ||
``` | ||
# Prompt user | ||
Tell me about Docker! | ||
``` | ||
- #log working on [[GitHub Refs]] | ||
- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- [[conversation loop]] | ||
id:: 66d9d1e0-a13e-4d62-8db7-9eebb37714a8 | ||
- | ||
- |
Binary file not shown.
Binary file not shown.
Oops, something went wrong.