From 603fa39a1a23318b80e21e48e192d61c12e6f1a4 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 12 Dec 2024 11:33:37 -0800 Subject: [PATCH] postprocessing rule for no suffix --- core/autocomplete/postprocessing/index.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/autocomplete/postprocessing/index.ts b/core/autocomplete/postprocessing/index.ts index ed7c41f05..c2cf5049b 100644 --- a/core/autocomplete/postprocessing/index.ts +++ b/core/autocomplete/postprocessing/index.ts @@ -90,6 +90,17 @@ export function postprocessCompletion({ completion = completion.slice(1); } } + + // When there is no suffix, Codestral tends to begin with a new line + // We do this to avoid double new lines + if ( + suffix.length === 0 && + prefix.endsWith("\n\n") && + completion.startsWith("\n") + ) { + // Remove a single leading \n from the completion + completion = completion.slice(1); + } } if (llm.model.includes("granite")) {