| 36 | } |
| 37 | |
| 38 | bool ChatPlugin::start() |
| 39 | { |
| 40 | auto windowService = dpfGetService(dpfservice::WindowService); |
| 41 | if (windowService) { |
| 42 | auto Chat = new ChatWidget; |
| 43 | auto ChatImpl = new AbstractWidget(Chat); |
| 44 | windowService->addWidgetRightspace(MWNA_CHAT, ChatImpl, ""); |
| 45 | } |
| 46 | |
| 47 | auto optionService = dpfGetService(dpfservice::OptionService); |
| 48 | if (optionService) { |
| 49 | optionService->implGenerator<OptionChatGenerator>(option::GROUP_AI, OptionChatGenerator::kitName()); |
| 50 | } |
| 51 | |
| 52 | Copilot::instance(); |
| 53 | ChatManager::instance()->checkCondaInstalled(); |
| 54 | |
| 55 | connect(&dpf::Listener::instance(), &dpf::Listener::pluginsStarted, [=] { |
| 56 | QTimer::singleShot(5000, windowService, [=] { |
| 57 | #ifdef SUPPORTMINIFORGE |
| 58 | if (!ChatManager::instance()->condaHasInstalled()) { |
| 59 | QStringList actions { "ai_rag_install", ChatPlugin::tr("Install") }; |
| 60 | windowService->notify(0, "AI", ChatPlugin::tr("Install a Python Conda virtual environment for using the file indexing feature.\ |
| 61 | Without it, there may be abnormalities in the @codebase and some AI functionalities."), |
| 62 | actions); |
| 63 | } |
| 64 | #endif |
| 65 | }); |
| 66 | }); |
| 67 | |
| 68 | using namespace std::placeholders; |
| 69 | auto aiService = dpfGetService(dpfservice::AiService); |
| 70 | aiService->generateRag = std::bind(&ChatManager::generateRag, ChatManager::instance(), _1); |
| 71 | aiService->query = std::bind(&ChatManager::query, ChatManager::instance(), _1, _2, _3); |
| 72 | aiService->chatWithAi = std::bind(&ChatManager::requestAsync, ChatManager::instance(), _1); |
| 73 | |
| 74 | auto editSrv = dpfGetService(EditorService); |
| 75 | editSrv->registerDiagnosticRepairTool("AI", std::bind(&ChatManager::repairDiagnostic, ChatManager::instance(), _1)); |
| 76 | |
| 77 | return true; |
| 78 | } |
| 79 | |
| 80 | dpf::Plugin::ShutdownFlag ChatPlugin::stop() |
| 81 | { |
no test coverage detected