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

Method checkValid

src/plugins/aimanager/codegeex/codegeexllm.cpp:372–407  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370}
371
372bool CodeGeeXLLM::checkValid(QString *errStr)
373{
374 d->loadConfig();
375 QString url = kUrlQueryUserInfo;
376 QNetworkReply *reply = d->getMessage(url, d->apiKey);
377 QEventLoop loop;
378 bool valid = false;
379 connect(reply, &QNetworkReply::finished, this, [=, &loop, &valid]() {
380 if (reply->error()) {
381 qCritical() << "Error:" << reply->errorString();
382 loop.exit();
383 return;
384 }
385 QString response = QString::fromUtf8(reply->readAll());
386 QJsonDocument document = QJsonDocument::fromJson(response.toUtf8());
387 QJsonObject jsonObject = document.object();
388 int code = jsonObject["code"].toInt();
389 if (code == kCode_Success) {
390 valid = true;
391 } else {
392 valid = false;
393 *errStr = "Please Login CodeGeeX first";
394
395 QStringList actions { "codegeex_login_default", tr("Login") };
396 auto windowService = dpfGetService(WindowService);
397 windowService->notifyWithCallback(0, "CodeGeeX", tr("Please login to use CodeGeeX."), actions, [=](const QString &actId) {
398 if (actId == "codegeex_login_default")
399 d->login();
400 });
401 }
402 loop.exit();
403 });
404 loop.exec();
405
406 return valid;
407}
408
409QJsonObject CodeGeeXLLM::create(const Conversation &conversation)
410{

Callers 4

checkModelValidMethod · 0.45
initLLMMethod · 0.45
initLLMMethod · 0.45
checkModelValidMethod · 0.45

Calls 10

connectFunction · 0.85
errorMethod · 0.80
readAllMethod · 0.80
loadConfigMethod · 0.45
getMessageMethod · 0.45
errorStringMethod · 0.45
exitMethod · 0.45
objectMethod · 0.45
loginMethod · 0.45
execMethod · 0.45

Tested by

no test coverage detected