refactor: Claude user message and code completion system prompt

This commit is contained in:
Petr Mironychev 2024-12-25 17:50:47 +01:00
parent f27429aa66
commit 35012865c7
2 changed files with 15 additions and 6 deletions

View File

@ -152,9 +152,17 @@ CodeCompletionSettings::CodeCompletionSettings()
systemPrompt.setSettingsKey(Constants::CC_SYSTEM_PROMPT);
systemPrompt.setDisplayStyle(Utils::StringAspect::TextEditDisplay);
systemPrompt.setDefaultValue(
"You are an expert C++, Qt, and QML. You insert the code into the areas where the user "
"specifies. In answer should be ONLY code suggestions in code block, without comments or "
"description. Don't repeat existing code. Complete ONLY one logic expression.");
"You are an expert in C++, Qt, and QML programming. Your task is to provide code "
"suggestions that seamlessly integrate with existing code. You will receive a code context "
"with specified insertion points. Your goal is to complete only one logic expression "
"within these points."
"Here is the code context with insertion points:<code_context>Before: {{variable}}After: "
"{{variable}}</code_context> Instructions: 1. Carefully analyze the provided code context. "
"2. Consider the existing code and the specified insertion points.3. Generate a code "
"suggestion that completes one logic expression between the 'Before' and 'After' points. "
"4. Ensure your suggestion does not repeat any existing code. 5. Format your suggestion as "
"a code block using triple backticks. 6. Do not include any comments or descriptions with "
"your code suggestion. Remember to include only the new code to be inserted.");
useFilePathInContext.setSettingsKey(Constants::CC_USE_FILE_PATH_IN_CONTEXT);
useFilePathInContext.setDefaultValue(true);

View File

@ -42,9 +42,10 @@ public:
QString content = message["content"].toString();
if (message["role"] == "user") {
message["content"] = QString("Complete the code ONLY between these "
"parts:\nBefore: %1\nAfter: %2\n")
.arg(context.prefix, context.suffix);
message["content"]
= QString("Here is the code context with insertion points: <code_context>"
"\nBefore: %1\nAfter: %2\n </code_context>")
.arg(context.prefix, context.suffix);
} else {
message["content"] = QString("%1").arg(content);
}