| 148 | } |
| 149 | |
| 150 | QString ChatManager::getChunks(const QString &queryText) |
| 151 | { |
| 152 | using dpfservice::ProjectService; |
| 153 | ProjectService *prjService = dpfGetService(ProjectService); |
| 154 | auto currentProjectPath = prjService->getActiveProjectInfo().workspaceFolder(); |
| 155 | |
| 156 | if (currentProjectPath != "") { |
| 157 | QJsonObject result = ChatManager::instance()->query(currentProjectPath, queryText, 20); |
| 158 | QJsonArray chunks = result["Chunks"].toArray(); |
| 159 | if (!chunks.isEmpty()) { |
| 160 | if (result["Completed"].toBool() == false) |
| 161 | emit notify(0, tr("The indexing of project %1 has not been completed, which may cause the results to be inaccurate.").arg(currentProjectPath)); |
| 162 | QString context; |
| 163 | context += "\n<context>\n"; |
| 164 | for (auto chunk : chunks) { |
| 165 | context += chunk.toObject()["fileName"].toString(); |
| 166 | context += '\n```'; |
| 167 | context += chunk.toObject()["content"].toString(); |
| 168 | context += "```\n\n"; |
| 169 | } |
| 170 | context += "\n</context>"; |
| 171 | return context; |
| 172 | } else if (ChatManager::instance()->condaHasInstalled()) { |
| 173 | emit noChunksFounded(); |
| 174 | return ""; |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | return ""; |
| 179 | } |
| 180 | |
| 181 | void ChatManager::repairDiagnostic(const QString &info) |
| 182 | { |
nothing calls this directly
no test coverage detected