diff --git a/core/autocomplete/templating/AutocompleteTemplate.ts b/core/autocomplete/templating/AutocompleteTemplate.ts
index 9ade88e46a..1547a413e6 100644
--- a/core/autocomplete/templating/AutocompleteTemplate.ts
+++ b/core/autocomplete/templating/AutocompleteTemplate.ts
@@ -237,10 +237,8 @@ Fill in the blank to complete the code block. Your response should include only
completionOptions: { stop: ["\n"] },
};
-const holeFillerTemplate: AutocompleteTemplate = {
- template: (prefix: string, suffix: string) => {
- // From https://github.com/VictorTaelin/AI-scripts
- const SYSTEM_MSG = `You are a HOLE FILLER. You are provided with a file containing holes, formatted as '{{HOLE_NAME}}'. Your TASK is to complete with a string to replace this hole with, inside a XML tag, including context-aware indentation, if needed. All completions MUST be truthful, accurate, well-written and correct.
+// From https://github.com/VictorTaelin/AI-scripts
+const HOLE_FILLER_SYSTEM_MSG = `You are a HOLE FILLER. You are provided with a file containing holes, formatted as '{{HOLE_NAME}}'. Your TASK is to complete with a string to replace this hole with, inside a XML tag, including context-aware indentation, if needed. All completions MUST be truthful, accurate, well-written and correct.
## EXAMPLE QUERY:
@@ -324,8 +322,10 @@ function hypothenuse(a, b) {
a ** 2 + `;
+const holeFillerTemplate: AutocompleteTemplate = {
+ template: (prefix: string, suffix: string) => {
const fullPrompt =
- SYSTEM_MSG +
+ HOLE_FILLER_SYSTEM_MSG +
`\n\n\n${prefix}{{FILL_HERE}}${suffix}\n\nTASK: Fill the {{FILL_HERE}} hole. Answer only with the CORRECT completion, and NOTHING ELSE. Do it now.\n`;
return fullPrompt;
},
@@ -334,6 +334,17 @@ function hypothenuse(a, b) {
},
};
+const graniteHoleFillerTemplate: AutocompleteTemplate = {
+ template: (prefix: string, suffix: string) => {
+ const request = `\n${prefix}{{FILL_HERE}}${suffix}\n\nTASK: Fill the {{FILL_HERE}} hole. Answer only with the CORRECT completion, and NOTHING ELSE.`;
+
+ return `<|start_of_role|>system<|end_of_role|>${HOLE_FILLER_SYSTEM_MSG}<|end_of_text|>\n<|start_of_role|>user<|end_of_role|>${request}<|end_of_text|>\n<|start_of_role|>assistant<|end_of_role|>`;
+ },
+ completionOptions: {
+ stop: ["<|end_of_text|>", "<|start_of_role|>", ""],
+ },
+};
+
export function getTemplateForModel(model: string): AutocompleteTemplate {
const lowerCaseModel = model.toLowerCase();
@@ -380,11 +391,14 @@ export function getTemplateForModel(model: string): AutocompleteTemplate {
if (
lowerCaseModel.includes("gpt") ||
lowerCaseModel.includes("davinci-002") ||
- lowerCaseModel.includes("claude") ||
- lowerCaseModel.includes("granite3")
+ lowerCaseModel.includes("claude")
) {
return holeFillerTemplate;
}
+ if (lowerCaseModel.includes("granite3")) {
+ return graniteHoleFillerTemplate;
+ }
+
return stableCodeFimTemplate;
}