diff --git a/LLMClientInterface.cpp b/LLMClientInterface.cpp
index 6b61777..c69a17c 100644
--- a/LLMClientInterface.cpp
+++ b/LLMClientInterface.cpp
@@ -217,10 +217,8 @@ void LLMClientInterface::handleCompletion(const QJsonObject &request)
QString userMessage;
if (completeSettings.useUserMessageTemplateForCC()
&& promptTemplate->type() == LLMCore::TemplateType::Chat) {
- userMessage = processMessageToFIM(
- completeSettings.userMessageTemplateForCC(),
- updatedContext.prefix,
- updatedContext.suffix);
+ userMessage
+ = completeSettings.processMessageToFIM(updatedContext.prefix, updatedContext.suffix);
} else {
userMessage = updatedContext.prefix;
}
@@ -246,15 +244,6 @@ void LLMClientInterface::handleCompletion(const QJsonObject &request)
m_requestHandler.sendLLMRequest(config, request);
}
-QString LLMClientInterface::processMessageToFIM(
- const QString &templateText, const QString &prefix, const QString &suffix)
-{
- QString result = templateText;
- result.replace("${prefix}", prefix);
- result.replace("${suffix}", suffix);
- return result;
-}
-
LLMCore::ContextData LLMClientInterface::prepareContext(const QJsonObject &request,
const QStringView &accumulatedCompletion)
{
diff --git a/LLMClientInterface.hpp b/LLMClientInterface.hpp
index 716d75c..624b60e 100644
--- a/LLMClientInterface.hpp
+++ b/LLMClientInterface.hpp
@@ -71,8 +71,6 @@ private:
void startTimeMeasurement(const QString &requestId);
void endTimeMeasurement(const QString &requestId);
void logPerformance(const QString &requestId, const QString &operation, qint64 elapsedMs);
- QString processMessageToFIM(
- const QString &templateText, const QString &prefix, const QString &suffix);
};
} // namespace QodeAssist
diff --git a/settings/CodeCompletionSettings.cpp b/settings/CodeCompletionSettings.cpp
index b671a7b..6b2dc38 100644
--- a/settings/CodeCompletionSettings.cpp
+++ b/settings/CodeCompletionSettings.cpp
@@ -152,25 +152,26 @@ CodeCompletionSettings::CodeCompletionSettings()
systemPrompt.setSettingsKey(Constants::CC_SYSTEM_PROMPT);
systemPrompt.setDisplayStyle(Utils::StringAspect::TextEditDisplay);
systemPrompt.setDefaultValue(
- "You are an expert in C++, Qt, and QML programming. Your task is to provide code "
- "completion by continuing exactly from the cursor position, without repeating any "
- "characters that are already typed before the cursor. For example, if \"fo\" is typed and "
- "cursor is after \"fo\", suggest only \"r\" to complete \"for\", not the full word.\n\n"
- "Rules:\n"
- "1. Continue the code exactly from the cursor position\n"
- "2. Never repeat characters that appear before the cursor\n"
- "3. Complete up to the first unmatched closing parenthesis or semicolon\n"
- "4. Provide only the new characters needed to complete the code\n"
- "5. Format your suggestion as a code block\n\n"
- "Context format:\n"
+ "You are an expert C++, Qt, and QML code completion assistant. Your task is to provide "
+ "precise and contextually appropriate code completions.\n\n"
+ "Core Requirements:\n"
+ "1. Continue code exactly from the cursor position, ensuring it properly connects with any "
+ "existing code after the cursor\n"
+ "2. Never repeat existing code before or after the cursor\n"
+ "Specific Guidelines:\n"
+ "- For function calls: Complete parameters with appropriate types and names\n"
+ "- For class members: Respect access modifiers and class conventions\n"
+ "- Respect existing indentation and formatting\n"
+ "- Consider scope and visibility of referenced symbols\n"
+ "- Ensure seamless integration with code both before and after the cursor\n\n"
+ "Context Format:\n"
"\n"
- "Before:{{code before cursor}}\n"
- "\n"
- "After:{{code after cursor}}\n"
+ "{{code before cursor}}{{code after cursor}}\n"
"\n\n"
- "Output format: Format your suggestion as a code block with language. Do not include any "
- "comments or "
- "descriptions with your code suggestion.");
+ "Response Format:\n"
+ "- No explanations or comments\n"
+ "- Only include new characters needed to create valid code\n"
+ "- Should be codeblock with language\n");
useUserMessageTemplateForCC.setSettingsKey(Constants::CC_USE_USER_TEMPLATE);
useUserMessageTemplateForCC.setDefaultValue(true);
@@ -179,8 +180,8 @@ CodeCompletionSettings::CodeCompletionSettings()
userMessageTemplateForCC.setSettingsKey(Constants::CC_USER_TEMPLATE);
userMessageTemplateForCC.setDisplayStyle(Utils::StringAspect::TextEditDisplay);
userMessageTemplateForCC.setDefaultValue(
- "Here is the code context with insertion points: "
- "\nBefore:${prefix}\n\nAfter:${suffix}\n\n\n");
+ "Here is the code context with insertion points:\n"
+ "\n${prefix}${suffix}\n\n");
useProjectChangesCache.setSettingsKey(Constants::CC_USE_PROJECT_CHANGES_CACHE);
useProjectChangesCache.setDefaultValue(true);
@@ -340,6 +341,14 @@ void CodeCompletionSettings::resetSettingsToDefaults()
}
}
+QString CodeCompletionSettings::processMessageToFIM(const QString &prefix, const QString &suffix)
+{
+ QString result = userMessageTemplateForCC();
+ result.replace("${prefix}", prefix);
+ result.replace("${suffix}", suffix);
+ return result;
+}
+
class CodeCompletionSettingsPage : public Core::IOptionsPage
{
public:
diff --git a/settings/CodeCompletionSettings.hpp b/settings/CodeCompletionSettings.hpp
index a37d172..33c215b 100644
--- a/settings/CodeCompletionSettings.hpp
+++ b/settings/CodeCompletionSettings.hpp
@@ -78,6 +78,8 @@ public:
// API Configuration Settings
Utils::StringAspect apiKey{this};
+ QString processMessageToFIM(const QString &prefix, const QString &suffix);
+
private:
void setupConnections();
void resetSettingsToDefaults();