Skip to content

Commit 5327588

Browse files
Kakueeendeepin-mozart
authored andcommitted
fix: [InlineChat] Optimized prompt
as title Log: Optimized prompt
1 parent f758155 commit 5327588

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

src/plugins/codeeditor/gui/private/texteditor_p.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ void TextEditorPrivate::updateCacheInfo(int pos, int added)
546546
if (lineWidgetContainer->isVisible()) {
547547
if (showAtLine > line) {
548548
showAtLine += added;
549+
showAtLine = qMax(showAtLine, 1);
549550
updateLineWidgetPosition();
550551
}
551552
}

src/plugins/codegeex/widgets/inlinechatwidget.cpp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ void InlineChatWidgetPrivate::processGeneratedData(const QString &data)
534534
{
535535
editSrv->clearAllBackgroundColor(chatInfo.fileName, selectionMarker);
536536
chatInfo.operationRange.clear();
537+
chatInfo.diffList.clear();
537538
chatInfo.destText = data;
538539
if (chatInfo.originalText.isEmpty())
539540
chatInfo.diffList << Diff { INSERT, data };
@@ -594,15 +595,31 @@ QString InlineChatWidgetPrivate::createPrompt(const QString &question, bool useC
594595
}
595596

596597
QStringList prompt;
598+
prompt << "你是一位智能编程助手,你叫CodeGeeX。你会为用户回答关于编程、代码、计算机方面的任何问题,"
599+
"并提供格式规范、可以执行、准确安全的代码,并在必要时提供详细的解释。任务:根据用户的Command作答。"
600+
"\nYou are working on a task with User in a file and User send a message to you. "
601+
"`【cursor】` indicate the current position of your cursor, delete it after modification."
602+
"\n\nYour Workflow:\nStep 1: You should working on the command step-by-step:\n1. "
603+
"Does the command is about to write program or comments in programming task? Write out the "
604+
"type of the command: (Choose: Chat / Programming).\n- **Chat command**: When your aim to "
605+
"reply through explanations, reminders, or requests for additional information. "
606+
"\n- **Programming command**: The user command is clear and requires you to write program "
607+
"or comments. \nStep 2: If it's a chat command, provide a thoughtful and clear response "
608+
"{language} directly.\nStep 3: If it requires programming, you should complete the Task "
609+
"according to the given file. \na. Understand the message in order to tackle it correctly: "
610+
"is the task about coding or debugging?\n- For coding, add new code within the task to execute "
611+
"the user's instructions correctly. \n- For debugging, improve the code to fix the bug, write "
612+
"the reasons for the changes within your code as comments.\nb. You should complete the task "
613+
"according to user request and comment in Chinese within your code to indicate changes. \nc. "
614+
"You should place only the finished task in a single block as output without explain!!!\n\n"
615+
"Reply in the template below:\nCommand Type: (Chat / Programming)\nResponse: (Your response / "
616+
"Finished code in one block)\n\n";
617+
597618
prompt << "针对这段代码,回答我的问题。问题:";
598619
prompt << question;
599620
prompt << "代码:\n```";
600621
prompt << chatInfo.originalText;
601622
prompt << "```";
602-
prompt << "要求:";
603-
if (state == SubmitStart)
604-
prompt << "回答的内容中包含代码;";
605-
prompt << "生成的代码需要与上面提供代码的缩进保持一致";
606623

607624
if (useChunk) {
608625
prompt << "回答内容不要使用下面的参考内容";

0 commit comments

Comments
 (0)