diff --git a/CMakeLists.txt b/CMakeLists.txt index fe51fc1..343e53c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,6 @@ add_qtc_plugin(QodeAssist providers/LMStudioProvider.hpp providers/LMStudioProvider.cpp providers/OpenAICompatProvider.hpp providers/OpenAICompatProvider.cpp LLMProvidersManager.hpp LLMProvidersManager.cpp - QodeAssistSettings.hpp QodeAssistSettings.cpp QodeAssist.qrc LSPCompletion.hpp LLMSuggestion.hpp LLMSuggestion.cpp diff --git a/DocumentContextReader.cpp b/DocumentContextReader.cpp index b8d8fad..063162b 100644 --- a/DocumentContextReader.cpp +++ b/DocumentContextReader.cpp @@ -23,7 +23,6 @@ #include #include -#include "QodeAssistSettings.hpp" #include "settings/ContextSettings.hpp" const QRegularExpression &getYearRegex() diff --git a/LLMClientInterface.cpp b/LLMClientInterface.cpp index 217f3b8..a473ac1 100644 --- a/LLMClientInterface.cpp +++ b/LLMClientInterface.cpp @@ -28,7 +28,6 @@ #include "DocumentContextReader.hpp" #include "LLMProvidersManager.hpp" #include "PromptTemplateManager.hpp" -#include "QodeAssistSettings.hpp" #include "QodeAssistUtils.hpp" #include "settings/ContextSettings.hpp" #include "settings/GeneralSettings.hpp" diff --git a/QodeAssistClient.cpp b/QodeAssistClient.cpp index 3a46793..34cea5e 100644 --- a/QodeAssistClient.cpp +++ b/QodeAssistClient.cpp @@ -31,7 +31,6 @@ #include "LLMClientInterface.hpp" #include "LLMSuggestion.hpp" -#include "QodeAssistSettings.hpp" #include "settings/GeneralSettings.hpp" using namespace LanguageServerProtocol; diff --git a/QodeAssistSettings.cpp b/QodeAssistSettings.cpp deleted file mode 100644 index 85faa5c..0000000 --- a/QodeAssistSettings.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/* - * 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 . - */ - -#include "QodeAssistSettings.hpp" - -#include -#include -#include -#include -#include -#include - -#include "QodeAssistConstants.hpp" -#include "QodeAssisttr.h" - -#include "LLMProvidersManager.hpp" -#include "PromptTemplateManager.hpp" -#include "QodeAssistUtils.hpp" - -namespace QodeAssist { - -QodeAssistSettings &settings() -{ - static QodeAssistSettings settings; - return settings; -} - -QodeAssistSettings::QodeAssistSettings() -{ - setAutoApply(false); - - readSettings(); - - setLayouter([this]() { - using namespace Layouting; - - return Column{Group{title(Tr::tr("FIM Prompt Settings")), - Form{Column{Column{ - }, - // readFullFile, - // maxFileThreshold, - // readStringsBeforeCursor, - // readStringsAfterCursor, - // ollamaLivetime, - // apiKey, - // useFilePathInContext, - // useSpecificInstructions, - // specificInstractions, - // temperature, - // maxTokens, - // startSuggestionTimer, - // Row{useTopP, topP, Stretch{1}}, - // Row{useTopK, topK, Stretch{1}}, -/* Row{usePresencePenalty, presencePenalty, Stretch{1}}, - Row{useFrequencyPenalty, frequencyPenalty, Stretch{1}}*/}}}, - st}; - }); - - setupConnections(); -} - -void QodeAssistSettings::setupConnections() -{ - -} - -QStringList QodeAssistSettings::getInstalledModels() -{ - auto *provider = LLMProvidersManager::instance().getCurrentProvider(); - if (provider) { - Utils::Environment env = Utils::Environment::systemEnvironment(); - return provider->getInstalledModels(env); - } - return {}; -} - -void QodeAssistSettings::resetSettingsToDefaults() -{ - 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(enableQodeAssist); - // resetAspect(enableAutoComplete); - // resetAspect(llmProviders); - // resetAspect(url); - // resetAspect(endPoint); - // resetAspect(modelName); - // resetAspect(fimPrompts); - // resetAspect(temperature); - // resetAspect(maxTokens); - // resetAspect(readFullFile); - // resetAspect(maxFileThreshold); - // resetAspect(readStringsBeforeCursor); - // resetAspect(readStringsAfterCursor); - // resetAspect(useTopP); - // resetAspect(topP); - // resetAspect(useTopK); - // resetAspect(topK); - // resetAspect(usePresencePenalty); - // resetAspect(presencePenalty); - // resetAspect(useFrequencyPenalty); - // resetAspect(frequencyPenalty); - // resetAspect(startSuggestionTimer); - // resetAspect(enableLogging); - // resetAspect(ollamaLivetime); - // resetAspect(specificInstractions); - // resetAspect(multiLineCompletion); - // resetAspect(useFilePathInContext); - // resetAspect(useSpecificInstructions); - // resetAspect(customJsonTemplate); - - // fimPrompts.setStringValue("StarCoder2"); - // llmProviders.setStringValue("Ollama"); - - apply(); - - QMessageBox::information(Core::ICore::dialogParent(), - Tr::tr("Settings Reset"), - Tr::tr("All settings have been reset to their default values.")); - } -} - -void QodeAssistSettings::saveCustomTemplate() -{ - // QString fileName = QFileDialog::getSaveFileName(nullptr, - // Tr::tr("Save JSON Template"), - // QString(), - // Tr::tr("JSON Files (*.json)")); - // if (fileName.isEmpty()) - // return; - - // QFile file(fileName); - // if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { - // QTextStream out(&file); - // out << customJsonTemplate.value(); - // file.close(); - // QMessageBox::information(nullptr, - // Tr::tr("Save Successful"), - // Tr::tr("JSON template has been saved successfully.")); - // } else { - // QMessageBox::critical(nullptr, - // Tr::tr("Save Failed"), - // Tr::tr("Failed to save JSON template.")); - // } -} - -void QodeAssistSettings::loadCustomTemplate() -{ - // QString fileName = QFileDialog::getOpenFileName(nullptr, - // Tr::tr("Load JSON Template"), - // QString(), - // Tr::tr("JSON Files (*.json)")); - // if (fileName.isEmpty()) - // return; - - // QFile file(fileName); - // if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { - // QTextStream in(&file); - // QString jsonContent = in.readAll(); - // file.close(); - - // QJsonParseError parseError; - // QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonContent.toUtf8(), &parseError); - // if (parseError.error == QJsonParseError::NoError) { - // customJsonTemplate.setValue(jsonContent); - // QMessageBox::information(nullptr, - // Tr::tr("Load Successful"), - // Tr::tr("JSON template has been loaded successfully.")); - // } else { - // QMessageBox::critical(nullptr, - // Tr::tr("Invalid JSON"), - // Tr::tr("The selected file contains invalid JSON.")); - // } - // } else { - // QMessageBox::critical(nullptr, - // Tr::tr("Load Failed"), - // Tr::tr("Failed to load JSON template.")); - // } -} - -class QodeAssistSettingsPage : public Core::IOptionsPage -{ -public: - QodeAssistSettingsPage() - { - setId(Constants::QODE_ASSIST_GENERAL_OPTIONS_ID); - setDisplayName("Qode Assist"); - setCategory(Constants::QODE_ASSIST_GENERAL_OPTIONS_CATEGORY); - setDisplayCategory(Constants::QODE_ASSIST_GENERAL_OPTIONS_DISPLAY_CATEGORY); - setCategoryIconPath(":/resources/images/qoderassist-icon.png"); - setSettingsProvider([] { return &settings(); }); - } -}; - -const QodeAssistSettingsPage settingsPage; - -} // namespace QodeAssist diff --git a/QodeAssistSettings.hpp b/QodeAssistSettings.hpp deleted file mode 100644 index 753ea98..0000000 --- a/QodeAssistSettings.hpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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 . - */ - -#pragma once - -#include -#include -#include - -namespace QodeAssist { - -template -void resetAspect(AspectType &aspect) -{ - aspect.setValue(aspect.defaultValue()); -} - -class ButtonAspect : public Utils::BaseAspect -{ - Q_OBJECT - -public: - ButtonAspect(Utils::AspectContainer *container = nullptr) - : Utils::BaseAspect(container) - {} - - void addToLayout(Layouting::Layout &parent) override - { - auto button = new QPushButton(m_buttonText); - connect(button, &QPushButton::clicked, this, &ButtonAspect::clicked); - parent.addItem(button); - } - - QString m_buttonText; -signals: - void clicked(); -}; - -class QodeAssistSettings : public Utils::AspectContainer -{ -public: - QodeAssistSettings(); - -private: - void setupConnections(); - QStringList getInstalledModels(); - Utils::Environment getEnvironmentWithProviderPaths() const; - void resetSettingsToDefaults(); - void saveCustomTemplate(); - void loadCustomTemplate(); -}; - -QodeAssistSettings &settings(); - -} // namespace QodeAssist diff --git a/providers/LMStudioProvider.cpp b/providers/LMStudioProvider.cpp index 96cf058..dba91bc 100644 --- a/providers/LMStudioProvider.cpp +++ b/providers/LMStudioProvider.cpp @@ -26,7 +26,6 @@ #include #include "PromptTemplateManager.hpp" -#include "QodeAssistSettings.hpp" #include "QodeAssistUtils.hpp" #include "settings/PresetPromptsSettings.hpp" diff --git a/providers/OllamaProvider.cpp b/providers/OllamaProvider.cpp index d3900d5..ab9a1ce 100644 --- a/providers/OllamaProvider.cpp +++ b/providers/OllamaProvider.cpp @@ -26,7 +26,6 @@ #include #include "PromptTemplateManager.hpp" -#include "QodeAssistSettings.hpp" #include "QodeAssistUtils.hpp" #include "settings/PresetPromptsSettings.hpp" diff --git a/providers/OpenAICompatProvider.cpp b/providers/OpenAICompatProvider.cpp index d55ca45..6214678 100644 --- a/providers/OpenAICompatProvider.cpp +++ b/providers/OpenAICompatProvider.cpp @@ -25,7 +25,6 @@ #include #include "PromptTemplateManager.hpp" -#include "QodeAssistSettings.hpp" #include "settings/PresetPromptsSettings.hpp" namespace QodeAssist::Providers { diff --git a/templates/CustomTemplate.hpp b/templates/CustomTemplate.hpp index 0c41824..5ae2e24 100644 --- a/templates/CustomTemplate.hpp +++ b/templates/CustomTemplate.hpp @@ -24,7 +24,6 @@ #include #include -#include "QodeAssistSettings.hpp" #include "QodeAssistUtils.hpp" #include "settings/CustomPromptSettings.hpp"