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

Method createPrompt

src/plugins/chat/widgets/inlinechatwidget.cpp:629–659  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

627}
628
629QString 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
661Edit::Range InlineChatWidgetPrivate::calculateTextRange(const QString &fileName, const Edit::Position &pos)
662{

Callers

nothing calls this directly

Calls 6

getAllProjectInfoMethod · 0.80
startsWithMethod · 0.80
toArrayMethod · 0.80
fileTextMethod · 0.45
queryMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected