[ISSUE #14848] Add download Prompt version as Markdown feature#15057
Conversation
|
| Commit | Author | |
|---|---|---|
541f7e8 |
Linyu | gengruilin.grl@alibaba-inc.com |
How to fix:
- Add your commit email to your GitHub account: https://github.com/settings/emails
- Or update your local git config to use an email already linked to GitHub:
git config user.name "Your GitHub Username" git config user.email "your-github-email@example.com" - Amend your commits and force-push:
git rebase -i HEAD~1 # mark commits as "edit" and amend author git push --force-with-lease
This check will re-run automatically after you push.
|
Thanks for your this PR. 🙏 感谢您提交的PR。 🙏 |
541f7e8 to
523a028
Compare
|
@Sunrisea Please help to review |
|
LGTM |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
523a028 to
e9b4bbc
Compare
|
Thanks for the contribution. The main feature direction looks aligned with #14848, and the Markdown builder already has focused unit coverage. Before moving this forward, could you add coverage for the new download-count path as well? In particular, One more thing to confirm: Also, the linked issue discussion mentioned 感谢贡献。这个功能方向和 #14848 是对齐的,Markdown builder 也已经有比较聚焦的单测覆盖。 继续推进前,建议再补一下新增下载量统计链路的测试。尤其是 另外有一点需要确认: 还有一个小点:关联 issue 里讨论的文件名是 |
@grllll 请帮忙确认一下上述review的问题。 |
3a6f883 to
f24d993
Compare
Thanks @shiyiyue1102 @KomachiSion! Updated accordingly:
|
- Add PromptMarkdownBuilder to convert prompt version content to Markdown format - Add download API endpoint (GET /v3/console/ai/prompt/version/markdown) in ConsolePromptController - Add PromptDownloadEvent and PromptDownloadCountManager for download counting - Add downloadCount field to PromptMetaSummary and PromptVersionSummary - Frontend: add download button in CliCommandCard and download count display in Basic Info Card - Add unit tests for PromptMarkdownBuilder, PromptDownloadEvent, PromptDownloadCountManager, ConsolePromptController and PromptOperationServiceImpl#downloadPromptVersion Assisted-by: Qoder
f24d993 to
f1362c4
Compare
What is the purpose of the change
Fix #14848
Currently the Nacos console only supports viewing the content of a Prompt version inline, but there is no way for users to export or persist a Prompt version locally. This PR adds a feature that allows users to download any version of a Prompt as a Markdown file from the console, and tracks the download counts of each prompt / prompt version so that users can observe the popularity of prompts. The implementation is fully aligned with the existing Skill download feature for consistency.
Brief changelog
Backend
PromptMarkdownBuilderutility to render aPromptVersionInfo(including metadata, variables, template, and examples) into a well-formatted Markdown document.GET /v3/console/ai/prompt/version/markdowninConsolePromptController, returning the markdown content withContent-Disposition: attachmentso that browsers trigger a file download.PromptHandler/PromptInnerHandler/PromptRemoteHandler/PromptNoopHandler/PromptProxy.downloadPromptVersioninPromptOperationService/PromptOperationServiceImpl, which fetches the version detail and publishes aPromptDownloadEvent.PromptDownloadEvent(new event) andPromptDownloadCountManager(newSmartSubscriber) to accumulate download counts in memory and flush them to DB every 10 seconds using atomic SQL (download_count = download_count + N), keeping the counting logic isolated from the existingSkillDownloadCountManager.downloadCountfield toPromptMetaSummaryandPromptVersionSummary, and populate it inlistPrompts/listPromptVersions/getPromptDetail.Frontend (console-ui-next)
downloadPromptVersionMarkdownAPI call insrc/api/prompt.ts.CliCommandCardcomponent on the right sidebar (aligned with Skill detail page).InfoCellentries inside the Basic Info card.types/prompt.ts(downloadCount: number | null).prompt.downloadCount,prompt.downloads,prompt.versionDownloadsin bothen-US.jsonandzh-CN.json.Verifying this change
Unit tests
PromptMarkdownBuilderTestcovering header/metadata rendering, variables section, template section, examples section, and null/empty edge cases.Manual tests (with MySQL datasource, standalone mode)
.mdfile named{promptKey}-{version}.mdis downloaded.Checks
mvn -B clean package apache-rat:check spotbugs:check -DskipTests— passedmvn clean install -DskipITs— passed