MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / initLLM

Method initLLM

src/plugins/console/generateinput.cpp:63–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63void 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
102void GenerateInput::initConnect()
103{

Callers

nothing calls this directly

Calls 8

connectFunction · 0.85
switchStateFunction · 0.85
getLLMMethod · 0.80
setStreamMethod · 0.45
checkValidMethod · 0.45
nextMethod · 0.45
isEmptyMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected