Adapt new settings

This commit is contained in:
Petr Mironychev
2024-11-10 23:42:06 +01:00
parent 85d039cbd5
commit bc93bce03b
16 changed files with 264 additions and 159 deletions

View File

@ -88,8 +88,8 @@ void ConfigurationManager::selectModel()
return; return;
const auto providerUrl = (settingsButton == &m_generalSettings.ccSelectModel) const auto providerUrl = (settingsButton == &m_generalSettings.ccSelectModel)
? m_generalSettings.ccUrl() ? m_generalSettings.ccUrl.volatileValue()
: m_generalSettings.caUrl(); : m_generalSettings.caUrl.volatileValue();
const auto modelList = m_providersManager.getProviderByName(providerName) const auto modelList = m_providersManager.getProviderByName(providerName)
->getInstalledModels(providerUrl); ->getInstalledModels(providerUrl);

View File

@ -24,7 +24,7 @@
#include <languageserverprotocol/lsptypes.h> #include <languageserverprotocol/lsptypes.h>
#include "core/ChangesManager.h" #include "core/ChangesManager.h"
#include "settings/ContextSettings.hpp" #include "settings/CodeCompletionSettings.hpp"
const QRegularExpression &getYearRegex() const QRegularExpression &getYearRegex()
{ {
@ -214,11 +214,11 @@ LLMCore::ContextData DocumentContextReader::prepareContext(int lineNumber, int c
QString DocumentContextReader::getContextBefore(int lineNumber, int cursorPosition) const QString DocumentContextReader::getContextBefore(int lineNumber, int cursorPosition) const
{ {
if (Settings::contextSettings().readFullFile()) { if (Settings::codeCompletionSettings().readFullFile()) {
return readWholeFileBefore(lineNumber, cursorPosition); return readWholeFileBefore(lineNumber, cursorPosition);
} else { } else {
int effectiveStartLine; int effectiveStartLine;
int beforeCursor = Settings::contextSettings().readStringsBeforeCursor(); int beforeCursor = Settings::codeCompletionSettings().readStringsBeforeCursor();
if (m_copyrightInfo.found) { if (m_copyrightInfo.found) {
effectiveStartLine = qMax(m_copyrightInfo.endLine + 1, lineNumber - beforeCursor); effectiveStartLine = qMax(m_copyrightInfo.endLine + 1, lineNumber - beforeCursor);
} else { } else {
@ -230,11 +230,11 @@ QString DocumentContextReader::getContextBefore(int lineNumber, int cursorPositi
QString DocumentContextReader::getContextAfter(int lineNumber, int cursorPosition) const QString DocumentContextReader::getContextAfter(int lineNumber, int cursorPosition) const
{ {
if (Settings::contextSettings().readFullFile()) { if (Settings::codeCompletionSettings().readFullFile()) {
return readWholeFileAfter(lineNumber, cursorPosition); return readWholeFileAfter(lineNumber, cursorPosition);
} else { } else {
int endLine = qMin(m_document->blockCount() - 1, int endLine = qMin(m_document->blockCount() - 1,
lineNumber + Settings::contextSettings().readStringsAfterCursor()); lineNumber + Settings::codeCompletionSettings().readStringsAfterCursor());
return getContextBetween(lineNumber + 1, endLine, -1); return getContextBetween(lineNumber + 1, endLine, -1);
} }
} }
@ -243,10 +243,10 @@ QString DocumentContextReader::getInstructions() const
{ {
QString instructions; QString instructions;
if (Settings::contextSettings().useFilePathInContext()) if (Settings::codeCompletionSettings().useFilePathInContext())
instructions += getLanguageAndFileInfo(); instructions += getLanguageAndFileInfo();
if (Settings::contextSettings().useProjectChangesCache()) if (Settings::codeCompletionSettings().useProjectChangesCache())
instructions += ChangesManager::instance().getRecentChangesContext(m_textDocument); instructions += ChangesManager::instance().getRecentChangesContext(m_textDocument);
return instructions; return instructions;

View File

@ -26,13 +26,11 @@
#include <llmcore/RequestConfig.hpp> #include <llmcore/RequestConfig.hpp>
#include <texteditor/textdocument.h> #include <texteditor/textdocument.h>
#include "ConfigurationManager.hpp"
#include "DocumentContextReader.hpp" #include "DocumentContextReader.hpp"
#include "llmcore/PromptTemplateManager.hpp" #include "llmcore/PromptTemplateManager.hpp"
#include "llmcore/ProvidersManager.hpp" #include "llmcore/ProvidersManager.hpp"
#include "logger/Logger.hpp" #include "logger/Logger.hpp"
#include "settings/CodeCompletionSettings.hpp" #include "settings/CodeCompletionSettings.hpp"
#include "settings/ContextSettings.hpp"
#include "settings/GeneralSettings.hpp" #include "settings/GeneralSettings.hpp"
namespace QodeAssist { namespace QodeAssist {

View File

@ -32,7 +32,7 @@
#include "LLMClientInterface.hpp" #include "LLMClientInterface.hpp"
#include "LLMSuggestion.hpp" #include "LLMSuggestion.hpp"
#include "core/ChangesManager.h" #include "core/ChangesManager.h"
#include "settings/ContextSettings.hpp" #include "settings/CodeCompletionSettings.hpp"
#include "settings/GeneralSettings.hpp" #include "settings/GeneralSettings.hpp"
using namespace LanguageServerProtocol; using namespace LanguageServerProtocol;
@ -65,52 +65,53 @@ QodeAssistClient::~QodeAssistClient()
void QodeAssistClient::openDocument(TextEditor::TextDocument *document) void QodeAssistClient::openDocument(TextEditor::TextDocument *document)
{ {
// auto project = ProjectManager::projectForFile(document->filePath()); auto project = ProjectManager::projectForFile(document->filePath());
// if (!isEnabled(project)) if (!isEnabled(project))
// return; return;
// Client::openDocument(document); Client::openDocument(document);
// connect(document, connect(document,
// &TextDocument::contentsChangedWithPosition, &TextDocument::contentsChangedWithPosition,
// this, this,
// [this, document](int position, int charsRemoved, int charsAdded) { [this, document](int position, int charsRemoved, int charsAdded) {
// Q_UNUSED(charsRemoved) Q_UNUSED(charsRemoved)
// if (!Settings::generalSettings().enableAutoComplete()) if (!Settings::codeCompletionSettings().autoCompletion())
// return; return;
// auto project = ProjectManager::projectForFile(document->filePath()); auto project = ProjectManager::projectForFile(document->filePath());
// if (!isEnabled(project)) if (!isEnabled(project))
// return; return;
// auto textEditor = BaseTextEditor::currentTextEditor(); auto textEditor = BaseTextEditor::currentTextEditor();
// if (!textEditor || textEditor->document() != document) if (!textEditor || textEditor->document() != document)
// return; return;
// if (Settings::contextSettings().useProjectChangesCache()) if (Settings::codeCompletionSettings().useProjectChangesCache())
// ChangesManager::instance().addChange(document, ChangesManager::instance().addChange(document,
// position, position,
// charsRemoved, charsRemoved,
// charsAdded); charsAdded);
// TextEditorWidget *widget = textEditor->editorWidget(); TextEditorWidget *widget = textEditor->editorWidget();
// if (widget->isReadOnly() || widget->multiTextCursor().hasMultipleCursors()) if (widget->isReadOnly() || widget->multiTextCursor().hasMultipleCursors())
// return; return;
// const int cursorPosition = widget->textCursor().position(); const int cursorPosition = widget->textCursor().position();
// if (cursorPosition < position || cursorPosition > position + charsAdded) if (cursorPosition < position || cursorPosition > position + charsAdded)
// return; return;
// m_recentCharCount += charsAdded; m_recentCharCount += charsAdded;
// if (m_typingTimer.elapsed() if (m_typingTimer.elapsed()
// > Settings::generalSettings().autoCompletionTypingInterval()) { > Settings::codeCompletionSettings().autoCompletionTypingInterval()) {
// m_recentCharCount = charsAdded; m_recentCharCount = charsAdded;
// m_typingTimer.restart(); m_typingTimer.restart();
// } }
// if (m_recentCharCount > Settings::generalSettings().autoCompletionCharThreshold()) { if (m_recentCharCount
// scheduleRequest(widget); > Settings::codeCompletionSettings().autoCompletionCharThreshold()) {
// } scheduleRequest(widget);
// }); }
});
} }
bool QodeAssistClient::canOpenProject(ProjectExplorer::Project *project) bool QodeAssistClient::canOpenProject(ProjectExplorer::Project *project)
@ -144,31 +145,32 @@ void QodeAssistClient::requestCompletions(TextEditor::TextEditorWidget *editor)
void QodeAssistClient::scheduleRequest(TextEditor::TextEditorWidget *editor) void QodeAssistClient::scheduleRequest(TextEditor::TextEditorWidget *editor)
{ {
// cancelRunningRequest(editor); cancelRunningRequest(editor);
// auto it = m_scheduledRequests.find(editor); auto it = m_scheduledRequests.find(editor);
// if (it == m_scheduledRequests.end()) { if (it == m_scheduledRequests.end()) {
// auto timer = new QTimer(this); auto timer = new QTimer(this);
// timer->setSingleShot(true); timer->setSingleShot(true);
// connect(timer, &QTimer::timeout, this, [this, editor]() { connect(timer, &QTimer::timeout, this, [this, editor]() {
// if (editor if (editor
// && editor->textCursor().position() && editor->textCursor().position()
// == m_scheduledRequests[editor]->property("cursorPosition").toInt() == m_scheduledRequests[editor]->property("cursorPosition").toInt()
// && m_recentCharCount > Settings::generalSettings().autoCompletionCharThreshold()) && m_recentCharCount
// requestCompletions(editor); > Settings::codeCompletionSettings().autoCompletionCharThreshold())
// }); requestCompletions(editor);
// connect(editor, &TextEditorWidget::destroyed, this, [this, editor]() { });
// delete m_scheduledRequests.take(editor); connect(editor, &TextEditorWidget::destroyed, this, [this, editor]() {
// cancelRunningRequest(editor); delete m_scheduledRequests.take(editor);
// }); cancelRunningRequest(editor);
// connect(editor, &TextEditorWidget::cursorPositionChanged, this, [this, editor] { });
// cancelRunningRequest(editor); connect(editor, &TextEditorWidget::cursorPositionChanged, this, [this, editor] {
// }); cancelRunningRequest(editor);
// it = m_scheduledRequests.insert(editor, timer); });
// } it = m_scheduledRequests.insert(editor, timer);
}
// it.value()->setProperty("cursorPosition", editor->textCursor().position()); it.value()->setProperty("cursorPosition", editor->textCursor().position());
// it.value()->start(Settings::generalSettings().startSuggestionTimer()); it.value()->start(Settings::codeCompletionSettings().startSuggestionTimer());
} }
void QodeAssistClient::handleCompletions(const GetCompletionRequest::Response &response, void QodeAssistClient::handleCompletions(const GetCompletionRequest::Response &response,
TextEditor::TextEditorWidget *editor) TextEditor::TextEditorWidget *editor)

View File

@ -1,3 +1,22 @@
/*
* Copyright (C) 2024 Petr Mironychev
*
* This file is part of QodeAssist.
*
* QodeAssist is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* QodeAssist is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with QodeAssist. If not, see <https://www.gnu.org/licenses/>.
*/
#include "ChatUtils.h" #include "ChatUtils.h"
#include <QClipboard> #include <QClipboard>

View File

@ -1,3 +1,22 @@
/*
* Copyright (C) 2024 Petr Mironychev
*
* This file is part of QodeAssist.
*
* QodeAssist is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* QodeAssist is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with QodeAssist. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once #pragma once
#include <qobject.h> #include <qobject.h>

View File

@ -18,8 +18,7 @@
*/ */
#include "ChangesManager.h" #include "ChangesManager.h"
#include "logger/Logger.hpp" #include "settings/CodeCompletionSettings.hpp"
#include "settings/ContextSettings.hpp"
namespace QodeAssist { namespace QodeAssist {
@ -61,7 +60,7 @@ void ChangesManager::addChange(TextEditor::TextDocument *document,
} else { } else {
documentQueue.enqueue(change); documentQueue.enqueue(change);
if (documentQueue.size() > Settings::contextSettings().maxChangesCacheSize()) { if (documentQueue.size() > Settings::codeCompletionSettings().maxChangesCacheSize()) {
documentQueue.dequeue(); documentQueue.dequeue();
} }
} }

View File

@ -1,3 +1,22 @@
/*
* Copyright (C) 2024 Petr Mironychev
*
* This file is part of QodeAssist.
*
* QodeAssist is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* QodeAssist is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with QodeAssist. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once #pragma once
namespace QodeAssist::LLMCore { namespace QodeAssist::LLMCore {

View File

@ -26,7 +26,8 @@
#include <QNetworkReply> #include <QNetworkReply>
#include "logger/Logger.hpp" #include "logger/Logger.hpp"
#include "settings/PresetPromptsSettings.hpp" #include "settings/ChatAssistantSettings.hpp"
#include "settings/CodeCompletionSettings.hpp"
namespace QodeAssist::Providers { namespace QodeAssist::Providers {
@ -54,36 +55,43 @@ QString LMStudioProvider::chatEndpoint() const
void LMStudioProvider::prepareRequest(QJsonObject &request, LLMCore::RequestType type) void LMStudioProvider::prepareRequest(QJsonObject &request, LLMCore::RequestType type)
{ {
auto &promptSettings = Settings::presetPromptsSettings(); auto prepareMessages = [](QJsonObject &req) -> QJsonArray {
auto settings = promptSettings.getSettings(type);
QJsonArray messages; QJsonArray messages;
if (req.contains("system")) {
if (request.contains("system")) { messages.append(
QJsonObject systemMessage{{"role", "system"}, QJsonObject{{"role", "system"}, {"content", req.take("system").toString()}});
{"content", request.take("system").toString()}};
messages.append(systemMessage);
} }
if (req.contains("prompt")) {
if (request.contains("prompt")) { messages.append(
QJsonObject userMessage{{"role", "user"}, {"content", request.take("prompt").toString()}}; QJsonObject{{"role", "user"}, {"content", req.take("prompt").toString()}});
messages.append(userMessage);
} }
return messages;
};
auto applyModelParams = [&request](const auto &settings) {
request["max_tokens"] = settings.maxTokens();
request["temperature"] = settings.temperature();
if (settings.useTopP())
request["top_p"] = settings.topP();
if (settings.useTopK())
request["top_k"] = settings.topK();
if (settings.useFrequencyPenalty())
request["frequency_penalty"] = settings.frequencyPenalty();
if (settings.usePresencePenalty())
request["presence_penalty"] = settings.presencePenalty();
};
QJsonArray messages = prepareMessages(request);
if (!messages.isEmpty()) { if (!messages.isEmpty()) {
request["messages"] = std::move(messages); request["messages"] = std::move(messages);
} }
request["max_tokens"] = settings.maxTokens; if (type == LLMCore::RequestType::Fim) {
request["temperature"] = settings.temperature; applyModelParams(Settings::codeCompletionSettings());
if (settings.useTopP) } else {
request["top_p"] = settings.topP; applyModelParams(Settings::chatAssistantSettings());
if (settings.useTopK) }
request["top_k"] = settings.topK;
if (settings.useFrequencyPenalty)
request["frequency_penalty"] = settings.frequencyPenalty;
if (settings.usePresencePenalty)
request["presence_penalty"] = settings.presencePenalty;
} }
bool LMStudioProvider::handleResponse(QNetworkReply *reply, QString &accumulatedResponse) bool LMStudioProvider::handleResponse(QNetworkReply *reply, QString &accumulatedResponse)

View File

@ -26,7 +26,8 @@
#include <QtCore/qeventloop.h> #include <QtCore/qeventloop.h>
#include "logger/Logger.hpp" #include "logger/Logger.hpp"
#include "settings/PresetPromptsSettings.hpp" #include "settings/ChatAssistantSettings.hpp"
#include "settings/CodeCompletionSettings.hpp"
namespace QodeAssist::Providers { namespace QodeAssist::Providers {
@ -54,22 +55,29 @@ QString OllamaProvider::chatEndpoint() const
void OllamaProvider::prepareRequest(QJsonObject &request, LLMCore::RequestType type) void OllamaProvider::prepareRequest(QJsonObject &request, LLMCore::RequestType type)
{ {
auto &promptSettings = Settings::presetPromptsSettings(); auto applySettings = [&request](const auto &settings) {
auto settings = promptSettings.getSettings(type);
QJsonObject options; QJsonObject options;
options["num_predict"] = settings.maxTokens; options["num_predict"] = settings.maxTokens();
options["temperature"] = settings.temperature; options["temperature"] = settings.temperature();
if (settings.useTopP)
options["top_p"] = settings.topP; if (settings.useTopP())
if (settings.useTopK) options["top_p"] = settings.topP();
options["top_k"] = settings.topK; if (settings.useTopK())
if (settings.useFrequencyPenalty) options["top_k"] = settings.topK();
options["frequency_penalty"] = settings.frequencyPenalty; if (settings.useFrequencyPenalty())
if (settings.usePresencePenalty) options["frequency_penalty"] = settings.frequencyPenalty();
options["presence_penalty"] = settings.presencePenalty; if (settings.usePresencePenalty())
options["presence_penalty"] = settings.presencePenalty();
request["options"] = options; request["options"] = options;
request["keep_alive"] = settings.ollamaLivetime; request["keep_alive"] = settings.ollamaLivetime();
};
if (type == LLMCore::RequestType::Fim) {
applySettings(Settings::codeCompletionSettings());
} else {
applySettings(Settings::chatAssistantSettings());
}
} }
bool OllamaProvider::handleResponse(QNetworkReply *reply, QString &accumulatedResponse) bool OllamaProvider::handleResponse(QNetworkReply *reply, QString &accumulatedResponse)

View File

@ -18,14 +18,14 @@
*/ */
#include "OpenAICompatProvider.hpp" #include "OpenAICompatProvider.hpp"
#include "settings/ChatAssistantSettings.hpp"
#include "settings/CodeCompletionSettings.hpp"
#include <QJsonArray> #include <QJsonArray>
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject> #include <QJsonObject>
#include <QNetworkReply> #include <QNetworkReply>
#include "settings/PresetPromptsSettings.hpp"
namespace QodeAssist::Providers { namespace QodeAssist::Providers {
OpenAICompatProvider::OpenAICompatProvider() {} OpenAICompatProvider::OpenAICompatProvider() {}
@ -52,39 +52,42 @@ QString OpenAICompatProvider::chatEndpoint() const
void OpenAICompatProvider::prepareRequest(QJsonObject &request, LLMCore::RequestType type) void OpenAICompatProvider::prepareRequest(QJsonObject &request, LLMCore::RequestType type)
{ {
auto &promptSettings = Settings::presetPromptsSettings(); auto prepareMessages = [](QJsonObject &req) -> QJsonArray {
auto settings = promptSettings.getSettings(type);
QJsonArray messages; QJsonArray messages;
if (req.contains("system")) {
if (request.contains("system")) { messages.append(
QJsonObject systemMessage{{"role", "system"}, QJsonObject{{"role", "system"}, {"content", req.take("system").toString()}});
{"content", request.take("system").toString()}};
messages.append(systemMessage);
} }
if (req.contains("prompt")) {
if (request.contains("prompt")) { messages.append(
QJsonObject userMessage{{"role", "user"}, {"content", request.take("prompt").toString()}}; QJsonObject{{"role", "user"}, {"content", req.take("prompt").toString()}});
messages.append(userMessage);
} }
return messages;
};
auto applyModelParams = [&request](const auto &settings) {
request["max_tokens"] = settings.maxTokens();
request["temperature"] = settings.temperature();
if (settings.useTopP())
request["top_p"] = settings.topP();
if (settings.useTopK())
request["top_k"] = settings.topK();
if (settings.useFrequencyPenalty())
request["frequency_penalty"] = settings.frequencyPenalty();
if (settings.usePresencePenalty())
request["presence_penalty"] = settings.presencePenalty();
};
QJsonArray messages = prepareMessages(request);
if (!messages.isEmpty()) { if (!messages.isEmpty()) {
request["messages"] = std::move(messages); request["messages"] = std::move(messages);
} }
request["max_tokens"] = settings.maxTokens; if (type == LLMCore::RequestType::Fim) {
request["temperature"] = settings.temperature; applyModelParams(Settings::codeCompletionSettings());
if (settings.useTopP) } else {
request["top_p"] = settings.topP; applyModelParams(Settings::chatAssistantSettings());
if (settings.useTopK)
request["top_k"] = settings.topK;
if (settings.useFrequencyPenalty)
request["frequency_penalty"] = settings.frequencyPenalty;
if (settings.usePresencePenalty)
request["presence_penalty"] = settings.presencePenalty;
const QString &apiKey = settings.apiKey;
if (!apiKey.isEmpty()) {
request["api_key"] = apiKey;
} }
} }

View File

@ -1,8 +1,6 @@
add_library(QodeAssistSettings STATIC add_library(QodeAssistSettings STATIC
GeneralSettings.hpp GeneralSettings.cpp GeneralSettings.hpp GeneralSettings.cpp
ContextSettings.hpp ContextSettings.cpp
CustomPromptSettings.hpp CustomPromptSettings.cpp CustomPromptSettings.hpp CustomPromptSettings.cpp
PresetPromptsSettings.hpp PresetPromptsSettings.cpp
SettingsUtils.hpp SettingsUtils.hpp
SettingsConstants.hpp SettingsConstants.hpp
ButtonAspect.hpp ButtonAspect.hpp

View File

@ -51,6 +51,27 @@ CodeCompletionSettings::CodeCompletionSettings()
multiLineCompletion.setDefaultValue(false); multiLineCompletion.setDefaultValue(false);
multiLineCompletion.setLabelText(Tr::tr("Enable Multiline Completion(experimental)")); multiLineCompletion.setLabelText(Tr::tr("Enable Multiline Completion(experimental)"));
startSuggestionTimer.setSettingsKey(Constants::СС_START_SUGGESTION_TIMER);
startSuggestionTimer.setLabelText(Tr::tr("with delay(ms)"));
startSuggestionTimer.setRange(10, 10000);
startSuggestionTimer.setDefaultValue(500);
autoCompletionCharThreshold.setSettingsKey(Constants::СС_AUTO_COMPLETION_CHAR_THRESHOLD);
autoCompletionCharThreshold.setLabelText(Tr::tr("AI suggestion triggers after typing"));
autoCompletionCharThreshold.setToolTip(
Tr::tr("The number of characters that need to be typed within the typing interval "
"before an AI suggestion request is sent."));
autoCompletionCharThreshold.setRange(0, 10);
autoCompletionCharThreshold.setDefaultValue(0);
autoCompletionTypingInterval.setSettingsKey(Constants::СС_AUTO_COMPLETION_TYPING_INTERVAL);
autoCompletionTypingInterval.setLabelText(Tr::tr("character(s) within(ms)"));
autoCompletionTypingInterval.setToolTip(
Tr::tr("The time window (in milliseconds) during which the character threshold "
"must be met to trigger an AI suggestion request."));
autoCompletionTypingInterval.setRange(500, 5000);
autoCompletionTypingInterval.setDefaultValue(2000);
// General Parameters Settings // General Parameters Settings
temperature.setSettingsKey(Constants::CC_TEMPERATURE); temperature.setSettingsKey(Constants::CC_TEMPERATURE);
temperature.setLabelText(Tr::tr("Temperature:")); temperature.setLabelText(Tr::tr("Temperature:"));
@ -136,7 +157,7 @@ CodeCompletionSettings::CodeCompletionSettings()
maxChangesCacheSize.setSettingsKey(Constants::CC_MAX_CHANGES_CACHE_SIZE); maxChangesCacheSize.setSettingsKey(Constants::CC_MAX_CHANGES_CACHE_SIZE);
maxChangesCacheSize.setRange(2, 1000); maxChangesCacheSize.setRange(2, 1000);
maxChangesCacheSize.setDefaultValue(20); maxChangesCacheSize.setDefaultValue(10);
// Ollama Settings // Ollama Settings
ollamaLivetime.setSettingsKey(Constants::CC_OLLAMA_LIVETIME); ollamaLivetime.setSettingsKey(Constants::CC_OLLAMA_LIVETIME);
@ -196,11 +217,13 @@ CodeCompletionSettings::CodeCompletionSettings()
return Column{Row{Stretch{1}, resetToDefaults}, return Column{Row{Stretch{1}, resetToDefaults},
Space{8}, Space{8},
Group{title(Tr::tr("Auto Completion Settings")), Group{title(Tr::tr("Auto Completion Settings")),
Column{ Column{autoCompletion,
autoCompletion,
Space{8}, Space{8},
multiLineCompletion, multiLineCompletion,
}}, Row{autoCompletionCharThreshold,
autoCompletionTypingInterval,
startSuggestionTimer,
Stretch{1}}}},
Space{8}, Space{8},
Group{title(Tr::tr("General Parameters")), Group{title(Tr::tr("General Parameters")),
Column{ Column{

View File

@ -36,6 +36,10 @@ public:
Utils::BoolAspect autoCompletion{this}; Utils::BoolAspect autoCompletion{this};
Utils::BoolAspect multiLineCompletion{this}; Utils::BoolAspect multiLineCompletion{this};
Utils::IntegerAspect startSuggestionTimer{this};
Utils::IntegerAspect autoCompletionCharThreshold{this};
Utils::IntegerAspect autoCompletionTypingInterval{this};
// General Parameters Settings // General Parameters Settings
Utils::DoubleAspect temperature{this}; Utils::DoubleAspect temperature{this};
Utils::IntegerAspect maxTokens{this}; Utils::IntegerAspect maxTokens{this};

View File

@ -60,6 +60,7 @@ GeneralSettings::GeneralSettings()
ccSelectProvider.m_buttonText = TrConstants::SELECT; ccSelectProvider.m_buttonText = TrConstants::SELECT;
initStringAspect(ccModel, Constants::CC_MODEL, TrConstants::MODEL, "codellama:7b-code"); initStringAspect(ccModel, Constants::CC_MODEL, TrConstants::MODEL, "codellama:7b-code");
ccModel.setHistoryCompleter(Constants::CC_MODEL_HISTORY);
ccSelectModel.m_buttonText = TrConstants::SELECT; ccSelectModel.m_buttonText = TrConstants::SELECT;
initStringAspect(ccTemplate, Constants::CC_TEMPLATE, TrConstants::TEMPLATE, "CodeLlama FIM"); initStringAspect(ccTemplate, Constants::CC_TEMPLATE, TrConstants::TEMPLATE, "CodeLlama FIM");
@ -67,6 +68,7 @@ GeneralSettings::GeneralSettings()
ccSelectTemplate.m_buttonText = TrConstants::SELECT; ccSelectTemplate.m_buttonText = TrConstants::SELECT;
initStringAspect(ccUrl, Constants::CC_URL, TrConstants::URL, "http://localhost:11434"); initStringAspect(ccUrl, Constants::CC_URL, TrConstants::URL, "http://localhost:11434");
ccUrl.setHistoryCompleter(Constants::CC_URL_HISTORY);
ccSetUrl.m_buttonText = TrConstants::SELECT; ccSetUrl.m_buttonText = TrConstants::SELECT;
ccStatus.setDisplayStyle(Utils::StringAspect::LabelDisplay); ccStatus.setDisplayStyle(Utils::StringAspect::LabelDisplay);
@ -79,6 +81,7 @@ GeneralSettings::GeneralSettings()
caSelectProvider.m_buttonText = TrConstants::SELECT; caSelectProvider.m_buttonText = TrConstants::SELECT;
initStringAspect(caModel, Constants::CA_MODEL, TrConstants::MODEL, "codellama:7b-instruct"); initStringAspect(caModel, Constants::CA_MODEL, TrConstants::MODEL, "codellama:7b-instruct");
caModel.setHistoryCompleter(Constants::CA_MODEL_HISTORY);
caSelectModel.m_buttonText = TrConstants::SELECT; caSelectModel.m_buttonText = TrConstants::SELECT;
initStringAspect(caTemplate, Constants::CA_TEMPLATE, TrConstants::TEMPLATE, "CodeLlama Chat"); initStringAspect(caTemplate, Constants::CA_TEMPLATE, TrConstants::TEMPLATE, "CodeLlama Chat");
@ -87,6 +90,7 @@ GeneralSettings::GeneralSettings()
caSelectTemplate.m_buttonText = TrConstants::SELECT; caSelectTemplate.m_buttonText = TrConstants::SELECT;
initStringAspect(caUrl, Constants::CA_URL, TrConstants::URL, "http://localhost:11434"); initStringAspect(caUrl, Constants::CA_URL, TrConstants::URL, "http://localhost:11434");
caUrl.setHistoryCompleter(Constants::CA_URL_HISTORY);
caSetUrl.m_buttonText = TrConstants::SELECT; caSetUrl.m_buttonText = TrConstants::SELECT;
caStatus.setDisplayStyle(Utils::StringAspect::LabelDisplay); caStatus.setDisplayStyle(Utils::StringAspect::LabelDisplay);

View File

@ -27,22 +27,26 @@ const char MENU_ID[] = "QodeAssist.Menu";
// new settings // new settings
const char CC_PROVIDER[] = "QodeAssist.ccProvider"; const char CC_PROVIDER[] = "QodeAssist.ccProvider";
const char CC_MODEL[] = "QodeAssist.ccModel"; const char CC_MODEL[] = "QodeAssist.ccModel";
const char CC_MODEL_HISTORY[] = "QodeAssist.ccModelHistory";
const char CC_TEMPLATE[] = "QodeAssist.ccTemplate"; const char CC_TEMPLATE[] = "QodeAssist.ccTemplate";
const char CC_URL[] = "QodeAssist.ccUrl"; const char CC_URL[] = "QodeAssist.ccUrl";
const char CC_URL_HISTORY[] = "QodeAssist.ccUrlHistory";
const char CA_PROVIDER[] = "QodeAssist.caProvider"; const char CA_PROVIDER[] = "QodeAssist.caProvider";
const char CA_MODEL[] = "QodeAssist.caModel"; const char CA_MODEL[] = "QodeAssist.caModel";
const char CA_MODEL_HISTORY[] = "QodeAssist.caModelHistory";
const char CA_TEMPLATE[] = "QodeAssist.caTemplate"; const char CA_TEMPLATE[] = "QodeAssist.caTemplate";
const char CA_URL[] = "QodeAssist.caUrl"; const char CA_URL[] = "QodeAssist.caUrl";
const char CA_URL_HISTORY[] = "QodeAssist.caUrlHistory";
// settings // settings
const char ENABLE_QODE_ASSIST[] = "QodeAssist.enableQodeAssist"; const char ENABLE_QODE_ASSIST[] = "QodeAssist.enableQodeAssist";
const char CC_AUTO_COMPLETION[] = "QodeAssist.ccAutoCompletion"; const char CC_AUTO_COMPLETION[] = "QodeAssist.ccAutoCompletion";
const char ENABLE_LOGGING[] = "QodeAssist.enableLogging"; const char ENABLE_LOGGING[] = "QodeAssist.enableLogging";
const char PROVIDER_PATHS[] = "QodeAssist.providerPaths"; const char PROVIDER_PATHS[] = "QodeAssist.providerPaths";
const char START_SUGGESTION_TIMER[] = "QodeAssist.startSuggestionTimer"; const char СС_START_SUGGESTION_TIMER[] = "QodeAssist.startSuggestionTimer";
const char AUTO_COMPLETION_CHAR_THRESHOLD[] = "QodeAssist.autoCompletionCharThreshold"; const char СС_AUTO_COMPLETION_CHAR_THRESHOLD[] = "QodeAssist.autoCompletionCharThreshold";
const char AUTO_COMPLETION_TYPING_INTERVAL[] = "QodeAssist.autoCompletionTypingInterval"; const char СС_AUTO_COMPLETION_TYPING_INTERVAL[] = "QodeAssist.autoCompletionTypingInterval";
const char MAX_FILE_THRESHOLD[] = "QodeAssist.maxFileThreshold"; const char MAX_FILE_THRESHOLD[] = "QodeAssist.maxFileThreshold";
const char CC_MULTILINE_COMPLETION[] = "QodeAssist.ccMultilineCompletion"; const char CC_MULTILINE_COMPLETION[] = "QodeAssist.ccMultilineCompletion";
const char CUSTOM_JSON_TEMPLATE[] = "QodeAssist.customJsonTemplate"; const char CUSTOM_JSON_TEMPLATE[] = "QodeAssist.customJsonTemplate";
@ -54,10 +58,7 @@ const char QODE_ASSIST_CODE_COMPLETION_SETTINGS_PAGE_ID[]
= "QodeAssist.2CodeCompletionSettingsPageId"; = "QodeAssist.2CodeCompletionSettingsPageId";
const char QODE_ASSIST_CHAT_ASSISTANT_SETTINGS_PAGE_ID[] const char QODE_ASSIST_CHAT_ASSISTANT_SETTINGS_PAGE_ID[]
= "QodeAssist.3ChatAssistantSettingsPageId"; = "QodeAssist.3ChatAssistantSettingsPageId";
const char QODE_ASSIST_CONTEXT_SETTINGS_PAGE_ID[] = "QodeAssist.4ContextSettingsPageId"; const char QODE_ASSIST_CUSTOM_PROMPT_SETTINGS_PAGE_ID[] = "QodeAssist.4CustomPromptSettingsPageId";
const char QODE_ASSIST_PRESET_PROMPTS_SETTINGS_PAGE_ID[]
= "QodeAssist.5PresetPromptsSettingsPageId";
const char QODE_ASSIST_CUSTOM_PROMPT_SETTINGS_PAGE_ID[] = "QodeAssist.6CustomPromptSettingsPageId";
const char QODE_ASSIST_GENERAL_OPTIONS_CATEGORY[] = "QodeAssist.Category"; const char QODE_ASSIST_GENERAL_OPTIONS_CATEGORY[] = "QodeAssist.Category";
const char QODE_ASSIST_GENERAL_OPTIONS_DISPLAY_CATEGORY[] = "Qode Assist"; const char QODE_ASSIST_GENERAL_OPTIONS_DISPLAY_CATEGORY[] = "Qode Assist";