JsonObject: Query: str Chunks: Arr[fileName:str, content:str] Instructions: obj{name:str, description:str, content:str} */
| 636 | Instructions: obj{name:str, description:str, content:str} |
| 637 | */ |
| 638 | QJsonObject ChatManager::query(const QString &projectPath, const QString &query, int topItems) |
| 639 | { |
| 640 | QProcess process; |
| 641 | |
| 642 | QObject::connect(&process, &QProcess::readyReadStandardError, &process, [&]() { |
| 643 | qInfo() << "Error:" << process.readAllStandardError() << "\n"; |
| 644 | }); |
| 645 | |
| 646 | // If modified, update the Python file accordingly. |
| 647 | auto pythonPath = condaRootPath() + "/miniforge/envs/deepin_unioncode_env/bin/python"; |
| 648 | if (!QFileInfo(pythonPath).exists() || !QFileInfo(condaRootPath() + "/index.sqlite").exists()) |
| 649 | return {}; |
| 650 | |
| 651 | auto modelPath = CustomPaths::CustomPaths::global(CustomPaths::Models); |
| 652 | auto ragPath = CustomPaths::CustomPaths::global(CustomPaths::Scripts) + "/rag"; |
| 653 | process.setWorkingDirectory(ragPath); |
| 654 | auto queryPyPath = ragPath + "/query.py"; |
| 655 | process.start(pythonPath, QStringList() << queryPyPath << modelPath << projectPath << query << QString::number(topItems)); |
| 656 | process.waitForFinished(); |
| 657 | auto result = process.readAll(); |
| 658 | QJsonDocument document = QJsonDocument::fromJson(result); |
| 659 | |
| 660 | QJsonObject obj = document.object(); |
| 661 | if (indexingProject.contains(projectPath)) |
| 662 | obj["Completed"] = false; |
| 663 | else |
| 664 | obj["Completed"] = true; |
| 665 | |
| 666 | if (isReferenceCodebase()) |
| 667 | currentChunks = obj; |
| 668 | else |
| 669 | currentChunks = QJsonObject(); |
| 670 | |
| 671 | return obj; |
| 672 | } |
no test coverage detected