Skip to content

Commit 6940d40

Browse files
committed
fix:修改提示词,增强自动修复效果
1 parent 24c02be commit 6940d40

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/cvbManager.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,9 @@ TCVB 格式规范:
450450
4. [markdown代码块], 一定要用\`\`\` ... \`\`\` 包裹,仔细检查不要漏掉。
451451
5. 注意TCVB和CVB的区别。CVB是完整的内容,而TCVB是用来生成差量同步的,通过多个OPERATION去操作已有CVB合成新CVB
452452
6. 插入和删除操作都可以转化为替换操作
453-
7. 用来匹配的锚点必须和原始传入的数据完全一致,不能有缺失,不能丢弃注释。
453+
7. 用来匹配的锚点必须和原文的格式完全一致,不能有缺失,不能丢弃注释。
454+
8. 注意不要丢失OPERATION而直接输出代码块
455+
9. 不要私自加入不必要的空行
454456
`;
455457
}
456458
}
@@ -539,19 +541,19 @@ function diagnoseMatchFailure(strContent: string, op: ExactReplaceOperation): st
539541

540542
if (beforeAnchorRange[0] === -1)
541543
{
542-
errorMessages.push(`FILE: ${op.m_strFilePath} 未找到 BEFORE_ANCHOR:\n\`\`\`\n${op.m_strBeforeAnchor}\n\`\`\``);
544+
errorMessages.push(`FILE: ${op.m_strFilePath} 无法精确匹配(有和原文不一致的地方) BEFORE_ANCHOR:\n\`\`\`\n${op.m_strBeforeAnchor}\n\`\`\``);
543545
console.log(`FILE: ${op.m_strFilePath} 未找到 BEFORE_ANCHOR:\n\`\`\`\n${op.m_strBeforeAnchor}\n\`\`\`\n表达式\n${beforeAnchorPattern}`);
544546
}
545547

546548
if (afterAnchorRange[0] === -1)
547549
{
548-
errorMessages.push(`FILE: ${op.m_strFilePath} 未找到 AFTER_ANCHOR:\n\`\`\`\n${op.m_strAfterAnchor}\n\`\`\``);
550+
errorMessages.push(`FILE: ${op.m_strFilePath} 无法精确匹配(有和原文不一致的地方) AFTER_ANCHOR:\n\`\`\`\n${op.m_strAfterAnchor}\n\`\`\``);
549551
console.log(`FILE: ${op.m_strFilePath} 未找到 AFTER_ANCHOR:\n\`\`\`\n${op.m_strAfterAnchor}\n\`\`\`\n表达式\n${afterAnchorPattern}`);
550552
}
551553

552554
if (oldContentRange[0] === -1)
553555
{
554-
errorMessages.push(`FILE: ${op.m_strFilePath} 未找到 OLD_CONTENT:\n\`\`\`\n${op.m_strOldContent}\n\`\`\``);
556+
errorMessages.push(`FILE: ${op.m_strFilePath} 无法精确匹配(有和原文不一致的地方) OLD_CONTENT:\n\`\`\`\n${op.m_strOldContent}\n\`\`\``);
555557
console.log(`FILE: ${op.m_strFilePath} 未找到 OLD_CONTENT:\n\`\`\`\n${op.m_strOldContent}\n\`\`\`\n表达式\n${oldContentPattern}`);
556558
}
557559

@@ -565,7 +567,7 @@ function diagnoseMatchFailure(strContent: string, op: ExactReplaceOperation): st
565567
if (firstOldContentLine < lastBeforeAnchorLine || lastOldContentLine > firstAfterAnchorLine)
566568
{
567569
errorMessages.push(
568-
`FILE: ${op.m_strFilePath} OLD_CONTENT 应该在 BEFORE_ANCHOR 和 AFTER_ANCHOR 之间:\nBEFORE_ANCHOR:\n\`\`\`\n${op.m_strBeforeAnchor}\n\`\`\`\nOLD_CONTENT:\n\`\`\`\n${op.m_strOldContent}\n\`\`\`\nAFTER_ANCHOR:\n\`\`\`\n${op.m_strAfterAnchor}\n\`\`\``);
570+
`FILE: ${op.m_strFilePath} OLD_CONTENT 应该在 BEFORE_ANCHOR 和 AFTER_ANCHOR 之间, 且不能有重叠 :\nBEFORE_ANCHOR:\n\`\`\`\n${op.m_strBeforeAnchor}\n\`\`\`\nOLD_CONTENT:\n\`\`\`\n${op.m_strOldContent}\n\`\`\`\nAFTER_ANCHOR:\n\`\`\`\n${op.m_strAfterAnchor}\n\`\`\``);
569571
}
570572
}
571573

src/deepseekApi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ export async function callDeepSeekFixApi(
203203
let messages_body = lastMessageBody;
204204

205205
messages_body.push(
206-
{ role: 'user', content:`接收的数据格式有错误: ${errorInfo}, 根据错误信息修正错误,其他的地方保持原样。然后重新完整输出:`}
206+
{ role: 'user', content:`接收的数据格式有错误: ${errorInfo}, 仔细检查,分析输出错误的原因。然后重新完整输出:`}
207207
);
208208

209209
let fullResponse = '';
@@ -278,7 +278,7 @@ ${TCVB.getFormatDescription()}
278278
任何时候都要保证修改完的代码是完整的可执行的,不能有省略
279279
先列出你的方案,然后再行动,注意输出一定要严格匹配要求格式
280280
281-
最后的输出需要是 TCVB 格式,用用来做差量修改
281+
最后的输出需要是 TCVB 格式,用来做差量修改合成CVB (为了节省通讯用的数据流量)
282282
尤其注意,输出除了TCVB的正文内容以外,别的地方出现TCVB的开始符和结束符(比如一些关于TCVB的附加说明,或者正好字符串前缀和TCVB符号一样)要做转义,
283283
以免接收的时候被错误的当成TCVB块(比如前面加入一些空格)
284284
(注意,TCVB会被用来和原始的CVB合并成新CVB的,所以输出格式要准确,用于匹配的字符串要精确)

0 commit comments

Comments
 (0)