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")) {