Skip to content

Commit 676be8f

Browse files
committed
Add Missing Tokens for CodeGeeX4 AutoComplete
Previous attempts at using the normal pipe char with CodeGeeX FIM tokens resulted in empty completion output. However, this was due to <|user|> and <|assistant|> tokens being necessary for completion. The earlier working change ommitted these tokens, and its functionality using deepseek pipes was merely coincidental. This change now properly follows the CodeGeeX infill guides and should match what the model expects. In addition to <|user|> and <|assistant|>, the <|endoftext|> token was added as a stop token.
1 parent d53326c commit 676be8f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

core/autocomplete/templates.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -168,20 +168,20 @@ const codegeexFimTemplate: AutocompleteTemplate = {
168168
...snippets.map((snippet) => snippet.filepath),
169169
filepath,
170170
]);
171-
const baseTemplate = `###PATH:${relativePaths[relativePaths.length - 1]}\n###LANGUAGE:\n###MODE:\n<code_suffix>${suffix}<code_prefix>${prefix}<code_middle>`;
171+
const baseTemplate = `###PATH:${relativePaths[relativePaths.length - 1]}\n###LANGUAGE:\n###MODE:BLOCK\n<|code_suffix|>${suffix}<|code_prefix|>${prefix}<|code_middle|>`;
172172
if (snippets.length == 0)
173173
{
174-
return baseTemplate;
174+
return `<|user|>\n${baseTemplate}<|assistant|>\n`;
175175
}
176176
const references =
177177
`###REFERENCE:\n${snippets
178178
.map((snippet, i) => `###PATH:${relativePaths[i]}\n${snippet.contents}\n`)
179179
.join("###REFERENCE:\n")}`;
180-
const prompt = `${references}\n${baseTemplate}`;
180+
const prompt = `<|user|>\n${references}\n${baseTemplate}<|assistant|>\n`;
181181
return prompt;
182182
},
183183
completionOptions: {
184-
stop: ["<code_suffix>", "<code_prefix>", "<code_middle>"],
184+
stop: ["<|user|>", "<|code_suffix|>", "<|code_prefix|>", "<|code_middle|>", "<|assistant|>", "<|endoftext|>"],
185185
},
186186
};
187187

0 commit comments

Comments
 (0)