Create template
Browse files
template
ADDED
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<|start|>system<|message|>You are ChatGPT, a large language model trained by OpenAI.
|
2 |
+
Knowledge cutoff: 2024-06
|
3 |
+
Current date: {{ currentDate }}
|
4 |
+
{{- if and .IsThinkSet .Think (ne .ThinkLevel "") }}
|
5 |
+
|
6 |
+
Reasoning: {{ .ThinkLevel }}
|
7 |
+
{{- else if or (not .IsThinkSet) (and .IsThinkSet .Think) }}
|
8 |
+
|
9 |
+
Reasoning: medium
|
10 |
+
{{- end }}
|
11 |
+
|
12 |
+
{{- $hasNonBuiltinTools := false }}
|
13 |
+
{{- if .Tools -}}
|
14 |
+
{{- $hasBrowserSearch := false }}
|
15 |
+
{{- $hasBrowserOpen := false }}
|
16 |
+
{{- $hasBrowserFind := false }}
|
17 |
+
{{- $hasPython := false }}
|
18 |
+
{{- range .Tools }}
|
19 |
+
{{- if eq .Function.Name "browser.search" -}}{{- $hasBrowserSearch = true -}}
|
20 |
+
{{- else if eq .Function.Name "browser.open" -}}{{- $hasBrowserOpen = true -}}
|
21 |
+
{{- else if eq .Function.Name "browser.find" -}}{{- $hasBrowserFind = true -}}
|
22 |
+
{{- else if eq .Function.Name "python" -}}{{- $hasPython = true -}}
|
23 |
+
{{- else }}{{ $hasNonBuiltinTools = true -}}
|
24 |
+
{{- end }}
|
25 |
+
{{- end }}
|
26 |
+
{{- if or $hasBrowserSearch $hasBrowserOpen $hasBrowserFind $hasPython }}
|
27 |
+
|
28 |
+
# Tools
|
29 |
+
{{- if or $hasBrowserSearch $hasBrowserOpen $hasBrowserFind }}
|
30 |
+
|
31 |
+
## browser
|
32 |
+
|
33 |
+
// Tool for browsing.
|
34 |
+
// The `cursor` appears in brackets before each browsing display: `[{cursor}]`.
|
35 |
+
// Cite information from the tool using the following format:
|
36 |
+
// `γ{cursor}β L{line_start}(-L{line_end})?γ`, for example: `γ6β L9-L11γ` or `γ8β L3γ`.
|
37 |
+
// Do not quote more than 10 words directly from the tool output.
|
38 |
+
// sources=web (default: web)
|
39 |
+
namespace browser {
|
40 |
+
{{- if $hasBrowserSearch }}
|
41 |
+
|
42 |
+
// Searches for information related to `query` and displays `topn` results.
|
43 |
+
type search = (_: {
|
44 |
+
query: string,
|
45 |
+
topn?: number, // default: 10
|
46 |
+
source?: string,
|
47 |
+
}) => any;
|
48 |
+
{{- end }}
|
49 |
+
{{- if $hasBrowserOpen }}
|
50 |
+
|
51 |
+
// Opens the link `id` from the page indicated by `cursor` starting at line number `loc`, showing `num_lines` lines.
|
52 |
+
// Valid link ids are displayed with the formatting: `γ{id}β .*γ`.
|
53 |
+
// If `cursor` is not provided, the most recent page is implied.
|
54 |
+
// If `id` is a string, it is treated as a fully qualified URL associated with `source`.
|
55 |
+
// If `loc` is not provided, the viewport will be positioned at the beginning of the document or centered on the most relevant passage, if available.
|
56 |
+
// Use this function without `id` to scroll to a new location of an opened page.
|
57 |
+
type open = (_: {
|
58 |
+
id?: number | string, // default: -1
|
59 |
+
cursor?: number, // default: -1
|
60 |
+
loc?: number, // default: -1
|
61 |
+
num_lines?: number, // default: -1
|
62 |
+
view_source?: boolean, // default: false
|
63 |
+
source?: string,
|
64 |
+
}) => any;
|
65 |
+
{{- end }}
|
66 |
+
{{- if $hasBrowserFind }}
|
67 |
+
|
68 |
+
// Finds exact matches of `pattern` in the current page, or the page given by `cursor`.
|
69 |
+
type find = (_: {
|
70 |
+
pattern: string,
|
71 |
+
cursor?: number, // default: -1
|
72 |
+
}) => any;
|
73 |
+
{{- end }}
|
74 |
+
|
75 |
+
} // namespace browser
|
76 |
+
{{- end }}{{/* end if has browser tools */}}
|
77 |
+
{{- if $hasPython }}
|
78 |
+
|
79 |
+
## python
|
80 |
+
|
81 |
+
Use this tool to execute Python code in your chain of thought. The code will not be shown to the user. This tool should be used for internal reasoning, but not for code that is intended to be visible to the user (e.g. when creating plots, tables, or files).
|
82 |
+
|
83 |
+
When you send a message containing Python code to python, it will be executed in a stateful Jupyter notebook environment. python will respond with the output of the execution or time out after 120.0 seconds. The drive at '/mnt/data' can be used to save and persist user files. Internet access for this session is UNKNOWN. Depends on the cluster.
|
84 |
+
{{- end }}{{/* end if hasPython */}}
|
85 |
+
{{- end }}{{/* end if has any built-in tools */}}
|
86 |
+
{{- end }}{{/* end if .Tools */}}
|
87 |
+
|
88 |
+
# Valid channels: analysis, commentary, final. Channel must be included for every message.{{ if $hasNonBuiltinTools }}
|
89 |
+
Calls to these tools must go to the commentary channel: 'functions'.
|
90 |
+
{{- end -}}<|end|>{{/* end of system */ -}}
|
91 |
+
{{- if or $hasNonBuiltinTools .System -}}
|
92 |
+
<|start|>developer<|message|>{{- if $hasNonBuiltinTools }}# Tools
|
93 |
+
|
94 |
+
## functions
|
95 |
+
|
96 |
+
namespace functions {
|
97 |
+
{{- range .Tools }}
|
98 |
+
{{- if not (or (eq .Function.Name "browser.search") (eq .Function.Name "browser.open") (eq .Function.Name "browser.find") (eq .Function.Name "python")) }}
|
99 |
+
{{if .Function.Description }}
|
100 |
+
// {{ .Function.Description }}
|
101 |
+
{{- end }}
|
102 |
+
{{- if and .Function.Parameters.Properties (gt (len .Function.Parameters.Properties) 0) }}
|
103 |
+
type {{ .Function.Name }} = (_: {
|
104 |
+
{{- range $name, $prop := .Function.Parameters.Properties }}
|
105 |
+
{{- if $prop.Description }}
|
106 |
+
// {{ $prop.Description }}
|
107 |
+
{{- end }}
|
108 |
+
{{ $name }}: {{ if gt (len $prop.Type) 1 }}{{ range $i, $t := $prop.Type }}{{ if $i }} | {{ end }}{{ $t }}{{ end }}{{ else }}{{ index $prop.Type 0 }}{{ end }},
|
109 |
+
{{- end }}
|
110 |
+
}) => any;
|
111 |
+
{{- else }}
|
112 |
+
type {{ .Function.Name }} = () => any;
|
113 |
+
{{- end }}
|
114 |
+
{{- end }}{{/* end if not browser tool */}}
|
115 |
+
{{- end }}{{/* end of range .Tools */}}
|
116 |
+
|
117 |
+
} // namespace functions
|
118 |
+
{{- end }}{{/* end if hasNonBuiltinTools */}}
|
119 |
+
{{- if .System}}
|
120 |
+
|
121 |
+
# Instructions
|
122 |
+
|
123 |
+
{{ .System }}
|
124 |
+
{{- end -}}
|
125 |
+
<|end|>
|
126 |
+
{{- end -}}
|
127 |
+
{{- /* Find the index of the last user message */ -}}
|
128 |
+
{{- $lastUserIdx := -1 }}
|
129 |
+
{{- $prefillingContent := false }}
|
130 |
+
{{- $prefillingThinkingOnly := false }}
|
131 |
+
{{- range $i, $msg := .Messages }}
|
132 |
+
{{- $last := eq (len (slice $.Messages $i)) 1 -}}
|
133 |
+
{{- if eq $msg.Role "user" }}
|
134 |
+
{{- $lastUserIdx = $i }}
|
135 |
+
{{- end -}}
|
136 |
+
{{- if and $last (eq $msg.Role "assistant") (gt (len $msg.Content) 0) }}
|
137 |
+
{{- $prefillingContent = true }}
|
138 |
+
{{- else if and $last (eq $msg.Role "assistant") (gt (len $msg.Thinking) 0) }}
|
139 |
+
{{- $prefillingThinkingOnly = true }}
|
140 |
+
{{- end }}
|
141 |
+
{{- end -}}
|
142 |
+
{{- /* Now render messages */ -}}
|
143 |
+
{{- range $i, $msg := .Messages }}
|
144 |
+
{{- $last := eq (len (slice $.Messages $i)) 1 -}}
|
145 |
+
{{- if (ne $msg.Role "system") -}}
|
146 |
+
{{- if eq $msg.Role "tool" -}}
|
147 |
+
{{- if or (eq $msg.ToolName "python") (eq $msg.ToolName "browser.search") (eq $msg.ToolName "browser.open") (eq $msg.ToolName "browser.find") -}}
|
148 |
+
<|start|>{{ $msg.ToolName }} to=assistant<|message|>{{ $msg.Content }}<|end|>
|
149 |
+
{{- else -}}
|
150 |
+
<|start|>functions.{{ $msg.ToolName }} to=assistant<|message|>{{ $msg.Content }}<|end|>
|
151 |
+
{{- end -}}
|
152 |
+
{{- else if eq $msg.Role "assistant" -}}
|
153 |
+
{{- if and $msg.Thinking (gt $i $lastUserIdx) -}}{{- /* Show thinking only after last user message */ -}}
|
154 |
+
<|start|>assistant<|channel|>analysis<|message|>{{ $msg.Thinking }}{{- if not $prefillingThinkingOnly -}}<|end|>{{- end -}}
|
155 |
+
{{- end -}}
|
156 |
+
{{- if gt (len $msg.Content) 0 -}}
|
157 |
+
<|start|>assistant<|channel|>final<|message|>{{ $msg.Content }}{{- if not $prefillingContent -}}<|end|>{{- end -}}
|
158 |
+
{{- end -}}
|
159 |
+
{{- if gt (len $msg.ToolCalls) 0 -}}
|
160 |
+
{{- range $j, $toolCall := $msg.ToolCalls -}}
|
161 |
+
{{- $isBuiltin := or (eq $toolCall.Function.Name "python") (eq $toolCall.Function.Name "browser.search") (eq $toolCall.Function.Name "browser.open") (eq $toolCall.Function.Name "browser.find") -}}
|
162 |
+
<|start|>assistant<|channel|>{{ if $isBuiltin }}analysis{{ else }}commentary{{ end }} to={{ if not $isBuiltin}}functions.{{end}}{{ $toolCall.Function.Name }} <|constrain|>json<|message|>{{ $toolCall.Function.Arguments }}<|call|>
|
163 |
+
{{- end -}}
|
164 |
+
{{- end -}}
|
165 |
+
{{- else if eq $msg.Role "user" -}}
|
166 |
+
<|start|>{{ $msg.Role }}<|message|>{{ $msg.Content }}<|end|>
|
167 |
+
{{- end }}
|
168 |
+
{{- else }}
|
169 |
+
{{- end }}
|
170 |
+
{{- end -}}
|
171 |
+
{{- if not (or $prefillingContent $prefillingThinkingOnly) -}}
|
172 |
+
<|start|>assistant
|
173 |
+
{{- end -}}
|