diff --git a/packages/ai-code/src/module/inline-completions/inline-completions.ts b/packages/ai-code/src/module/inline-completions/inline-completions.ts index fc40d1863748daf49b43b93dccf674daade22b18..851a95ece3b6fd9dc8f70bf395decf0fe898c7e3 100644 --- a/packages/ai-code/src/module/inline-completions/inline-completions.ts +++ b/packages/ai-code/src/module/inline-completions/inline-completions.ts @@ -440,21 +440,17 @@ export class InlineCompletions { private buildMessages(context: ICompletionContext): IData { const { currentLine, aboveLines, belowLines, languageId, position } = context; - const above = '```' + `${languageId}\n` + aboveLines + '\n```'; - const current = '```' + `${languageId}\n` + currentLine + '\n```'; - const below = '```' + `${languageId}\n` + belowLines + '\n```'; + const above = `\`\`\`${languageId} \n ${aboveLines} \n \`\`\``; + const current = `\`\`\`${languageId} \n ${currentLine} \n \`\`\``; + const below = `\`\`\`${languageId} \n ${belowLines} \n \`\`\``; return { messages: [ ...this.history, { role: 'USER', - content: ` - 语言:${languageId} - 上文代码: ${above} - 当前行: ${current} - 下文代码: ${below} - 光标位置:${position.column - 2} - `, + content: `当前语言:${languageId},当前光标所在行代码:\n ${current} \n 光标前5行的上文代码: \n ${above} \n 光标后3行的下文代码: \n ${below} \n 光标在当前行的位置:${ + position.column - 2 + },请基于以上上下文,在光变处提供最合适的代码补全建议。`, }, ], };