feat(ai): Add Markdown and JSON export buttons to AI Summary and Chat tabs
Closes #13868
Implemented the export functionality for AI Summary and AI Chat as requested. Users can now save the content to Markdown (human-readable) or JSON (machine-readable, OpenAI format). Added an export menu button to the UI and handled the file saving logic.
Steps to test
-
Open an entry that has a citation key and a linked PDF. I tested the UI logic in a simulated local environment (since I don't have an AI API key)
-
Go to the AI Summary or AI Chat tab.
-
Even without an API key (interface might show an error), you should see the new Export button (floppy disk icon) in the toolbar. In the AI Summary tab, the Export button is only visible after a summary has been successfully generated.
- Click the button and select Export to Markdown or Export to JSON.
- Save the file and verify the content:
- Markdown: Should contain the BibTeX source and the text.
- JSON: Should contain metadata and a
conversationlist compatible with OpenAI format. - I confirmed that clicking the Export button correctly triggers the 'Save As' file dialog and generates the file with the expected structure.
Mandatory checks
- [x] I own the copyright of the code submitted and I license it under the MIT license
- [x] I manually tested my changes in running JabRef (always required)
- [ ] I added JUnit tests for changes (if applicable)
- [x] I added screenshots in the PR description (if change is visible to the user)
- [x] I described the change in
CHANGELOG.mdin a way that is understandable for the average user (if change is visible to the user) - [ ] I checked the user documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request updating file(s) in https://github.com/JabRef/user-documentation/tree/main/en.
@CXZHANG0508 Please do not close PRs and open new ones. Just push changes to your branch.
Understood, thanks!
Hi, thanks for your contribution.
Please use a proper PR title. "Feat ai export" is not enough to quickly understand from the table what this PR is about. Remember that in open source you occansionally happen to work with other people together and as long as we dont have the technology for mind sharing and telepathy, we need to keep communicating in a mutual understandable way.
Thank you for your feedback! I apologize for the previous simple title. I have updated the PR title to be more descriptive.I hope that is clearer.
See https://github.com/JabRef/jabref/issues/13868#issuecomment-3604371479 why there are two PRs.
Apologies for the oversight, it was a careless mistake on my part.Now I had fixed it.
Moreover, consistency please!!
Export always right - as in AI summary
JUnit tests of jablib are failing. You can see which checks are failing by locating the box "Some checks were not successful" on the pull request page. To see the test output, locate "Source Code Tests / Unit tests (pull_request)" and click on it.
You can then run these tests in IntelliJ to reproduce the failing tests locally. We offer a quick test running howto in the section Final build system checks in our setup guide.