mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2025-07-14 02:54:48 -04:00
Add singleline completion
This commit is contained in:
@ -91,6 +91,27 @@ void LLMClientInterface::handleCancelRequest(const QJsonObject &request)
|
||||
}
|
||||
}
|
||||
|
||||
bool LLMClientInterface::processSingleLineCompletion(QNetworkReply *reply,
|
||||
const QJsonObject &request,
|
||||
const QString &accumulatedCompletion)
|
||||
{
|
||||
int newlinePos = accumulatedCompletion.indexOf('\n');
|
||||
|
||||
if (newlinePos != -1) {
|
||||
QString singleLineCompletion = accumulatedCompletion.left(newlinePos).trimmed();
|
||||
singleLineCompletion = removeStopWords(singleLineCompletion);
|
||||
|
||||
QJsonObject position = request["params"].toObject()["doc"].toObject()["position"].toObject();
|
||||
|
||||
sendCompletionToClient(singleLineCompletion, request, position, true);
|
||||
m_accumulatedResponses.remove(reply);
|
||||
reply->abort();
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QString LLMClientInterface::сontextBefore(TextEditor::TextEditorWidget *widget,
|
||||
int lineNumber,
|
||||
int cursorPosition)
|
||||
@ -175,9 +196,7 @@ void LLMClientInterface::handleShutdown(const QJsonObject &request)
|
||||
emit messageReceived(LanguageServerProtocol::JsonRpcMessage(response));
|
||||
}
|
||||
|
||||
void LLMClientInterface::handleTextDocumentDidOpen(const QJsonObject &request)
|
||||
{
|
||||
}
|
||||
void LLMClientInterface::handleTextDocumentDidOpen(const QJsonObject &request) {}
|
||||
|
||||
void LLMClientInterface::handleInitialized(const QJsonObject &request)
|
||||
{
|
||||
@ -207,6 +226,11 @@ void LLMClientInterface::handleLLMResponse(QNetworkReply *reply, const QJsonObje
|
||||
|
||||
QJsonObject position = request["params"].toObject()["doc"].toObject()["position"].toObject();
|
||||
|
||||
if (!settings().multiLineCompletion()
|
||||
&& processSingleLineCompletion(reply, request, accumulatedResponse)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isComplete || reply->isFinished()) {
|
||||
if (isComplete) {
|
||||
auto cleanedCompletion = removeStopWords(accumulatedResponse);
|
||||
@ -353,8 +377,6 @@ QString LLMClientInterface::removeStopWords(const QString &completion)
|
||||
return filteredCompletion;
|
||||
}
|
||||
|
||||
void LLMClientInterface::parseCurrentMessage()
|
||||
{
|
||||
}
|
||||
void LLMClientInterface::parseCurrentMessage() {}
|
||||
|
||||
} // namespace QodeAssist
|
||||
|
Reference in New Issue
Block a user