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

Method createNewSession

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

Source from the content-addressed store, hash-verified

154}
155
156void CodeGeeXLLMPrivate::createNewSession()
157{
158 loadConfig(); // incase sessionId has updated
159 QString url = kUrlCreateNewSession;
160 QString currentMSecsStr = QString::number(QDateTime::currentMSecsSinceEpoch());
161 QString sessionTitle("Session_" + currentMSecsStr);
162 QString taskId(uuid());
163
164 QJsonObject jsonObject;
165 jsonObject.insert("prompt", sessionTitle);
166 jsonObject.insert("talkId", taskId);
167
168 QNetworkReply *reply = postMessage(url, apiKey, QJsonDocument(jsonObject).toJson());
169 QEventLoop loop;
170 CodeGeeXLLM::connect(reply, &QNetworkReply::finished, q, [=, &loop]() {
171 if (reply->error()) {
172 qCritical() << "CodeGeeX Session created faield \nError:" << reply->errorString();
173 loop.exit();
174 return;
175 }
176
177 QString response = QString::fromUtf8(reply->readAll());
178 QJsonDocument document = QJsonDocument::fromJson(response.toUtf8());
179 QJsonObject jsonObject = document.object();
180 int code = jsonObject["code"].toInt();
181 if (code == kCode_Success)
182 talkId = taskId;
183 loop.exit();
184 });
185 loop.exec();
186}
187
188void CodeGeeXLLMPrivate::handleReplyFinished(QNetworkReply *reply)
189{

Callers 2

createMethod · 0.80
requestMethod · 0.80

Calls 12

numberClass · 0.85
uuidFunction · 0.85
connectFunction · 0.85
insertMethod · 0.80
errorMethod · 0.80
readAllMethod · 0.80
QJsonDocumentClass · 0.50
toJsonMethod · 0.45
errorStringMethod · 0.45
exitMethod · 0.45
objectMethod · 0.45
execMethod · 0.45

Tested by

no test coverage detected