3
3
- [ Default Template] ( #default-template )
4
4
- [ Default Prompt] ( #default-prompt )
5
5
- [ Default Guidelines] ( #default-guidelines )
6
- - [ Default ` n_completions ` template] ( #default--n-completions- -template )
6
+ - [ Default ` n_completions ` template] ( #default-n_completions -template )
7
7
- [ Default Few Shots Examples] ( #default-few-shots-examples )
8
8
- [ Default Chat Input Example] ( #default-chat-input-example )
9
9
- [ Customization] ( #customization )
10
- - [ An Experimental Configuration Setup for Gemini ] ( #an-experimental-configuration-setup-for-gemini )
10
+ - [ A Practical Example ] ( #a-practical-example )
11
11
12
12
# FIM LLM Prompt Structure
13
13
@@ -42,12 +42,46 @@ tokens within the prompt function.
42
42
43
43
# Chat LLM Prompt Structure
44
44
45
+ We utilize two distinct strategies when constructing prompts:
46
+
47
+ 1 . ** Prefix First Style** : This involves including the code preceding the
48
+ cursor initially, followed by the code succeeding the cursor. This approach
49
+ is used only for the ** Gemini** provider.
50
+
51
+ 2 . ** Suffix First Style** : This method involves including the code following
52
+ the cursor initially, and then the code preceding the cursor. It is employed
53
+ for ** other** providers such as OpenAI, OpenAI-Compatible, and Claude.
54
+
55
+ To access the ** Suffix First Style** default prompt, use:
56
+
57
+ 1 . ` require('minuet.config').default_system `
58
+ 1 . ` require('minuet.config').default_few_shots `
59
+ 1 . ` require('minuet.config').default_chat_input `
60
+
61
+ To access the ** Prefix First Style** default prompt, use:
62
+
63
+ 1 . ` require('minuet.config').default_system_prefix_first `
64
+ 1 . ` require('minuet.config').default_few_shots_prefix_first `
65
+ 1 . ` require('minuet.config').default_chat_input_prefix_first `
66
+
45
67
## Default Template
46
68
47
69
` {{{prompt}}}\n{{{guidelines}}}\n{{{n_completion_template}}} `
48
70
49
71
## Default Prompt
50
72
73
+ ** Prefix First Style** :
74
+
75
+ You are the backend of an AI-powered code completion engine. Your task is to
76
+ provide code suggestions based on the user's input. The user's code will be
77
+ enclosed in markers:
78
+
79
+ - ` <contextAfterCursor> ` : Code context after the cursor
80
+ - ` <cursorPosition> ` : Current cursor location
81
+ - ` <contextBeforeCursor> ` : Code context before the cursor
82
+
83
+ ** Suffix First Style** :
84
+
51
85
You are the backend of an AI-powered code completion engine. Your task is to
52
86
provide code suggestions based on the user's input. The user's code will be
53
87
enclosed in markers:
@@ -81,6 +115,7 @@ Guidelines:
81
115
## Default Few Shots Examples
82
116
83
117
``` lua
118
+ -- suffix first style
84
119
local default_few_shots = {
85
120
{
86
121
role = ' user' ,
@@ -114,6 +149,22 @@ def fibonacci(n):
114
149
]] ,
115
150
},
116
151
}
152
+
153
+ -- prefix first style
154
+ local default_few_shots_prefix_first = {
155
+ {
156
+ role = ' user' ,
157
+ content = [[
158
+ # language: python
159
+ <contextBeforeCursor>
160
+ def fibonacci(n):
161
+ <cursorPosition>
162
+ <contextAfterCursor>
163
+
164
+ fib(5)]] ,
165
+ },
166
+ default_few_shots [2 ],
167
+ }
117
168
```
118
169
119
170
## Default Chat Input Example
@@ -122,7 +173,27 @@ The chat input represents the final prompt delivered to the LLM for completion.
122
173
Its template follows a structured format similar to the system prompt and can
123
174
be customized as follows:
124
175
125
- ` {{{language}}}\n{{{tab}}}\n<contextAfterCursor>\n{{{context_after_cursor}}}\n<contextBeforeCursor>\n{{{context_before_cursor}}}<cursorPosition> `
176
+ ** Suffix First Style** :
177
+
178
+ ```
179
+ {{{language}}}
180
+ {{{tab}}}
181
+ <contextAfterCursor>
182
+ {{{context_after_cursor}}}
183
+ <contextBeforeCursor>
184
+ {{{context_before_cursor}}}<cursorPosition>
185
+ ```
186
+
187
+ ** Prefix First Style** :
188
+
189
+ ```
190
+ {{{language}}}
191
+ {{{tab}}}
192
+ <contextBeforeCursor>
193
+ {{{context_before_cursor}}}<cursorPosition>
194
+ <contextAfterCursor>
195
+ {{{context_after_cursor}}}
196
+ ```
126
197
127
198
Components:
128
199
@@ -207,17 +278,13 @@ require('minuet').setup {
207
278
There's no need to replicate unchanged fields. The system will automatically
208
279
merge modified fields with default values using the ` tbl_deep_extend ` function.
209
280
210
- ## An Experimental Configuration Setup for Gemini
211
-
212
- Some observations suggest that Gemini might perform better with a ` Prefix-Suffix `
213
- structured input format, specifically ` Before-Cursor -> Cursor-Pos -> After-Cursor ` .
214
-
215
- This contrasts with other chat-based LLMs, which may yield better results with
216
- the inverse structure: ` After-Cursor -> Before-Cursor -> Cursor-Pos ` .
281
+ ## A Practical Example
217
282
218
- This finding remains experimental and requires further validation.
283
+ Here, we present a practical example for configuring the prompt for Gemini,
284
+ aiming to reuse existing components of the default prompt wherever possible.
219
285
220
- Below is the current configuration used by the maintainer for Gemini:
286
+ Please note that you should not copy-paste this into your configuration, as it
287
+ represents the ** default setting** applied to Gemini.
221
288
222
289
``` lua
223
290
local gemini_prompt = [[
@@ -251,6 +318,7 @@ local gemini_chat_input_template =
251
318
gemini_few_shots [2 ] = require (' minuet.config' ).default_few_shots [2 ]
252
319
253
320
require (' minuet' ).setup {
321
+ provider = ' gemini' ,
254
322
provider_options = {
255
323
gemini = {
256
324
system = {
0 commit comments