| 61 | } |
| 62 | |
| 63 | void GenerateInput::initLLM() |
| 64 | { |
| 65 | using namespace dpfservice; |
| 66 | auto aiSrv = dpfGetService(AiService); |
| 67 | LLMInfo liteModel; |
| 68 | auto liteLLMInfo = aiSrv->getCodeGeeXLLMPro(); |
| 69 | d->llm = aiSrv->getLLM(liteLLMInfo); |
| 70 | d->llm->setStream(false); |
| 71 | connect(d->llm, &AbstractLLM::dataReceived, this, [=](const QString &data, AbstractLLM::ResponseState state){ |
| 72 | if (state == AbstractLLM::Failed) { |
| 73 | QString err = ""; |
| 74 | auto valid = d->llm->checkValid(&err); |
| 75 | if (!valid){ |
| 76 | switchState(false); |
| 77 | emit commandGenerated(err); |
| 78 | } else { |
| 79 | emit commandGenerated(tr("Please try again later")); |
| 80 | } |
| 81 | } |
| 82 | auto response = data; |
| 83 | QString results; |
| 84 | QRegularExpression regex(R"(```.*\n((.*\n)*?.*)\n\s*```)"); |
| 85 | |
| 86 | QRegularExpressionMatchIterator matchIterator = regex.globalMatch(response); |
| 87 | while (matchIterator.hasNext()) { |
| 88 | QRegularExpressionMatch match = matchIterator.next(); |
| 89 | QString codePart = match.captured(1).trimmed(); |
| 90 | if (!codePart.isEmpty()) { |
| 91 | if (!results.isEmpty()) |
| 92 | results.append(';'); |
| 93 | results.append(codePart); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | switchState(false); |
| 98 | emit commandGenerated(results); |
| 99 | }); |
| 100 | } |
| 101 | |
| 102 | void GenerateInput::initConnect() |
| 103 | { |
nothing calls this directly
no test coverage detected