Skip to content

Commit 7582a73

Browse files
role is optional in h1 prompt headers
- defaults to user
1 parent 08a4440 commit 7582a73

File tree

10 files changed

+136
-7
lines changed

10 files changed

+136
-7
lines changed

docs/content/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ breadcrumbs: false
1010
{{< cards >}}
1111
{{< card link="tools" title="AI Tools for Devs" subtitle="Using Docker to extend AI systems with custom tool runtimes" image="https://spec.modelcontextprotocol.io/images/dark.svg" tag="Incubating">}}
1212
{{< card link="speculative" title="Speculative Execution" image="img/speculative.png" tag="Incubating">}}
13-
{{< card link="projects/vscode.md" title="Docker VSCode Extension" image="img/vscode.png" tag="Engineering">}}
13+
{{< card link="projects/vscode" title="Docker VSCode Extension" image="img/vscode.png" tag="Engineering">}}
1414
{{< /cards >}}

docs/content/projects/vscode.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
# Background
3+
4+
We worked on a VSCode extension to add a new Docker Language Service. The language sevice is IDE agnostic and can be attached to IDEs like Intellij, and neovim.
5+
6+
The [current extension releases](https://github.com/docker/docker-vscode-extension/releases) are available internally to Docker employees.

docs/content/tools/_index.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
---
2-
title: Tools For Devs (Model Context Protocol)
2+
title: Tools For Devs
33
weight: 1
44
---
5+
6+
## AI Tools for Dev
7+
8+
9+
10+
## Model Context Protocol

docs/content/tools/docs/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Documentation
2+
title: Tools Project Documentation
33
---
44

55

docs/content/tools/docs/authoring-prompts.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: Authoring Prompts
3+
weight: 2
4+
---
5+
16
# Prompt files
27

38
A prompt is markdown content with a preamble describing tools available to the agent when executing this prompt.
@@ -107,3 +112,96 @@ Run the curl command, in silent mode, to fetch gists for user slimslenderslacks
107112
Set streaming to false if you're using Ollama for tool calling. Ollama does not currently stream tool calls.
108113
{{< /callout >}}
109114

115+
## Prompt Templates
116+
117+
It is common for prompts to contain parameters that are either extracted from a user interaction
118+
or, in the case of RAG, are populated by some sort of retrieval process. Markdown prompts can also
119+
contain template parameters.
120+
121+
For example, the above curl example could be re-written as a template with a ``{{ user }}`` parameter.
122+
123+
```markdown
124+
---
125+
tools:
126+
- name: curl
127+
url: http://localhost/v1/chat/completions
128+
stream: false
129+
model: llama3.1
130+
---
131+
132+
# prompt
133+
134+
Run the curl command, in silent mode, to fetch gists for user {{ user }} from GitHub.
135+
```
136+
137+
### Binding values during testing
138+
139+
When running in VSCode, you can set values of the parameters in the markdown preamble.
140+
141+
```markdown
142+
---
143+
parameter-values:
144+
user: slimslenderslacks
145+
---
146+
```
147+
148+
### Extractors
149+
150+
Extractors are container functions that can be used to extract values when the prompt has been deployed
151+
to a server. These extractors are also used to populate default values for a prompt when it is used from
152+
an MCP client.
153+
154+
Extractor definitions also follow the pattern of compose services. They are just docker images but with
155+
the additional requirement that they should write `application/json` to stdout. This json will be used to
156+
populate the context for binding parameters in the prompt template.
157+
158+
```markdown
159+
---
160+
extractors:
161+
- name: linguist
162+
image: vonwig/go-linguist:latest
163+
command:
164+
- -json
165+
---
166+
```
167+
168+
We can create lists if the extractor json output has array types. For example,
169+
if we run the linguist tool to extract language from a project, our prompt can list
170+
them using the following template. You need to be familar with the json format output
171+
by linguist (eg that it creates lists of maps with a `language` key).
172+
173+
```markdown
174+
---
175+
extractors:
176+
- name: linguist
177+
---
178+
179+
# prompt
180+
181+
{{#linguist}}
182+
183+
This project contains {{language}} code.
184+
185+
{{/linguist}}
186+
187+
```
188+
189+
### Template Engine
190+
191+
We support two templating engines today.
192+
193+
* [mustache](https://mustache.github.io/mustache.5.html) is the default
194+
* [django](https://docs.djangoproject.com/en/5.1/topics/templates/)
195+
196+
If you want to use django, then add the following field in the markdown preamble.
197+
198+
```markdown
199+
---
200+
prompt-format: "django"
201+
---
202+
```
203+
204+
### MCP arguments
205+
206+
207+

docs/content/tools/docs/claude-desktop.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: Using Claude Desktop
3+
weight: 3
34
---
45

56
Enable mcp_run in your claude_desktop_config.json file using the following snippet. See the [quickstart for Claude Desktop Users](https://modelcontextprotocol.io/quickstart/user) for more details.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: Quick Start
3+
weight: 1
4+
---
5+
6+

docs/content/tools/mcp.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
title: Model Context Protocol
3+
---

prompts/examples/curl.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ tools:
44
- name: curl
55
---
66

7-
# prompt user
7+
# prompt
88

99
Run the curl command, in silent mode, to fetch gists for user slimslenderslacks from GitHub.
1010

src/markdown.clj

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@
3131
(update 0 (fn [s] (.substring ^String s (dec c1))))
3232
(update (dec (count lines)) (fn [s] (.substring ^String s 0 (- c2 c1))))))))
3333

34-
(def prompt-pattern #"(?i)\s*prompt\s+(\w+)\s?")
34+
(def prompt-pattern-with-role-capture #"(?i)\s*prompt\s+(\w+)\s?")
35+
(def prompt-pattern #"(?i)\s*prompt\s?(\w+)?\s?")
3536

3637
(defn extract-role [s]
3738
(second
38-
(re-find prompt-pattern s)))
39+
(re-find prompt-pattern-with-role-capture s)))
3940

4041
;; headings that include the word Prompt
4142
(defn prompt-section? [content node]
@@ -51,10 +52,18 @@
5152
;; extract Role from Prompt ....
5253
(defn node-content [content node]
5354
{:role
54-
(-> node (nth 2) (nth 3) (nth 1) (from-range content) (extract-role))
55+
(or (-> node (nth 2) (nth 3) (nth 1) (from-range content) (extract-role)) "user")
5556
:content
5657
(remove-first-line (from-range (nth node 1) content))})
5758

59+
(comment
60+
(extract-role "prompt user")
61+
(extract-role "prompt")
62+
(extract-role "prompt user and more")
63+
(re-matches prompt-pattern "prompt")
64+
(re-matches prompt-pattern "prompt user")
65+
(re-matches prompt-pattern "prompt user"))
66+
5867
(defn extract-prompts [content ast]
5968
(->>
6069
(iterate zip/next (zip/seq-zip ast))

0 commit comments

Comments
 (0)