Skip to content

Commit dcef26d

Browse files
Merge pull request #10 from docker/slim/args
Deprecate positional args
2 parents edb895a + b38e689 commit dcef26d

File tree

20 files changed

+543
-231
lines changed

20 files changed

+543
-231
lines changed

README.md

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ following command.
1313
docker run --rm \
1414
-v /var/run/docker.sock:/var/run/docker.sock \
1515
--mount type=volume,source=docker-prompts,target=/prompts \
16-
vonwig/prompts:latest $PWD \
17-
jimclark106 \
18-
darwin \
19-
"github:docker/labs-make-runbook?ref=main&path=prompts/lazy_docker"
16+
vonwig/prompts:latest --host-dir $PWD \
17+
--user jimclark106 \
18+
--platform darwin \
19+
--prompts-dir "github:docker/labs-make-runbook?ref=main&path=prompts/lazy_docker"
2020
```
2121

2222
The four arguments are
@@ -33,10 +33,10 @@ docker run --rm \
3333
-v /var/run/docker.sock:/var/run/docker.sock \
3434
--mount type=bind,source=$PWD,target=/app/my_prompts \
3535
--workdir /app \
36-
vonwig/prompts:latest $PWD \
37-
jimclark106 \
38-
darwin \
39-
my_prompts
36+
vonwig/prompts:latest --host-dir $PWD \
37+
--user jimclark106 \
38+
--platform darwin \
39+
--prompts-dir my_prompts
4040
```
4141

4242
## Running a Conversation Loop
@@ -54,10 +54,10 @@ docker run --rm \
5454
--mount type=bind,source=$HOME/.openai-api-key,target=/root/.openai-api-key \
5555
vonwig/prompts:latest \
5656
run \
57-
$PWD \
58-
$USER \
59-
"$(uname -o)" \
60-
"github:docker/labs-githooks?ref=main&path=prompts/git_hooks"
57+
--host-dir $PWD \
58+
--user $USER \
59+
--platform "$(uname -o)" \
60+
--prompts "github:docker/labs-githooks?ref=main&path=prompts/git_hooks"
6161
```
6262

6363
### Running a Conversation Loop with Local Prompts
@@ -81,24 +81,23 @@ docker run --rm \
8181
--mount type=bind,source=$HOME/.openai-api-key,target=/root/.openai-api-key \
8282
vonwig/prompts:latest \
8383
run \
84-
$PWD \
85-
$USER \
86-
"$(uname -o)" \
87-
my_prompts
84+
--host-dir $PWD \
85+
--user $USER \
86+
--platform "$(uname -o)" \
87+
--prompts-dir my_prompts
8888
```
8989

9090
## GitHub refs
9191

92-
Prompts are fetched from a GitHub repository. The mandatory parts of the ref are `github:{owner}/{repo}`
92+
Prompts can be fetched from a GitHub repository when using the `--prompts` arg. The mandatory parts of the ref are `github:{owner}/{repo}`
9393
but optional `path` and `ref` can be added to pull prompts from branches, and to specify a subdirectory
9494
where the prompt files are located in the repo.
9595

9696
## Function volumes
9797

9898
Every function container will have a shared volume mounted into the container at `/thread`.
9999
The volume is intended to be ephemeral and will be deleted at the end of the run. However, the volume
100-
can be saved for inspection by passing the argument `--save-thread-volume`. The name of the shared volume
101-
can also be controlled using `--thread-id <name>` but will normally just be a guid.
100+
can be saved for inspection by passing the argument `--thread-id`.
102101

103102
## Output json-rpc notifications
104103

dev/ollama_openai_tools.clj

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
(ns ollama-openai-tools
2+
(:require [openai]
3+
[prompts]
4+
[babashka.fs :as fs]))
5+
6+
(openai/openai
7+
{:model "mistral-nemo"
8+
:stream false
9+
:temperature -1
10+
:url "http://localhost:11434/v1/chat/completions"
11+
:messages [{:role "user" :content "Use a tool to lint the clojure code in this project by passing the arguments `--lint .`."}]
12+
:tools (prompts/collect-functions (fs/file "prompts/clj-kondo/"))}
13+
println)
14+
15+
(openai/openai
16+
{:model "llama3.1"
17+
:stream true
18+
:url "http://localhost:11434/v1/chat/completions"
19+
:messages [{:role "user" :content "Use a tool to the clojure code in this project by passing the arguments `--lint .`."}]
20+
:tools (prompts/collect-functions (fs/file "prompts/clj-kondo/"))}
21+
println)
22+
23+
(openai/openai
24+
{:stream false
25+
:messages [{:role "user" :content "Lint the clojure code in this project by passing the arguments `--lint .`."}]
26+
:tools (prompts/collect-functions (fs/file "prompts/clj-kondo/"))}
27+
println)

extractors/registry.edn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"--vs-machine-id"
66
"none"
77
"--workspace"
8-
"/docker"]}
8+
"/project"]}
99
{:name "go-linguist",
1010
:image "vonwig/go-linguist:latest",
1111
:command ["-json"],

prompts/clj-kondo/README.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,27 @@ docker run --rm \
3434
--mount type=bind,source=/Users/slim/docker/labs-ai-tools-for-devs/prompts,target=/app/local \
3535
--workdir /app \
3636
vonwig/prompts:local run \
37-
/Users/slim/docker/labs-ai-tools-for-devs \
38-
jimclark106 \
39-
"$(uname -o)" \
40-
local/clj-kondo \
37+
--host-dir /Users/slim/docker/labs-ai-tools-for-devs \
38+
--user jimclark106 \
39+
--platform "$(uname -o)" \
40+
--prompts local/clj-kondo \
4141
--pat "$(cat ~/.secrets/dockerhub-pat-ai-tools-for-devs.txt)" \
42-
--thread-id "clj-kondo" \
43-
--save-thread-volume
42+
--thread-id "clj-kondo"
43+
```
44+
45+
```sh
46+
bb -m prompts run \
47+
--host-dir /Users/slim/docker/labs-ai-tools-for-devs \
48+
--user jimclark106 \
49+
--platform "$(uname -o)" \
50+
--prompts-dir prompts/clj-kondo \
51+
--url http://localhost:11434/v1/chat/completions \
52+
--model "llama3-groq-tool-use:latest" \
53+
--thread-id "clj-kondo"
4454
```
4555

4656
## TODO
4757

4858
- [ ] the clj-kondo function is downloading into an `\?/.m2` repository in the project root. We can't have this.
4959

60+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
You are an assistant who specializes in authoring Dockerfiles for projects.
2+
Since you are an expert and know about their project, be definitive about recommendations.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Write Dockerfiles using three stages. Here are the three stages to use:
2+
1. the first stage should be called "deps"
3+
and it should fetch the runtime dependencies using npm ci
4+
`with the --omit=dev` flag.
5+
2. The second stage should be called build
6+
and it should be based on the deps stage.
7+
It should run npm ci first and then it should run npm build
8+
3. The third stage should start with a FROM line that uses the `node` base image.
9+
This stage should do then do three things.
10+
1. it copies the node_modules directory from the deps stage.
11+
2. it copies the dist directory from the build stage.
12+
3. it should then create an entrypoint that runs npm start
13+
14+
If you need to use a RUN statement containing `npm ci` always
15+
add the argument `--mount=type=cache,target=/root/.npm` to the RUN instruction.
16+
The `--mount` argument should be placed between the word RUN and the npm command.
17+
This will cache the npm packages in the docker build cache and speed up the build process.
18+
19+
* Generate a Dockerfile for an NPM project.
20+
* Call a function to get the recommended tag for repository `node`
21+
* In each FROM line in the Dockerfile, use the recommended tag.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
extractors:
3+
- name: go-linguist
4+
tool_choice: auto
5+
model: gpt-4
6+
stream: true
7+
functions:
8+
- name: docker_scout_tag_recommendation
9+
---
10+
11+
# Background
12+
13+
These prompts add Dockerfile authoring skills to the assistant.
14+
15+
* the [user prompts](100_user_prompt.md) direct the assist to extract details about the project, and then write a Dockerfile to the root of the project.
16+
* the [npm best practices](npm-best-practices.md) is are added to the system prompts whenever the assist detects that this is an NPM project.
17+
18+
## functions
19+
20+
These instructions in these prompts rely on 3 functions
21+
22+
1. `analyze_project` - requires read-only access to the project and extracts details from the project to give the assistant context for authoring the Dockerfile
23+
2. `write_files` - has read-write access to the project and will write Dockerfiles so that developers don't have to copy and paste data out of a chat.
24+
3. `docker_scout_tag_recommendation` - uses Docker Scout to improve the choice tag selection during code generation.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
You are an assistant who specializes in authoring Dockerfiles for projects.
2+
Since you are an expert and know about their project, be definitive about recommendations.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Write Dockerfiles for NPM projects using three stages. Do these three steps sequentially.
2+
* the first node depemdencies stage should be called "deps"
3+
and it should fetch the runtime dependencies using npm ci
4+
`with the --omit=dev` flag.
5+
* The second Dockerfile stage should be called build
6+
and it should be based on the deps stage.
7+
It should run npm ci and then npm build
8+
* The third Dockerfile stage should select a base image
9+
that is recommended by Scout and use that in the FROM line.
10+
This stage should do then do three things.
11+
1. it copies the node_modules directory from the deps stage.
12+
2. it copies the dist directory from the build stage.
13+
3. it then runs npm start
14+
15+
If you need to use a RUN statement containing `npm ci` always
16+
add the argument `--mount=type=cache,target=/root/.npm` to the RUN instruction.
17+
The `--mount` argument should be placed between the word RUN and the npm command.
18+
This will cache the npm packages in the docker build cache and speed up the build process.
19+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
extractors:
3+
- name: go-linguist
4+
tool_choice: auto
5+
model: gpt-4
6+
stream: true
7+
functions:
8+
- name: docker_scout_tag_recommendation
9+
---
10+
11+
# Background
12+
13+
These prompts add Dockerfile authoring skills to the assistant.
14+
15+
* the [user prompts](100_user_prompt.md) direct the assist to extract details about the project, and then write a Dockerfile to the root of the project.
16+
* the [npm best practices](npm-best-practices.md) is are added to the system prompts whenever the assist detects that this is an NPM project.
17+
18+
## functions
19+
20+
These instructions in these prompts rely on 3 functions
21+
22+
1. `analyze_project` - requires read-only access to the project and extracts details from the project to give the assistant context for authoring the Dockerfile
23+
2. `write_files` - has read-write access to the project and will write Dockerfiles so that developers don't have to copy and paste data out of a chat.
24+
3. `docker_scout_tag_recommendation` - uses Docker Scout to improve the choice tag selection during code generation.

0 commit comments

Comments
 (0)