Skip to content

Commit

Permalink
Support single-file prompts
Browse files Browse the repository at this point in the history
* adding --prompts-file arg to point just at a README.md with
  prompts sections
  • Loading branch information
slimslenderslacks committed Aug 27, 2024
1 parent c4cd68b commit 9c3a74d
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 98 deletions.
2 changes: 0 additions & 2 deletions prompts/qrencode/100_user_prompts.md

This file was deleted.

8 changes: 8 additions & 0 deletions prompts/qrencode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ functions:
image: vonwig/qrencode:latest
---

# Prompt user

Generate a QR code for the
url https://github.com/docker/labs-ai-tools-for-devs and write it to file `qrcode.png`.

# Result

This function generates a QR code for a URL. The QR code is saved as a PNG file.
39 changes: 39 additions & 0 deletions runbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
bb -m prompts --help
```

### run without --host-dir

```sh
bb -m prompts
```

### Plain prompt Generation

```sh
Expand Down Expand Up @@ -58,6 +64,8 @@ bb -m prompts run \
--url http://localhost:11434/v1/chat/completions
```

TODO - this should fail better because the prompts-dir is not valid.

```sh
bb -m prompts run \
--host-dir /Users/slim/docker/labs-make-runbook \
Expand Down Expand Up @@ -133,6 +141,37 @@ bb -m prompts run \
--model "llama3-groq-tool-use:latest"
```

#### Test single file prompts

```sh
rm ~/docker/labs-make-runbook/qrcode.png
```

```sh
bb -m prompts run \
--host-dir /Users/slim/docker/labs-make-runbook \
--user jimclark106 \
--platform darwin \
--prompts-file prompts/qrencode/README.md
```

```sh
open ~/docker/labs-make-runbook/qrcode.png
```

```sh
bb -m prompts run \
--host-dir /Users/slim/docker/labs-make-runbook \
--user jimclark106 \
--platform darwin \
--prompts-file prompts/qrencode/README.md \
--url http://localhost:11434/v1/chat/completions \
--model "llama3.1" \
--nostream \
--debug
```


#### Using Containerized runner

```sh
Expand Down
4 changes: 2 additions & 2 deletions src/git.clj
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
(fs/create-dirs default-dir)
default-dir))))

(defn prompt-dir
(defn prompt-file
"returns the path or nil if the github ref does not resolve
throws if the path in the repo does not exist or if the clone fails"
[ref]
Expand Down Expand Up @@ -85,7 +85,7 @@
(fs/create-dir prompts-cache)
(def x "github:docker/labs-make-runbook?ref=main&path=prompts/docker")
(def git-ref (parse-github-ref x))
(prompt-dir "github:docker/labs-make-runbook?ref=main&path=prompts/docker")
(prompt-file "github:docker/labs-make-runbook?ref=main&path=prompts/docker")
(parse-github-ref nil)
(parse-github-ref "")
(parse-github-ref "github:docker/labs-make-runbook")
Expand Down
9 changes: 5 additions & 4 deletions src/markdown.clj
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@
(filter heading-1-section?)
(map (comp zip/node zip/up zip/up))
(filter (partial prompt-section? content))
(map (partial node-content content))
(pprint)))
(map (partial node-content content))))

(defn parse-markdown [content]
(let [x (docker/function-call-with-stdin
Expand All @@ -66,11 +65,13 @@
(docker/finish-call x)))]
(->> s
(edn/read-string)
(extract-prompts content))))
(extract-prompts content)
(into []))))

(comment
(string/split content #"\n")

(def content (slurp "test.md"))
(def content (slurp "prompts/qrencode/README.md" ))
(pprint (parse-markdown content))

(def t
Expand Down
Loading

0 comments on commit 9c3a74d

Please sign in to comment.