mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2025-06-04 01:28:58 -04:00
Move context settings to page
This commit is contained in:
parent
b5ca11ed38
commit
356f28a97b
@ -24,6 +24,7 @@
|
|||||||
#include <languageserverprotocol/lsptypes.h>
|
#include <languageserverprotocol/lsptypes.h>
|
||||||
|
|
||||||
#include "QodeAssistSettings.hpp"
|
#include "QodeAssistSettings.hpp"
|
||||||
|
#include "settings/ContextSettings.hpp"
|
||||||
|
|
||||||
const QRegularExpression &getYearRegex()
|
const QRegularExpression &getYearRegex()
|
||||||
{
|
{
|
||||||
@ -136,7 +137,7 @@ QString DocumentContextReader::getLanguageAndFileInfo() const
|
|||||||
|
|
||||||
QString DocumentContextReader::getSpecificInstructions() const
|
QString DocumentContextReader::getSpecificInstructions() const
|
||||||
{
|
{
|
||||||
QString specificInstruction = settings().specificInstractions().arg(
|
QString specificInstruction = Settings::contextSettings().specificInstractions().arg(
|
||||||
LanguageServerProtocol::TextDocumentItem::mimeTypeToLanguageId(m_textDocument->mimeType()));
|
LanguageServerProtocol::TextDocumentItem::mimeTypeToLanguageId(m_textDocument->mimeType()));
|
||||||
return QString("%1").arg(specificInstruction);
|
return QString("%1").arg(specificInstruction);
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "PromptTemplateManager.hpp"
|
#include "PromptTemplateManager.hpp"
|
||||||
#include "QodeAssistSettings.hpp"
|
#include "QodeAssistSettings.hpp"
|
||||||
#include "QodeAssistUtils.hpp"
|
#include "QodeAssistUtils.hpp"
|
||||||
|
#include "settings/ContextSettings.hpp"
|
||||||
#include "settings/GeneralSettings.hpp"
|
#include "settings/GeneralSettings.hpp"
|
||||||
|
|
||||||
namespace QodeAssist {
|
namespace QodeAssist {
|
||||||
@ -131,12 +132,13 @@ QString LLMClientInterface::сontextBefore(TextEditor::TextEditorWidget *widget,
|
|||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
QString contextBefore;
|
QString contextBefore;
|
||||||
if (settings().readFullFile()) {
|
if (Settings::contextSettings().readFullFile()) {
|
||||||
contextBefore = reader.readWholeFileBefore(lineNumber, cursorPosition);
|
contextBefore = reader.readWholeFileBefore(lineNumber, cursorPosition);
|
||||||
} else {
|
} else {
|
||||||
contextBefore = reader.getContextBefore(lineNumber,
|
contextBefore
|
||||||
cursorPosition,
|
= reader.getContextBefore(lineNumber,
|
||||||
settings().readStringsBeforeCursor());
|
cursorPosition,
|
||||||
|
Settings::contextSettings().readStringsBeforeCursor());
|
||||||
}
|
}
|
||||||
|
|
||||||
return contextBefore;
|
return contextBefore;
|
||||||
@ -154,12 +156,12 @@ QString LLMClientInterface::сontextAfter(TextEditor::TextEditorWidget *widget,
|
|||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
QString contextAfter;
|
QString contextAfter;
|
||||||
if (settings().readFullFile()) {
|
if (Settings::contextSettings().readFullFile()) {
|
||||||
contextAfter = reader.readWholeFileAfter(lineNumber, cursorPosition);
|
contextAfter = reader.readWholeFileAfter(lineNumber, cursorPosition);
|
||||||
} else {
|
} else {
|
||||||
contextAfter = reader.getContextAfter(lineNumber,
|
contextAfter = reader.getContextAfter(lineNumber,
|
||||||
cursorPosition,
|
cursorPosition,
|
||||||
settings().readStringsAfterCursor());
|
Settings::contextSettings().readStringsAfterCursor());
|
||||||
}
|
}
|
||||||
|
|
||||||
return contextAfter;
|
return contextAfter;
|
||||||
@ -228,7 +230,7 @@ void LLMClientInterface::handleLLMResponse(QNetworkReply *reply, const QJsonObje
|
|||||||
|
|
||||||
QJsonObject position = request["params"].toObject()["doc"].toObject()["position"].toObject();
|
QJsonObject position = request["params"].toObject()["doc"].toObject()["position"].toObject();
|
||||||
|
|
||||||
if (!settings().multiLineCompletion()
|
if (!Settings::generalSettings().multiLineCompletion()
|
||||||
&& processSingleLineCompletion(reply, request, accumulatedResponse)) {
|
&& processSingleLineCompletion(reply, request, accumulatedResponse)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -278,10 +280,10 @@ ContextData LLMClientInterface::prepareContext(const QJsonObject &request,
|
|||||||
|
|
||||||
QString contextBefore = сontextBefore(widget, lineNumber, cursorPosition);
|
QString contextBefore = сontextBefore(widget, lineNumber, cursorPosition);
|
||||||
QString contextAfter = сontextAfter(widget, lineNumber, cursorPosition);
|
QString contextAfter = сontextAfter(widget, lineNumber, cursorPosition);
|
||||||
QString instructions = QString("%1%2").arg(settings().useSpecificInstructions()
|
QString instructions = QString("%1%2").arg(Settings::contextSettings().useSpecificInstructions()
|
||||||
? reader.getSpecificInstructions()
|
? reader.getSpecificInstructions()
|
||||||
: QString(),
|
: QString(),
|
||||||
settings().useFilePathInContext()
|
Settings::contextSettings().useFilePathInContext()
|
||||||
? reader.getLanguageAndFileInfo()
|
? reader.getLanguageAndFileInfo()
|
||||||
: QString());
|
: QString());
|
||||||
|
|
||||||
|
@ -58,23 +58,6 @@ QodeAssistSettings::QodeAssistSettings()
|
|||||||
ollamaLivetime.setDefaultValue("5m");
|
ollamaLivetime.setDefaultValue("5m");
|
||||||
ollamaLivetime.setDisplayStyle(Utils::StringAspect::LineEditDisplay);
|
ollamaLivetime.setDisplayStyle(Utils::StringAspect::LineEditDisplay);
|
||||||
|
|
||||||
readFullFile.setSettingsKey(Constants::READ_FULL_FILE);
|
|
||||||
readFullFile.setLabelText(Tr::tr("Read Full File"));
|
|
||||||
readFullFile.setDefaultValue(false);
|
|
||||||
|
|
||||||
maxFileThreshold.setSettingsKey(Constants::MAX_FILE_THRESHOLD);
|
|
||||||
maxFileThreshold.setLabelText(Tr::tr("Max File Threshold:"));
|
|
||||||
maxFileThreshold.setRange(10, 100000);
|
|
||||||
maxFileThreshold.setDefaultValue(600);
|
|
||||||
|
|
||||||
readStringsBeforeCursor.setSettingsKey(Constants::READ_STRINGS_BEFORE_CURSOR);
|
|
||||||
readStringsBeforeCursor.setLabelText(Tr::tr("Read Strings Before Cursor"));
|
|
||||||
readStringsBeforeCursor.setDefaultValue(50);
|
|
||||||
|
|
||||||
readStringsAfterCursor.setSettingsKey(Constants::READ_STRINGS_AFTER_CURSOR);
|
|
||||||
readStringsAfterCursor.setLabelText(Tr::tr("Read Strings After Cursor"));
|
|
||||||
readStringsAfterCursor.setDefaultValue(30);
|
|
||||||
|
|
||||||
maxTokens.setSettingsKey(Constants::MAX_TOKENS);
|
maxTokens.setSettingsKey(Constants::MAX_TOKENS);
|
||||||
maxTokens.setLabelText(Tr::tr("Max Tokens"));
|
maxTokens.setLabelText(Tr::tr("Max Tokens"));
|
||||||
maxTokens.setRange(-1, 10000);
|
maxTokens.setRange(-1, 10000);
|
||||||
@ -117,26 +100,7 @@ QodeAssistSettings::QodeAssistSettings()
|
|||||||
startSuggestionTimer.setRange(10, 10000);
|
startSuggestionTimer.setRange(10, 10000);
|
||||||
startSuggestionTimer.setDefaultValue(500);
|
startSuggestionTimer.setDefaultValue(500);
|
||||||
|
|
||||||
useFilePathInContext.setSettingsKey(Constants::USE_FILE_PATH_IN_CONTEXT);
|
|
||||||
useFilePathInContext.setDefaultValue(false);
|
|
||||||
useFilePathInContext.setLabelText(Tr::tr("Use File Path in Context"));
|
|
||||||
|
|
||||||
useSpecificInstructions.setSettingsKey(Constants::USE_SPECIFIC_INSTRUCTIONS);
|
|
||||||
useSpecificInstructions.setDefaultValue(false);
|
|
||||||
useSpecificInstructions.setLabelText(Tr::tr("Use Specific Instructions"));
|
|
||||||
|
|
||||||
specificInstractions.setSettingsKey(Constants::SPECIFIC_INSTRUCTIONS);
|
|
||||||
specificInstractions.setDisplayStyle(Utils::StringAspect::TextEditDisplay);
|
|
||||||
specificInstractions.setLabelText(
|
|
||||||
Tr::tr("Instructions: Please keep %1 for languge name, warning, it shouldn't too big"));
|
|
||||||
specificInstractions.setDefaultValue(
|
|
||||||
"You are an expert %1 code completion AI."
|
|
||||||
"CRITICAL: Please provide minimal the best possible code completion suggestions.\n");
|
|
||||||
|
|
||||||
resetToDefaults.m_buttonText = Tr::tr("Reset to Defaults");
|
resetToDefaults.m_buttonText = Tr::tr("Reset to Defaults");
|
||||||
multiLineCompletion.setSettingsKey(Constants::MULTILINE_COMPLETION);
|
|
||||||
multiLineCompletion.setDefaultValue(true);
|
|
||||||
multiLineCompletion.setLabelText(Tr::tr("Enable Multiline Completion"));
|
|
||||||
|
|
||||||
apiKey.setSettingsKey(Constants::API_KEY);
|
apiKey.setSettingsKey(Constants::API_KEY);
|
||||||
apiKey.setLabelText(Tr::tr("API Key:"));
|
apiKey.setLabelText(Tr::tr("API Key:"));
|
||||||
@ -175,9 +139,7 @@ QodeAssistSettings::QodeAssistSettings()
|
|||||||
topP.setEnabled(useTopP());
|
topP.setEnabled(useTopP());
|
||||||
presencePenalty.setEnabled(usePresencePenalty());
|
presencePenalty.setEnabled(usePresencePenalty());
|
||||||
frequencyPenalty.setEnabled(useFrequencyPenalty());
|
frequencyPenalty.setEnabled(useFrequencyPenalty());
|
||||||
readStringsAfterCursor.setEnabled(!readFullFile());
|
|
||||||
readStringsBeforeCursor.setEnabled(!readFullFile());
|
|
||||||
specificInstractions.setEnabled(useSpecificInstructions());
|
|
||||||
customJsonTemplate.setVisible(PromptTemplateManager::instance().getCurrentTemplate()->name()
|
customJsonTemplate.setVisible(PromptTemplateManager::instance().getCurrentTemplate()->name()
|
||||||
== "Custom Template");
|
== "Custom Template");
|
||||||
|
|
||||||
@ -189,15 +151,15 @@ QodeAssistSettings::QodeAssistSettings()
|
|||||||
Row{saveCustomTemplateButton,
|
Row{saveCustomTemplateButton,
|
||||||
loadCustomTemplateButton,
|
loadCustomTemplateButton,
|
||||||
Stretch{1}}},
|
Stretch{1}}},
|
||||||
readFullFile,
|
// readFullFile,
|
||||||
maxFileThreshold,
|
// maxFileThreshold,
|
||||||
readStringsBeforeCursor,
|
// readStringsBeforeCursor,
|
||||||
readStringsAfterCursor,
|
// readStringsAfterCursor,
|
||||||
ollamaLivetime,
|
ollamaLivetime,
|
||||||
apiKey,
|
apiKey,
|
||||||
useFilePathInContext,
|
// useFilePathInContext,
|
||||||
useSpecificInstructions,
|
// useSpecificInstructions,
|
||||||
specificInstractions,
|
// specificInstractions,
|
||||||
temperature,
|
temperature,
|
||||||
maxTokens,
|
maxTokens,
|
||||||
startSuggestionTimer,
|
startSuggestionTimer,
|
||||||
@ -225,19 +187,12 @@ void QodeAssistSettings::setupConnections()
|
|||||||
connect(&useFrequencyPenalty, &Utils::BoolAspect::volatileValueChanged, this, [this]() {
|
connect(&useFrequencyPenalty, &Utils::BoolAspect::volatileValueChanged, this, [this]() {
|
||||||
frequencyPenalty.setEnabled(useFrequencyPenalty.volatileValue());
|
frequencyPenalty.setEnabled(useFrequencyPenalty.volatileValue());
|
||||||
});
|
});
|
||||||
connect(&readFullFile, &Utils::BoolAspect::volatileValueChanged, this, [this]() {
|
|
||||||
readStringsAfterCursor.setEnabled(!readFullFile.volatileValue());
|
|
||||||
readStringsBeforeCursor.setEnabled(!readFullFile.volatileValue());
|
|
||||||
});
|
|
||||||
connect(&resetToDefaults,
|
connect(&resetToDefaults,
|
||||||
&ButtonAspect::clicked,
|
&ButtonAspect::clicked,
|
||||||
this,
|
this,
|
||||||
&QodeAssistSettings::resetSettingsToDefaults);
|
&QodeAssistSettings::resetSettingsToDefaults);
|
||||||
|
|
||||||
connect(&useSpecificInstructions, &Utils::BoolAspect::volatileValueChanged, this, [this]() {
|
|
||||||
specificInstractions.setEnabled(useSpecificInstructions.volatileValue());
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(&saveCustomTemplateButton,
|
connect(&saveCustomTemplateButton,
|
||||||
&ButtonAspect::clicked,
|
&ButtonAspect::clicked,
|
||||||
this,
|
this,
|
||||||
@ -277,10 +232,10 @@ void QodeAssistSettings::resetSettingsToDefaults()
|
|||||||
// resetAspect(fimPrompts);
|
// resetAspect(fimPrompts);
|
||||||
resetAspect(temperature);
|
resetAspect(temperature);
|
||||||
resetAspect(maxTokens);
|
resetAspect(maxTokens);
|
||||||
resetAspect(readFullFile);
|
// resetAspect(readFullFile);
|
||||||
resetAspect(maxFileThreshold);
|
// resetAspect(maxFileThreshold);
|
||||||
resetAspect(readStringsBeforeCursor);
|
// resetAspect(readStringsBeforeCursor);
|
||||||
resetAspect(readStringsAfterCursor);
|
// resetAspect(readStringsAfterCursor);
|
||||||
resetAspect(useTopP);
|
resetAspect(useTopP);
|
||||||
resetAspect(topP);
|
resetAspect(topP);
|
||||||
resetAspect(useTopK);
|
resetAspect(useTopK);
|
||||||
@ -292,10 +247,10 @@ void QodeAssistSettings::resetSettingsToDefaults()
|
|||||||
resetAspect(startSuggestionTimer);
|
resetAspect(startSuggestionTimer);
|
||||||
// resetAspect(enableLogging);
|
// resetAspect(enableLogging);
|
||||||
resetAspect(ollamaLivetime);
|
resetAspect(ollamaLivetime);
|
||||||
resetAspect(specificInstractions);
|
// resetAspect(specificInstractions);
|
||||||
resetAspect(multiLineCompletion);
|
// resetAspect(multiLineCompletion);
|
||||||
resetAspect(useFilePathInContext);
|
// resetAspect(useFilePathInContext);
|
||||||
resetAspect(useSpecificInstructions);
|
// resetAspect(useSpecificInstructions);
|
||||||
resetAspect(customJsonTemplate);
|
resetAspect(customJsonTemplate);
|
||||||
|
|
||||||
// fimPrompts.setStringValue("StarCoder2");
|
// fimPrompts.setStringValue("StarCoder2");
|
||||||
|
@ -60,10 +60,6 @@ public:
|
|||||||
Utils::DoubleAspect temperature{this};
|
Utils::DoubleAspect temperature{this};
|
||||||
Utils::IntegerAspect maxTokens{this};
|
Utils::IntegerAspect maxTokens{this};
|
||||||
|
|
||||||
Utils::BoolAspect readFullFile{this};
|
|
||||||
Utils::IntegerAspect readStringsBeforeCursor{this};
|
|
||||||
Utils::IntegerAspect readStringsAfterCursor{this};
|
|
||||||
|
|
||||||
Utils::BoolAspect useTopP{this};
|
Utils::BoolAspect useTopP{this};
|
||||||
Utils::DoubleAspect topP{this};
|
Utils::DoubleAspect topP{this};
|
||||||
|
|
||||||
@ -77,13 +73,8 @@ public:
|
|||||||
Utils::DoubleAspect frequencyPenalty{this};
|
Utils::DoubleAspect frequencyPenalty{this};
|
||||||
|
|
||||||
Utils::IntegerAspect startSuggestionTimer{this};
|
Utils::IntegerAspect startSuggestionTimer{this};
|
||||||
Utils::IntegerAspect maxFileThreshold{this};
|
|
||||||
|
|
||||||
Utils::StringAspect ollamaLivetime{this};
|
Utils::StringAspect ollamaLivetime{this};
|
||||||
Utils::StringAspect specificInstractions{this};
|
|
||||||
Utils::BoolAspect useSpecificInstructions{this};
|
|
||||||
Utils::BoolAspect useFilePathInContext{this};
|
|
||||||
Utils::BoolAspect multiLineCompletion{this};
|
|
||||||
|
|
||||||
Utils::StringAspect customJsonTemplate{this};
|
Utils::StringAspect customJsonTemplate{this};
|
||||||
ButtonAspect saveCustomTemplateButton{this};
|
ButtonAspect saveCustomTemplateButton{this};
|
||||||
|
@ -21,7 +21,9 @@
|
|||||||
|
|
||||||
#include "ContextSettings.hpp"
|
#include "ContextSettings.hpp"
|
||||||
|
|
||||||
|
#include <QMessageBox>
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
#include <utils/layoutbuilder.h>
|
#include <utils/layoutbuilder.h>
|
||||||
|
|
||||||
#include "QodeAssistConstants.hpp"
|
#include "QodeAssistConstants.hpp"
|
||||||
@ -40,12 +42,93 @@ ContextSettings::ContextSettings()
|
|||||||
|
|
||||||
setDisplayName(Tr::tr("Context"));
|
setDisplayName(Tr::tr("Context"));
|
||||||
|
|
||||||
|
readFullFile.setSettingsKey(Constants::READ_FULL_FILE);
|
||||||
|
readFullFile.setLabelText(Tr::tr("Read Full File"));
|
||||||
|
readFullFile.setDefaultValue(false);
|
||||||
|
|
||||||
|
readStringsBeforeCursor.setSettingsKey(Constants::READ_STRINGS_BEFORE_CURSOR);
|
||||||
|
readStringsBeforeCursor.setLabelText(Tr::tr("Read Strings Before Cursor"));
|
||||||
|
readStringsBeforeCursor.setRange(0, 10000);
|
||||||
|
readStringsBeforeCursor.setDefaultValue(50);
|
||||||
|
|
||||||
|
readStringsAfterCursor.setSettingsKey(Constants::READ_STRINGS_AFTER_CURSOR);
|
||||||
|
readStringsAfterCursor.setLabelText(Tr::tr("Read Strings After Cursor"));
|
||||||
|
readStringsAfterCursor.setRange(0, 10000);
|
||||||
|
readStringsAfterCursor.setDefaultValue(30);
|
||||||
|
|
||||||
|
useFilePathInContext.setSettingsKey(Constants::USE_FILE_PATH_IN_CONTEXT);
|
||||||
|
useFilePathInContext.setDefaultValue(false);
|
||||||
|
useFilePathInContext.setLabelText(Tr::tr("Use File Path in Context"));
|
||||||
|
|
||||||
|
useSpecificInstructions.setSettingsKey(Constants::USE_SPECIFIC_INSTRUCTIONS);
|
||||||
|
useSpecificInstructions.setDefaultValue(false);
|
||||||
|
useSpecificInstructions.setLabelText(Tr::tr("Use Specific Instructions"));
|
||||||
|
|
||||||
|
specificInstractions.setSettingsKey(Constants::SPECIFIC_INSTRUCTIONS);
|
||||||
|
specificInstractions.setDisplayStyle(Utils::StringAspect::TextEditDisplay);
|
||||||
|
specificInstractions.setLabelText(
|
||||||
|
Tr::tr("Instructions: Please keep %1 for languge name, warning, it shouldn't too big"));
|
||||||
|
specificInstractions.setDefaultValue(
|
||||||
|
"You are an expert %1 code completion AI."
|
||||||
|
"CRITICAL: Please provide minimal the best possible code completion suggestions.\n");
|
||||||
|
|
||||||
|
resetToDefaults.m_buttonText = Tr::tr("Reset Page to Defaults");
|
||||||
|
|
||||||
|
readSettings();
|
||||||
|
|
||||||
|
readStringsAfterCursor.setEnabled(!readFullFile());
|
||||||
|
readStringsBeforeCursor.setEnabled(!readFullFile());
|
||||||
|
specificInstractions.setEnabled(useSpecificInstructions());
|
||||||
|
|
||||||
|
setupConnection();
|
||||||
|
|
||||||
setLayouter([this]() {
|
setLayouter([this]() {
|
||||||
using namespace Layouting;
|
using namespace Layouting;
|
||||||
return Column{Stretch{1}};
|
return Column{Row{readFullFile, Stretch{1}, resetToDefaults},
|
||||||
|
readStringsBeforeCursor,
|
||||||
|
readStringsAfterCursor,
|
||||||
|
useFilePathInContext,
|
||||||
|
useSpecificInstructions,
|
||||||
|
specificInstractions,
|
||||||
|
Stretch{1}};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContextSettings::setupConnection()
|
||||||
|
{
|
||||||
|
connect(&readFullFile, &Utils::BoolAspect::volatileValueChanged, this, [this]() {
|
||||||
|
readStringsAfterCursor.setEnabled(!readFullFile.volatileValue());
|
||||||
|
readStringsBeforeCursor.setEnabled(!readFullFile.volatileValue());
|
||||||
|
});
|
||||||
|
connect(&useSpecificInstructions, &Utils::BoolAspect::volatileValueChanged, this, [this]() {
|
||||||
|
specificInstractions.setEnabled(useSpecificInstructions.volatileValue());
|
||||||
|
});
|
||||||
|
connect(&resetToDefaults, &ButtonAspect::clicked, this, &ContextSettings::resetPageToDefaults);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContextSettings::resetPageToDefaults()
|
||||||
|
{
|
||||||
|
QMessageBox::StandardButton reply;
|
||||||
|
reply = QMessageBox::question(
|
||||||
|
Core::ICore::dialogParent(),
|
||||||
|
Tr::tr("Reset Settings"),
|
||||||
|
Tr::tr("Are you sure you want to reset all settings to default values?"),
|
||||||
|
QMessageBox::Yes | QMessageBox::No);
|
||||||
|
|
||||||
|
if (reply == QMessageBox::Yes) {
|
||||||
|
resetAspect(readFullFile);
|
||||||
|
resetAspect(readStringsBeforeCursor);
|
||||||
|
resetAspect(readStringsAfterCursor);
|
||||||
|
resetAspect(useFilePathInContext);
|
||||||
|
resetAspect(useSpecificInstructions);
|
||||||
|
resetAspect(specificInstractions);
|
||||||
|
}
|
||||||
|
|
||||||
|
QMessageBox::information(Core::ICore::dialogParent(),
|
||||||
|
Tr::tr("Settings Reset"),
|
||||||
|
Tr::tr("All settings have been reset to their default values."));
|
||||||
|
}
|
||||||
|
|
||||||
class ContextSettingsPage : public Core::IOptionsPage
|
class ContextSettingsPage : public Core::IOptionsPage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -21,12 +21,28 @@
|
|||||||
|
|
||||||
#include <utils/aspects.h>
|
#include <utils/aspects.h>
|
||||||
|
|
||||||
|
#include "SettingsUtils.hpp"
|
||||||
|
|
||||||
namespace QodeAssist::Settings {
|
namespace QodeAssist::Settings {
|
||||||
|
|
||||||
class ContextSettings : public Utils::AspectContainer
|
class ContextSettings : public Utils::AspectContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ContextSettings();
|
ContextSettings();
|
||||||
|
|
||||||
|
Utils::BoolAspect readFullFile{this};
|
||||||
|
Utils::IntegerAspect readStringsBeforeCursor{this};
|
||||||
|
Utils::IntegerAspect readStringsAfterCursor{this};
|
||||||
|
|
||||||
|
Utils::StringAspect specificInstractions{this};
|
||||||
|
Utils::BoolAspect useSpecificInstructions{this};
|
||||||
|
Utils::BoolAspect useFilePathInContext{this};
|
||||||
|
|
||||||
|
ButtonAspect resetToDefaults{this};
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setupConnection();
|
||||||
|
void resetPageToDefaults();
|
||||||
};
|
};
|
||||||
|
|
||||||
ContextSettings &contextSettings();
|
ContextSettings &contextSettings();
|
||||||
|
@ -155,8 +155,8 @@ void GeneralSettings::updateProviderSettings()
|
|||||||
const auto provider = LLMProvidersManager::instance().getCurrentProvider();
|
const auto provider = LLMProvidersManager::instance().getCurrentProvider();
|
||||||
|
|
||||||
if (provider) {
|
if (provider) {
|
||||||
url.setValue(provider->url());
|
url.setVolatileValue(provider->url());
|
||||||
endPoint.setValue(provider->completionEndpoint());
|
endPoint.setVolatileValue(provider->completionEndpoint());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ void GeneralSettings::showModelSelectionDialog()
|
|||||||
&ok);
|
&ok);
|
||||||
|
|
||||||
if (ok && !selectedModel.isEmpty()) {
|
if (ok && !selectedModel.isEmpty()) {
|
||||||
modelName.setValue(selectedModel);
|
modelName.setVolatileValue(selectedModel);
|
||||||
writeSettings();
|
writeSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -206,8 +206,6 @@ void GeneralSettings::resetPageToDefaults()
|
|||||||
fimPrompts.setStringValue("StarCoder2");
|
fimPrompts.setStringValue("StarCoder2");
|
||||||
llmProviders.setStringValue("Ollama");
|
llmProviders.setStringValue("Ollama");
|
||||||
|
|
||||||
apply();
|
|
||||||
|
|
||||||
QMessageBox::information(Core::ICore::dialogParent(),
|
QMessageBox::information(Core::ICore::dialogParent(),
|
||||||
Tr::tr("Settings Reset"),
|
Tr::tr("Settings Reset"),
|
||||||
Tr::tr("All settings have been reset to their default values."));
|
Tr::tr("All settings have been reset to their default values."));
|
||||||
|
@ -28,7 +28,7 @@ namespace QodeAssist::Settings {
|
|||||||
template<typename AspectType>
|
template<typename AspectType>
|
||||||
void resetAspect(AspectType &aspect)
|
void resetAspect(AspectType &aspect)
|
||||||
{
|
{
|
||||||
aspect.setValue(aspect.defaultValue());
|
aspect.setVolatileValue(aspect.defaultValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
class ButtonAspect : public Utils::BaseAspect
|
class ButtonAspect : public Utils::BaseAspect
|
||||||
|
Loading…
x
Reference in New Issue
Block a user