Skip to content

Commit 44c3f68

Browse files
author
colinmcneil
committed
Improve docs on authoring prompts with more examples
1 parent b679962 commit 44c3f68

File tree

1 file changed

+45
-70
lines changed

1 file changed

+45
-70
lines changed

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

Lines changed: 45 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,31 @@ weight: 2
77

88
A prompt is markdown content with a preamble describing tools available to the agent when executing this prompt.
99

10-
We use `h1` headers to delineate sections that should be exposed as prompts. When authoring this markdown, you can include non-prompt sections
11-
using headers that don't start with the word "prompt".
10+
## Prompt Headers
1211

12+
We use `h1` headers to delineate sections that should be exposed as prompts. `h1` headers that start with `prompt` will be sent to the model.
13+
14+
We use `h2` headers to indicate metadata about the prompt.
15+
16+
Both h1 and h2 headers are reserved keywords and should not be used in the markdown.
17+
18+
```markdown
19+
# prompt I am a prompt header
20+
## metadata I am metadata header
21+
### header I am a regular header
22+
```
23+
24+
You can also use h1 headers that don't start with the word "prompt" to organize your markdown.
25+
26+
```markdown
27+
# I am not a prompt header
28+
```
29+
30+
## Front-matter
31+
Prompt files support a yaml front-matter section that can be used to specify tools, models, and other metadata.
1332
Here's a simple prompt that will use Docker official curl container to fetch gists from Github.
1433

34+
## Example
1535

1636
```markdown
1737
---
@@ -24,9 +44,9 @@ tools:
2444
Run the curl command, in silent mode, to fetch gists for user slimslenderslacks from GitHub.
2545
```
2646

27-
## Tools
47+
## Adding Tools
2848

29-
Some tools, like curl, are available by default. However, the container for a tool can also be defined inline.
49+
Some tools, like curl, are available by default. However, you can add your own tools by adding a `tools` section to the front-matter.
3050

3151

3252
```markdown
@@ -54,65 +74,62 @@ Use ffmpeg to convert the file UsingPuppeteer.mp4 into an animated gif file at 1
5474
The output file should be named UsingPuppeteer.gif.
5575
```
5676

57-
The `name`, `description`, and `container` fields are mandatory, and you'll typically also have a `parameters` field to descript the json schema
58-
of the parameters that the agent will extract from the conversation.
77+
The `name`, `description`, and `container` fields are mandatory, and you'll typically also have a `parameters` field to descript the json schema of the parameters that the agent will extract from the conversation.
5978

6079
* `name` should uniquely identify the tool.
6180
* `description` is important. Good descriptions help the agent understand the tool and how to use it.
6281
* `container` sticks close to the format of a [compose service definition](https://docs.docker.com/reference/compose-file/services/) but does
6382
fully implement it. Many of the most common top-level arguments are supported (`image`, `command`, `volumes`)
6483

65-
You can interpolate into parameter properties into the container definition using strings with double curly braces. These substitutions also
66-
support filters, such as `into`, which spreads an array parameter. There are some common patterns for moving parameters into the container
67-
runtime that we support for making it easier to use standard images.
84+
You can interpolate into parameter properties into the container definition using strings with double curly braces. These substitutions also support filters, such as `into`, which spreads an array parameter. There are some common patterns for moving parameters into the container runtime that we support for making it easier to use standard images.
85+
86+
## Changing the Default Model
6887

69-
## Models
88+
If you don't specify a model in the preamble, the default model is currently set to be `gpt-4` on OpenAI. You can refer to other models and their endpoints by specifying the `model` and `url` fields.
7089

71-
If you don't specify a model in the preamble, the default model is currently set to be gpt-4 on openai. You can refer to other models and
72-
other endpoints using `model` and `url`.
90+
**We currentlysupport all models compatible with the OpenAI API or Anthropic API.**
7391

7492
```markdown
7593
---
7694
tools:
7795
- name: curl
78-
model: claude-3-5-sonnet-20241022
96+
model: llama3.2
97+
url: http://localhost:11434/v1
7998
---
8099

81100
# prompt
82101

83102
Run the curl command, in silent mode, to fetch gists for user slimslenderslacks from GitHub.
84103
```
85104

86-
If you specify an anthropic model, such as `model: claude-3-5-sonnet-20241022`, you do not need to specify the url. The correct anthropic
87-
endpoint will be used.
88-
89-
{{< callout type="info" >}}
90-
When using anthropic, do not change tool definitions to use `json_schema`. Use the openai standard of `parameters` - this will be automatically converted before making the api call.
91-
{{< /callout >}}
92-
93-
### OpenAI-compatible endpoints (Ollama)
94-
95-
You can specify other openai-compatible endpoints by including a `url`.
105+
### Pre-configured endpoints
106+
If you specify a model that we know about, such as `model: claude-3-5-sonnet-20241022`, you do not need to specify the url. The correct anthropic endpoint will be used. Currently, we support pre-configured endpoints for Anthropic and OpenAI.
96107

97108
```markdown
98109
---
99110
tools:
100111
- name: curl
101-
url: http://localhost/v1/chat/completions
102-
stream: false
103-
model: llama3.1
112+
model: claude-3-5-sonnet-20241022
104113
---
105114

106115
# prompt
107116

108117
Run the curl command, in silent mode, to fetch gists for user slimslenderslacks from GitHub.
109118
```
110119

120+
{{< callout type="info" >}}
121+
When using Anthropic models, do not change tool definitions to use `json_schema`. Use the OpenAI standard of `parameters` - this will be automatically converted before making the api call.
122+
{{< /callout >}}
123+
124+
### Streaming
125+
126+
The parameter `stream` can be used to control whether the tool call is streamed to the model. This is useful for models that do not support streaming. The default is `true`.
127+
111128
{{< callout type="info" >}}
112129
Set streaming to false if you're using Ollama for tool calling. Ollama does not currently stream tool calls.
113130
{{< /callout >}}
114131

115-
## Prompt Templates
132+
## Using Templates and Parameters in Prompts
116133

117134
It is common for prompts to contain parameters that are either extracted from a user interaction
118135
or, in the case of RAG, are populated by some sort of retrieval process. Markdown prompts can also
@@ -167,7 +184,7 @@ prompt-format: "django"
167184
---
168185
```
169186

170-
### Binding values during testing
187+
### Testing Templates
171188

172189
When running in VSCode, you can set values of the parameters in the markdown preamble. This is
173190
a great way to quickly test your prompt during development.
@@ -178,45 +195,3 @@ parameter-values:
178195
user: slimslenderslacks
179196
---
180197
```
181-
182-
### Extractors
183-
184-
Extractors are container functions that can be used to extract values when the prompt has been deployed
185-
to a server. These extractors are also used to populate default values for a prompt when it is used from
186-
an MCP client.
187-
188-
Extractor definitions also follow the pattern of compose services. They are just docker images but with
189-
the additional requirement that they should write `application/json` to stdout. This json will be used to
190-
populate the context for binding parameters in the prompt template.
191-
192-
```markdown
193-
---
194-
extractors:
195-
- name: linguist
196-
image: vonwig/go-linguist:latest
197-
command:
198-
- -json
199-
---
200-
```
201-
202-
We can create lists if the extractor json output has array types. For example,
203-
if we run the linguist tool to extract language from a project, our prompt can list
204-
them using the following template. You need to be familar with the json format output
205-
by linguist (eg that it creates lists of maps with a `language` key).
206-
207-
```markdown
208-
---
209-
extractors:
210-
- name: linguist
211-
---
212-
213-
# prompt
214-
215-
{{#linguist}}
216-
217-
This project contains {{language}} code.
218-
219-
{{/linguist}}
220-
221-
```
222-

0 commit comments

Comments
 (0)