| 627 | } |
| 628 | |
| 629 | QString InlineChatWidgetPrivate::createPrompt(const QString &question, bool useChunk) |
| 630 | { |
| 631 | QString prompt = systemenPrompt; |
| 632 | |
| 633 | QStringList context = {""}; |
| 634 | auto code = createFormatCode(chatInfo.fileName, chatInfo.originalText, chatInfo.originalRange); |
| 635 | auto fileText = editSrv->fileText(chatInfo.fileName); |
| 636 | if (useChunk) { |
| 637 | QString workspace = chatInfo.fileName; |
| 638 | ProjectService *prjSrv = dpfGetService(ProjectService); |
| 639 | const auto &allPrjInfo = prjSrv->getAllProjectInfo(); |
| 640 | for (const auto &info : allPrjInfo) { |
| 641 | if (chatInfo.fileName.startsWith(info.workspaceFolder())) { |
| 642 | workspace = info.workspaceFolder(); |
| 643 | break; |
| 644 | } |
| 645 | } |
| 646 | |
| 647 | auto result = ChatManager::instance()->query(workspace, code, 5); |
| 648 | QJsonArray chunks = result["Chunks"].toArray(); |
| 649 | context << "<context>"; |
| 650 | for (auto chunk : chunks) { |
| 651 | context << chunk.toObject()["fileName"].toString(); |
| 652 | context << chunk.toObject()["content"].toString(); |
| 653 | } |
| 654 | context << "</context>"; |
| 655 | } |
| 656 | QString command = state == QuestionStart ? "Chat" : "Programing"; |
| 657 | |
| 658 | return prompt.arg(question, code, context.join('\n'), command); |
| 659 | } |
| 660 | |
| 661 | Edit::Range InlineChatWidgetPrivate::calculateTextRange(const QString &fileName, const Edit::Position &pos) |
| 662 | { |
nothing calls this directly
no test coverage detected