data = { "context": [{ "kind": "active_document":{} }, { "kind": "document":{} }, ], "model":, "lang": } */
| 494 | } |
| 495 | */ |
| 496 | void CodeGeeXLLM::generate(const QString &prefix, const QString &suffix) |
| 497 | { |
| 498 | setModelState(Busy); |
| 499 | |
| 500 | auto file = getCurrentFileInfo(); |
| 501 | |
| 502 | QJsonObject activeDocument; |
| 503 | activeDocument.insert("path", file.first); |
| 504 | activeDocument.insert("prefix", prefix); |
| 505 | activeDocument.insert("suffix", suffix); |
| 506 | activeDocument.insert("lang", file.second); |
| 507 | |
| 508 | QJsonObject activeContextItem; |
| 509 | activeContextItem.insert("kind", "active_document"); |
| 510 | activeContextItem.insert("active_document", activeDocument); |
| 511 | |
| 512 | // ProjectService *prjSrv = dpfGetService(ProjectService); |
| 513 | QJsonArray context; |
| 514 | context.append(activeContextItem); |
| 515 | // QJsonObject queryResults = ChatManager::instance()->query(prjSrv->getActiveProjectInfo().workspaceFolder(), prefix, 5); |
| 516 | // QJsonArray chunks = queryResults["Chunks"].toArray(); |
| 517 | |
| 518 | // for (auto chunk : chunks) { |
| 519 | // QJsonObject document; |
| 520 | // document.insert("path", chunk.toObject()["fileName"].toString()); |
| 521 | // document.insert("text", chunk.toObject()["content"].toString()); |
| 522 | // document.insert("lang", file.second); |
| 523 | |
| 524 | // QJsonObject contextItem; |
| 525 | // contextItem.insert("kind", "document"); |
| 526 | // contextItem.insert("document", document); |
| 527 | // context.append(contextItem); |
| 528 | // } |
| 529 | |
| 530 | QJsonObject json; |
| 531 | json.insert("ide", qApp->applicationName()); |
| 532 | json.insert("ide_version", version()); |
| 533 | json.insert("context", context); |
| 534 | json.insert("model", modelName()); |
| 535 | json.insert("lang", file.second); |
| 536 | json.insert("max_new_tokens", d->maxTokens == 0 ? 126 : d->maxTokens); |
| 537 | |
| 538 | QNetworkReply *reply = d->postMessage(kUrlGenerateMultiLine, d->apiKey, QJsonDocument(json).toJson()); |
| 539 | connect(this, &CodeGeeXLLM::requstCancel, reply, &QNetworkReply::abort); |
| 540 | connect(reply, &QNetworkReply::finished, this, [=](){ |
| 541 | d->handleReplyFinished(reply); |
| 542 | }); |
| 543 | |
| 544 | d->processResponse(reply); |
| 545 | } |
| 546 | |
| 547 | void CodeGeeXLLM::setTemperature(double temperature) |
| 548 | { |
no test coverage detected