-
Notifications
You must be signed in to change notification settings - Fork 5
/
prompt_templates.c
233 lines (225 loc) · 7.42 KB
/
prompt_templates.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
// GENERATED CODE, do not edit (see Makefile)
/* #prompt_list
agreement_to_nl_diff
agreement_to_pl_diff
agreement
nl2algo
nl2pl_rewrite
pl2nl_rewrite
summarize_block
*/
span pt_agreement_to_nl_diff() {
return S(""
"The context:\n"
"\n"
"```{langtag}\n"
"{context}\n"
"```\n"
"\n"
"The NL (natural language) part:\n"
"\n"
"```{langtag}\n"
"{comment}\n"
"```\n"
"\n"
"The PL (programming language) part:\n"
"\n"
"```{langtag}\n"
"{code}\n"
"```\n"
"\n"
"There is a discrepancy between the NL part and the PL part which was described as follows:\n"
"\n"
"{agreement}\n"
"\n"
"Reply only with a unified diff to the NL part (not the PL part!) which would bring it into line with what the PL part implements.\n"
"\n"
"Note that the discrepancy is reported in terms of the PL part's implementation of the NL part, but here we want a diff to the NL part.\n");
}
span pt_agreement_to_pl_diff() {
return S(""
"The context:\n"
"\n"
"```{langtag}\n"
"{context}\n"
"```\n"
"\n"
"The NL (natural language) part:\n"
"\n"
"```{langtag}\n"
"{comment}\n"
"```\n"
"\n"
"The PL (programming language) part:\n"
"\n"
"```{langtag}\n"
"{code}\n"
"```\n"
"\n"
"There is a discrepancy between the NL part and the PL part which was described as follows:\n"
"\n"
"{agreement}\n"
"\n"
"Reply only with a unified diff to the PL part which would bring it into line with what the NL part describes.\n");
}
span pt_agreement() {
return S(""
"The context:\n"
"\n"
"```{langtag}\n"
"{context}\n"
"```\n"
"\n"
"The comment:\n"
"\n"
"```{langtag}\n"
"{comment}\n"
"```\n"
"The code:\n"
"\n"
"```{langtag}\n"
"{code}\n"
"```\n"
"\n"
"Does the code correctly implement what the comment describes? Reply only with \"Yes\" or with \"No\" followed by a sentence describing the problem.\n");
}
span pt_nl2algo() {
return S(""
"You are now translating requirements and a high-level description into a step-by-step algorithm.\n"
"\n"
"The algorithm should be expressed as bullet points.\n"
"\n"
"Examples:\n"
"\n"
"Input:\n"
"\n"
"```{langtag}\n"
"/*\n"
"Function: int add(int, int)\n"
"\n"
"Here we implement a function that adds its arguments.\n"
"*/\n"
"```\n"
"\n"
"Your reply:\n"
"\n"
"```{langtag}\n"
"/*\n"
"- Return a + b\n"
"*/\n"
"```\n"
"\n"
"Input:\n"
"\n"
"```\n"
"/*\n"
"Function: int sum(ints xs)\n"
"\n"
"Here we implement a sum function using a simple loop.\n"
"*/\n"
"```\n"
"\n"
"Your reply:\n"
"\n"
"```\n"
"/*\n"
"- declare a variable to hold the return value, initialized to zero\n"
"- for each x in xs:\n"
" - accumulate into the running total\n"
"- return it\n"
"*/\n"
"```\n"
"\n"
"Focus on high-level algorithmic approach, as we will map into low-level coding syntax in a following step.\n"
"Prefer simple, iterative approaches, and focus on correctness rather than performance.\n"
"Be concise.\n"
"You may include hints towards proof of correctness.\n"
"\n"
"Here is context information, and a comment containing the high-level description.\n"
"\n"
"Context:\n"
"\n"
"```{langtag}\n"
"{context}\n"
"```\n"
"\n"
"Comment:\n"
"\n"
"```{langtag}\n"
"{comment}\n"
"```\n"
"\n"
"Reply only with a code block containing a block comment containing your step-by-step algorithm implementing what the Comment describes.\n");
}
span pt_nl2pl_rewrite() {
return S(""
"```{langtag}\n"
"{context}\n"
"```\n"
"\n"
"(above: references)\n"
"---\n"
"(below: current task)\n"
"\n"
"```{langtag}\n"
"{comment}\n"
"```\n"
"\n"
"Write the code only for the current task. Reply only with a code block beginning with \"```{langtag}\". Do not include comments.\n");
}
span pt_pl2nl_rewrite() {
return S(""
"We are translating code from C to English.\n"
"The English code should be explicit enough that the C code can be recreated from it. We also have a context, which describes some general principles.\n"
"\n"
"Context:\n"
"\n"
"```{langtag}\n"
"{context}\n"
"```\n"
"\n"
"Code:\n"
"\n"
"```c\n"
"{code}\n"
"```\n"
"\n"
"Translate the above code. Reply with a C block comment, inside a markdown code section, like this:\n"
"\n"
"```c\n"
"/* [block_id]\n"
"\n"
"Function:\n"
"[C function declaration]\n"
"\n"
"Purpose:\n"
"[Summary sentence]\n"
"\n"
"Algorithm:\n"
"[Detailed step-by-step translation]\n"
"*/\n"
"```\n"
"\n"
"Do not use any indentation inside the code block (every line begins flush left).\n"
"Be concise, and use newlines sparingly, trying to make your English shorter than the original code.\n"
"Use the existing code to write the function declaration, include parameter names as they are in the existing code, and include the semicolon.\n"
"Assume that the context, which is provided above, is already known.\n"
"Don't repeat the context in your output, but rely on it to make the translation more precise, idiomatic, and concise.\n"
"Create the block id by taking the function (or struct) name and prepending a \"#\", e.g. if the function declaration is \"int add(int a, int b);\" the block id should be \"#id\".\n"
"If there are comments in the original code, include them verbatim, but remove the comment syntax and again make them flush left.\n"
"Reply only with the C code block, with no other commentary, beginning with \"```c\".\n");
}
span pt_summarize_block() {
return S(""
"Write a summary of the following code.\n"
"\n"
"```{langtag}\n"
"{comment}\n"
"\n"
"{code}\n"
"```\n"
"\n"
"The summary should focus on the purpose of the code, in relation to the rest of the system, not the implementation details.\n"
"\n"
"Reply only with a single sentence.\n");
}