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

Method initLLM

src/plugins/chat/chatmanager.cpp:421–460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

419}
420
421void ChatManager::initLLM(AbstractLLM *llm)
422{
423 if (!llm)
424 return;
425 chatLLM->setLocale(locale == Chat::Zh ? AbstractLLM::Zh : AbstractLLM::En);
426 connect(chatLLM, &AbstractLLM::dataReceived, this, [=](const QString &data, AbstractLLM::ResponseState state) {
427 if (state == AbstractLLM::Canceled)
428 return;
429 if (state == AbstractLLM::Failed) {
430 QString errStr;
431 bool valid = chatLLM->checkValid(&errStr);
432 if (!valid)
433 emit notify(2, tr("LLM is not valid. %1").arg(errStr));
434 else
435 emit notify(2, tr("Error: %1, try again later").arg(data));
436 emit terminated();
437 return;
438 }
439 onResponse(QString::number(answerFlag), data, state);
440 });
441 connect(chatLLM, &AbstractLLM::customDataReceived, this, [=](const QString &key, const QJsonObject &obj) {
442 QList<websiteReference> websites;
443 if (key == "crawl") {
444 for (auto it = obj.begin(); it != obj.end(); ++it) {
445 websiteReference website;
446 QString citationKey = it.key();
447 QJsonObject citationObj = it.value().toObject();
448
449 website.citation = citationKey;
450 website.status = citationObj["status"].toString();
451 website.url = citationObj["url"].toString();
452 website.title = citationObj["title"].toString();
453
454 websites.append(website);
455 }
456 emit crawledWebsite(QString::number(answerFlag), websites);
457 }
458 });
459 connect(this, &ChatManager::requestStop, chatLLM, &AbstractLLM::cancel);
460}
461
462// todo: storage of session records
463void ChatManager::fetchSessionRecords()

Callers

nothing calls this directly

Calls 11

connectFunction · 0.85
notifyFunction · 0.85
numberClass · 0.85
setLocaleMethod · 0.45
checkValidMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
keyMethod · 0.45
valueMethod · 0.45
toStringMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected