mirror of
				https://github.com/Palm1r/QodeAssist.git
				synced 2025-10-31 08:14:36 -04:00 
			
		
		
		
	refactor: Move context to separate lib
This commit is contained in:
		| @ -16,6 +16,7 @@ add_subdirectory(llmcore) | ||||
| add_subdirectory(settings) | ||||
| add_subdirectory(logger) | ||||
| add_subdirectory(ChatView) | ||||
| add_subdirectory(context) | ||||
|  | ||||
| add_qtc_plugin(QodeAssist | ||||
|   PLUGIN_DEPENDS | ||||
| @ -63,9 +64,6 @@ add_qtc_plugin(QodeAssist | ||||
|     LSPCompletion.hpp | ||||
|     LLMSuggestion.hpp LLMSuggestion.cpp | ||||
|     QodeAssistClient.hpp QodeAssistClient.cpp | ||||
|     DocumentContextReader.hpp DocumentContextReader.cpp | ||||
|     utils/CounterTooltip.hpp utils/CounterTooltip.cpp | ||||
|     core/ChangesManager.h core/ChangesManager.cpp | ||||
|     chat/ChatOutputPane.h chat/ChatOutputPane.cpp | ||||
|     chat/NavigationPanel.hpp chat/NavigationPanel.cpp | ||||
|     ConfigurationManager.hpp ConfigurationManager.cpp | ||||
|  | ||||
| @ -33,6 +33,7 @@ target_link_libraries(QodeAssistChatView | ||||
|     QtCreator::Utils | ||||
|     LLMCore | ||||
|     QodeAssistSettings | ||||
|     Context | ||||
| ) | ||||
|  | ||||
| target_include_directories(QodeAssistChatView | ||||
|  | ||||
| @ -27,7 +27,7 @@ | ||||
| #include <texteditor/textdocument.h> | ||||
|  | ||||
| #include "CodeHandler.hpp" | ||||
| #include "DocumentContextReader.hpp" | ||||
| #include "context/DocumentContextReader.hpp" | ||||
| #include "llmcore/MessageBuilder.hpp" | ||||
| #include "llmcore/PromptTemplateManager.hpp" | ||||
| #include "llmcore/ProvidersManager.hpp" | ||||
|  | ||||
| @ -31,10 +31,10 @@ | ||||
|  | ||||
| #include "LLMClientInterface.hpp" | ||||
| #include "LLMSuggestion.hpp" | ||||
| #include "core/ChangesManager.h" | ||||
| #include "settings/CodeCompletionSettings.hpp" | ||||
| #include "settings/GeneralSettings.hpp" | ||||
| #include "settings/ProjectSettings.hpp" | ||||
| #include <context/ChangesManager.h> | ||||
|  | ||||
| using namespace LanguageServerProtocol; | ||||
| using namespace TextEditor; | ||||
|  | ||||
							
								
								
									
										18
									
								
								context/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								context/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,18 @@ | ||||
| add_library(Context STATIC | ||||
|     DocumentContextReader.hpp DocumentContextReader.cpp | ||||
|     ChangesManager.h ChangesManager.cpp | ||||
| ) | ||||
|  | ||||
| target_link_libraries(Context | ||||
|     PUBLIC | ||||
|     Qt::Core | ||||
|     QtCreator::Core | ||||
|     QtCreator::TextEditor | ||||
|     QtCreator::Utils | ||||
|     QtCreator::ProjectExplorer | ||||
|     PRIVATE | ||||
|     LLMCore | ||||
|     QodeAssistSettings | ||||
| ) | ||||
|  | ||||
| target_include_directories(Context PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}) | ||||
| @ -18,7 +18,7 @@ | ||||
|  */ | ||||
| 
 | ||||
| #include "ChangesManager.h" | ||||
| #include "settings/CodeCompletionSettings.hpp" | ||||
| #include "CodeCompletionSettings.hpp" | ||||
| 
 | ||||
| namespace QodeAssist { | ||||
| 
 | ||||
| @ -23,8 +23,9 @@ | ||||
| #include <QTextBlock> | ||||
| #include <languageserverprotocol/lsptypes.h> | ||||
| 
 | ||||
| #include "core/ChangesManager.h" | ||||
| #include "settings/CodeCompletionSettings.hpp" | ||||
| #include "CodeCompletionSettings.hpp" | ||||
| 
 | ||||
| #include "ChangesManager.h" | ||||
| 
 | ||||
| const QRegularExpression &getYearRegex() | ||||
| { | ||||
| @ -19,8 +19,8 @@ | ||||
| 
 | ||||
| #pragma once | ||||
| 
 | ||||
| #include <QTextDocument> | ||||
| #include <texteditor/textdocument.h> | ||||
| #include <QTextDocument> | ||||
| 
 | ||||
| #include <llmcore/ContextData.hpp> | ||||
| 
 | ||||
| @ -1,19 +0,0 @@ | ||||
| { | ||||
|   "prompt": "{{QODE_INSTRUCTIONS}}<fim_prefix>{{QODE_PREFIX}}<fim_suffix>{{QODE_SUFFIX}}<fim_middle>", | ||||
|   "options": { | ||||
|     "temperature": 0.7, | ||||
|     "top_p": 0.95, | ||||
|     "top_k": 40, | ||||
|     "num_predict": 175, | ||||
|     "stop": [ | ||||
|       "<|endoftext|>", | ||||
|       "<file_sep>", | ||||
|       "<fim_prefix>", | ||||
|       "<fim_suffix>", | ||||
|       "<fim_middle>" | ||||
|     ], | ||||
|     "frequency_penalty": 0, | ||||
|     "presence_penalty": 0 | ||||
|   }, | ||||
|   "stream": true | ||||
| } | ||||
| @ -1,16 +0,0 @@ | ||||
| { | ||||
|   "max_tokens": 150, | ||||
|   "messages": [ | ||||
|     { | ||||
|       "content": "{{QODE_INSTRUCTIONS}}\n### Instruction:{{QODE_PREFIX}}{{QODE_SUFFIX}} ### Response:\n", | ||||
|       "role": "user" | ||||
|     } | ||||
|   ], | ||||
|   "stop": [ | ||||
|     "### Instruction:", | ||||
|     "### Response:", | ||||
|     "\n\n### " | ||||
|   ], | ||||
|   "stream": true, | ||||
|   "temperature": 0.2 | ||||
| } | ||||
| @ -1,48 +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 <https://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #include "CounterTooltip.hpp" | ||||
|  | ||||
| namespace QodeAssist { | ||||
|  | ||||
| CounterTooltip::CounterTooltip(int count) | ||||
|     : m_count(count) | ||||
| { | ||||
|     m_label = new QLabel(this); | ||||
|     addWidget(m_label); | ||||
|     updateLabel(); | ||||
|  | ||||
|     m_timer = new QTimer(this); | ||||
|     m_timer->setSingleShot(true); | ||||
|     m_timer->setInterval(2000); | ||||
|  | ||||
|     connect(m_timer, &QTimer::timeout, this, [this] { emit finished(m_count); }); | ||||
|  | ||||
|     m_timer->start(); | ||||
| } | ||||
|  | ||||
| CounterTooltip::~CounterTooltip() {} | ||||
|  | ||||
| void CounterTooltip::updateLabel() | ||||
| { | ||||
|     const auto hotkey = QKeySequence(QKeySequence::MoveToNextWord).toString(); | ||||
|     m_label->setText(QString("Insert Next %1 line(s) (%2)").arg(m_count).arg(hotkey)); | ||||
| } | ||||
|  | ||||
| } // namespace QodeAssist | ||||
| @ -1,48 +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 <https://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #include <QLabel> | ||||
| #include <QTimer> | ||||
| #include <QToolBar> | ||||
| #include <QWidget> | ||||
|  | ||||
| namespace QodeAssist { | ||||
|  | ||||
| class CounterTooltip : public QToolBar | ||||
| { | ||||
|     Q_OBJECT | ||||
|  | ||||
| public: | ||||
|     CounterTooltip(int count); | ||||
|     ~CounterTooltip(); | ||||
|  | ||||
| signals: | ||||
|     void finished(int count); | ||||
|  | ||||
| private: | ||||
|     void updateLabel(); | ||||
|  | ||||
|     QLabel *m_label; | ||||
|     QTimer *m_timer; | ||||
|     int m_count; | ||||
| }; | ||||
|  | ||||
| } // namespace QodeAssist | ||||
		Reference in New Issue
	
	Block a user