You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/tools/docs/authoring-prompts.md
+45-70Lines changed: 45 additions & 70 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,11 +7,31 @@ weight: 2
7
7
8
8
A prompt is markdown content with a preamble describing tools available to the agent when executing this prompt.
9
9
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
12
11
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.
13
32
Here's a simple prompt that will use Docker official curl container to fetch gists from Github.
14
33
34
+
## Example
15
35
16
36
```markdown
17
37
---
@@ -24,9 +44,9 @@ tools:
24
44
Run the curl command, in silent mode, to fetch gists for user slimslenderslacks from GitHub.
25
45
```
26
46
27
-
## Tools
47
+
## Adding Tools
28
48
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.
30
50
31
51
32
52
```markdown
@@ -54,65 +74,62 @@ Use ffmpeg to convert the file UsingPuppeteer.mp4 into an animated gif file at 1
54
74
The output file should be named UsingPuppeteer.gif.
55
75
```
56
76
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.
59
78
60
79
*`name` should uniquely identify the tool.
61
80
*`description` is important. Good descriptions help the agent understand the tool and how to use it.
62
81
*`container` sticks close to the format of a [compose service definition](https://docs.docker.com/reference/compose-file/services/) but does
63
82
fully implement it. Many of the most common top-level arguments are supported (`image`, `command`, `volumes`)
64
83
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
68
87
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.
70
89
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.**
73
91
74
92
```markdown
75
93
---
76
94
tools:
77
95
- name: curl
78
-
model: claude-3-5-sonnet-20241022
96
+
model: llama3.2
97
+
url: http://localhost:11434/v1
79
98
---
80
99
81
100
# prompt
82
101
83
102
Run the curl command, in silent mode, to fetch gists for user slimslenderslacks from GitHub.
84
103
```
85
104
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.
96
107
97
108
```markdown
98
109
---
99
110
tools:
100
111
- name: curl
101
-
url: http://localhost/v1/chat/completions
102
-
stream: false
103
-
model: llama3.1
112
+
model: claude-3-5-sonnet-20241022
104
113
---
105
114
106
115
# prompt
107
116
108
117
Run the curl command, in silent mode, to fetch gists for user slimslenderslacks from GitHub.
109
118
```
110
119
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
+
111
128
{{< callout type="info" >}}
112
129
Set streaming to false if you're using Ollama for tool calling. Ollama does not currently stream tool calls.
113
130
{{< /callout >}}
114
131
115
-
## Prompt Templates
132
+
## Using Templates and Parameters in Prompts
116
133
117
134
It is common for prompts to contain parameters that are either extracted from a user interaction
118
135
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"
167
184
---
168
185
```
169
186
170
-
### Binding values during testing
187
+
### Testing Templates
171
188
172
189
When running in VSCode, you can set values of the parameters in the markdown preamble. This is
173
190
a great way to quickly test your prompt during development.
@@ -178,45 +195,3 @@ parameter-values:
178
195
user: slimslenderslacks
179
196
---
180
197
```
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).
0 commit comments