diff --git a/LLMClientInterface.cpp b/LLMClientInterface.cpp index 8e974b7..1dadcde 100644 --- a/LLMClientInterface.cpp +++ b/LLMClientInterface.cpp @@ -306,6 +306,8 @@ void LLMClientInterface::sendCompletionToClient(const QString &completion, QJsonArray completions; QJsonObject completionItem; + LOG_MESSAGE(QString("Completions before filter: \n%1").arg(completion)); + QString processedCompletion = promptTemplate->type() == LLMCore::TemplateType::Chat && Settings::codeCompletionSettings().smartProcessInstuctText() diff --git a/context/DocumentContextReader.cpp b/context/DocumentContextReader.cpp index e6f2374..81c6aa9 100644 --- a/context/DocumentContextReader.cpp +++ b/context/DocumentContextReader.cpp @@ -210,8 +210,7 @@ LLMCore::ContextData DocumentContextReader::prepareContext(int lineNumber, int c QString contextAfter = getContextAfter(lineNumber, cursorPosition); QString fileContext; - if (Settings::codeCompletionSettings().useFilePathInContext()) - fileContext.append("\n ").append(getLanguageAndFileInfo()); + fileContext.append("\n ").append(getLanguageAndFileInfo()); if (Settings::codeCompletionSettings().useProjectChangesCache()) fileContext.append("\n ").append( diff --git a/settings/CodeCompletionSettings.cpp b/settings/CodeCompletionSettings.cpp index dcb2685..5e28619 100644 --- a/settings/CodeCompletionSettings.cpp +++ b/settings/CodeCompletionSettings.cpp @@ -153,16 +153,24 @@ CodeCompletionSettings::CodeCompletionSettings() systemPrompt.setDisplayStyle(Utils::StringAspect::TextEditDisplay); systemPrompt.setDefaultValue( "You are an expert in C++, Qt, and QML programming. Your task is to provide code " - "suggestions that seamlessly integrate with existing code. Do not repeat code from position " - "before or after . You will receive a code context with specified insertion points. " - "Your goal is to complete only one code block." - "Here is the code context with insertion points:Before: {{variable}}After: " - "{{variable}} 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."); + "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" + "\n" + "Before:{{code before cursor}}\n" + "\n" + "After:{{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."); useUserMessageTemplateForCC.setSettingsKey(Constants::CC_USE_USER_TEMPLATE); useUserMessageTemplateForCC.setDefaultValue(true); @@ -170,12 +178,9 @@ CodeCompletionSettings::CodeCompletionSettings() userMessageTemplateForCC.setSettingsKey(Constants::CC_USER_TEMPLATE); userMessageTemplateForCC.setDisplayStyle(Utils::StringAspect::TextEditDisplay); - userMessageTemplateForCC.setDefaultValue("Here is the code context with insertion points: " - "\nBefore: %1After: %2\n "); - - useFilePathInContext.setSettingsKey(Constants::CC_USE_FILE_PATH_IN_CONTEXT); - useFilePathInContext.setDefaultValue(true); - useFilePathInContext.setLabelText(Tr::tr("Use File Path in Context")); + userMessageTemplateForCC.setDefaultValue( + "Here is the code context with insertion points: " + "\nBefore:%1\n\nAfter:%2\n\n\n"); useProjectChangesCache.setSettingsKey(Constants::CC_USE_PROJECT_CHANGES_CACHE); useProjectChangesCache.setDefaultValue(true); @@ -239,7 +244,6 @@ CodeCompletionSettings::CodeCompletionSettings() systemPrompt, Row{useUserMessageTemplateForCC, Stretch{1}}, userMessageTemplateForCC, - Row{useFilePathInContext, Stretch{1}}, Row{useProjectChangesCache, maxChangesCacheSize, Stretch{1}}}; return Column{ @@ -327,11 +331,12 @@ void CodeCompletionSettings::resetSettingsToDefaults() resetAspect(readStringsAfterCursor); resetAspect(useSystemPrompt); resetAspect(systemPrompt); - resetAspect(useFilePathInContext); resetAspect(useProjectChangesCache); resetAspect(maxChangesCacheSize); resetAspect(ollamaLivetime); resetAspect(contextWindow); + resetAspect(useUserMessageTemplateForCC); + resetAspect(userMessageTemplateForCC); } } diff --git a/settings/CodeCompletionSettings.hpp b/settings/CodeCompletionSettings.hpp index 4de0f9f..a37d172 100644 --- a/settings/CodeCompletionSettings.hpp +++ b/settings/CodeCompletionSettings.hpp @@ -68,7 +68,6 @@ public: Utils::StringAspect systemPrompt{this}; Utils::BoolAspect useUserMessageTemplateForCC{this}; Utils::StringAspect userMessageTemplateForCC{this}; - Utils::BoolAspect useFilePathInContext{this}; Utils::BoolAspect useProjectChangesCache{this}; Utils::IntegerAspect maxChangesCacheSize{this}; diff --git a/settings/SettingsConstants.hpp b/settings/SettingsConstants.hpp index 4df7c20..d93fd70 100644 --- a/settings/SettingsConstants.hpp +++ b/settings/SettingsConstants.hpp @@ -106,7 +106,6 @@ const char CC_READ_FULL_FILE[] = "QodeAssist.ccReadFullFile"; const char CC_READ_STRINGS_BEFORE_CURSOR[] = "QodeAssist.ccReadStringsBeforeCursor"; const char CC_READ_STRINGS_AFTER_CURSOR[] = "QodeAssist.ccReadStringsAfterCursor"; const char CC_USE_SYSTEM_PROMPT[] = "QodeAssist.ccUseSystemPrompt"; -const char CC_USE_FILE_PATH_IN_CONTEXT[] = "QodeAssist.ccUseFilePathInContext"; const char CC_SYSTEM_PROMPT[] = "QodeAssist.ccSystemPrompt"; const char CC_USE_USER_TEMPLATE[] = "QodeAssist.ccUseUserTemplate"; const char CC_USER_TEMPLATE[] = "QodeAssist.ccUserTemplate";