backend
backend copied to clipboard
AI-powered marking
Description
Created a new feature to automate feedback generation of code submissions in Source Academy, with the help of LLMs. This will help save TAs some time in grading code submissions from students!
- Added AI comment generation functionality in the backend.
- Integrated OpenAI API for generating AI comments.
- Implemented
generate_ai_commentsendpoint to fetch question details and generate AI-generated comments for submissions. - Added
save_chosen_commentsendpoint to save multiple chosen comments for a submission and question for logging purposes. - Added
save_final_commentendpoint to save the final comment chosen for a submission for logging purposes. - Added new
ai_comment_logstable to log various data points from inputs, original student's code, outputs generated by LLM, comments chosen, and final comment. - Added
AICommentsmodule to handle creation, retrieval, and updates for AI comments, including saving final and chosen comments. - Added
AICodeAnalysisControllerto handle AI comment generation, saving final comments, and saving chosen comments. - Added test cases for
generate_ai_comments,save_final_comment, andsave_chosen_commentsendpoints inAICodeAnalysisControllerTest. - Updated Swagger documentation for the new endpoints.
- Added necessary migrations to update the database schema.
- Added encryption and decryption logic for LLM API keys using AES-GCM.
Note: This may require changes to the DB diagram in README.md.
Type of Change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [x] This change requires a documentation update
- [ ] Code quality improvements
Checklist
- [x] I have tested this code
- [ ] I have updated the documentation
coverage: 88.716% (-0.9%) from 89.621% when pulling d0a08df181cfe2ee294f3f618b8aceeddda8e581 on feat/add-AI-generated-comments-grading into 8736877eace8420f18a184c33a66e1c785dbcd1d on master.
@sentry review
@sentry review
@sentry generate-test
Sentry has determined that unit tests are not necessary for this PR.