Skip to content

Commit 9c3a74d

Browse files
Support single-file prompts
* adding --prompts-file arg to point just at a README.md with prompts sections
1 parent c4cd68b commit 9c3a74d

File tree

9 files changed

+173
-98
lines changed

9 files changed

+173
-98
lines changed

prompts/qrencode/100_user_prompts.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

prompts/qrencode/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,11 @@ functions:
1616
image: vonwig/qrencode:latest
1717
---
1818

19+
# Prompt user
20+
21+
Generate a QR code for the
22+
url https://github.com/docker/labs-ai-tools-for-devs and write it to file `qrcode.png`.
23+
24+
# Result
25+
26+
This function generates a QR code for a URL. The QR code is saved as a PNG file.

runbook.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
bb -m prompts --help
77
```
88

9+
### run without --host-dir
10+
11+
```sh
12+
bb -m prompts
13+
```
14+
915
### Plain prompt Generation
1016

1117
```sh
@@ -58,6 +64,8 @@ bb -m prompts run \
5864
--url http://localhost:11434/v1/chat/completions
5965
```
6066

67+
TODO - this should fail better because the prompts-dir is not valid.
68+
6169
```sh
6270
bb -m prompts run \
6371
--host-dir /Users/slim/docker/labs-make-runbook \
@@ -133,6 +141,37 @@ bb -m prompts run \
133141
--model "llama3-groq-tool-use:latest"
134142
```
135143

144+
#### Test single file prompts
145+
146+
```sh
147+
rm ~/docker/labs-make-runbook/qrcode.png
148+
```
149+
150+
```sh
151+
bb -m prompts run \
152+
--host-dir /Users/slim/docker/labs-make-runbook \
153+
--user jimclark106 \
154+
--platform darwin \
155+
--prompts-file prompts/qrencode/README.md
156+
```
157+
158+
```sh
159+
open ~/docker/labs-make-runbook/qrcode.png
160+
```
161+
162+
```sh
163+
bb -m prompts run \
164+
--host-dir /Users/slim/docker/labs-make-runbook \
165+
--user jimclark106 \
166+
--platform darwin \
167+
--prompts-file prompts/qrencode/README.md \
168+
--url http://localhost:11434/v1/chat/completions \
169+
--model "llama3.1" \
170+
--nostream \
171+
--debug
172+
```
173+
174+
136175
#### Using Containerized runner
137176

138177
```sh

src/git.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
(fs/create-dirs default-dir)
5353
default-dir))))
5454

55-
(defn prompt-dir
55+
(defn prompt-file
5656
"returns the path or nil if the github ref does not resolve
5757
throws if the path in the repo does not exist or if the clone fails"
5858
[ref]
@@ -85,7 +85,7 @@
8585
(fs/create-dir prompts-cache)
8686
(def x "github:docker/labs-make-runbook?ref=main&path=prompts/docker")
8787
(def git-ref (parse-github-ref x))
88-
(prompt-dir "github:docker/labs-make-runbook?ref=main&path=prompts/docker")
88+
(prompt-file "github:docker/labs-make-runbook?ref=main&path=prompts/docker")
8989
(parse-github-ref nil)
9090
(parse-github-ref "")
9191
(parse-github-ref "github:docker/labs-make-runbook")

src/markdown.clj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@
5454
(filter heading-1-section?)
5555
(map (comp zip/node zip/up zip/up))
5656
(filter (partial prompt-section? content))
57-
(map (partial node-content content))
58-
(pprint)))
57+
(map (partial node-content content))))
5958

6059
(defn parse-markdown [content]
6160
(let [x (docker/function-call-with-stdin
@@ -66,11 +65,13 @@
6665
(docker/finish-call x)))]
6766
(->> s
6867
(edn/read-string)
69-
(extract-prompts content))))
68+
(extract-prompts content)
69+
(into []))))
7070

7171
(comment
72+
(string/split content #"\n")
7273

73-
(def content (slurp "test.md"))
74+
(def content (slurp "prompts/qrencode/README.md" ))
7475
(pprint (parse-markdown content))
7576

7677
(def t

0 commit comments

Comments
 (0)