From 5536de146cff73dffe1a04a6a7d326cd8071292f Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Thu, 6 Mar 2025 15:19:01 +0200 Subject: [PATCH] chore: Remove dead code in RequestHandler (#106) --- llmcore/RequestHandler.cpp | 32 -------------------------------- llmcore/RequestHandler.hpp | 1 - 2 files changed, 33 deletions(-) diff --git a/llmcore/RequestHandler.cpp b/llmcore/RequestHandler.cpp index cce2eec..9425d56 100644 --- a/llmcore/RequestHandler.cpp +++ b/llmcore/RequestHandler.cpp @@ -143,36 +143,4 @@ QString RequestHandler::removeStopWords(const QStringView &completion, const QSt return filteredCompletion; } -void RequestHandler::removeCodeBlockWrappers(QString &response) -{ - static const QRegularExpression - fullCodeBlockRegex(R"(```[\w\s]*\n([\s\S]*?)```)", QRegularExpression::MultilineOption); - static const QRegularExpression - partialStartBlockRegex(R"(```[\w\s]*\n([\s\S]*?)$)", QRegularExpression::MultilineOption); - static const QRegularExpression - partialEndBlockRegex(R"(^([\s\S]*?)```)", QRegularExpression::MultilineOption); - - QRegularExpressionMatchIterator matchIterator = fullCodeBlockRegex.globalMatch(response); - while (matchIterator.hasNext()) { - QRegularExpressionMatch match = matchIterator.next(); - QString codeBlock = match.captured(0); - QString codeContent = match.captured(1).trimmed(); - response.replace(codeBlock, codeContent); - } - - QRegularExpressionMatch startMatch = partialStartBlockRegex.match(response); - if (startMatch.hasMatch()) { - QString partialBlock = startMatch.captured(0); - QString codeContent = startMatch.captured(1).trimmed(); - response.replace(partialBlock, codeContent); - } - - QRegularExpressionMatch endMatch = partialEndBlockRegex.match(response); - if (endMatch.hasMatch()) { - QString partialBlock = endMatch.captured(0); - QString codeContent = endMatch.captured(1).trimmed(); - response.replace(partialBlock, codeContent); - } -} - } // namespace QodeAssist::LLMCore diff --git a/llmcore/RequestHandler.hpp b/llmcore/RequestHandler.hpp index ec28522..08eeb2c 100644 --- a/llmcore/RequestHandler.hpp +++ b/llmcore/RequestHandler.hpp @@ -56,7 +56,6 @@ private: const QString &accumulatedResponse, const LLMConfig &config); QString removeStopWords(const QStringView &completion, const QStringList &stopWords); - void removeCodeBlockWrappers(QString &response); }; } // namespace QodeAssist::LLMCore