Package: ai-aside
ai-asidePurposeThis plugin holds LLM related blocks and tools, initially the summary XBlock aside but eventually more options.Getting StartedDevelopingOne Time Setup# Clone the repository
git clone git@github.com:openedx/ai-aside.git
cd ai-aside

# Set up a virtualenv using virtualenvwrapper with the same name as the repo and activate it
mkvirtualenv -p python3.8 ai-asideLocal testingTo test your changes locally, you will need to install the package from your local branch into edx-platform. For example, if using devstack, copy or clone your branch into <devstack-parent>/src/ai-aside. Bring up the LMS and CMS containers in devstack, and run this make target in the ai-aside directory:make install-localYou should see it uninstall any existing ai-aside in and install your local source, for both the CMS and LMS.The plug-in configuration will automatically be picked up once installed. Changes will be hot reloaded after the next LMS or CMS restart.If you would like to manually install ai-aside, go to your lms or cms shell and run:pip install -e /edx/src/ai-asideRun MigrationsYou will also need to run migrations for local testing. Using the same lms or cms shell as before, run:./manage.py lms migrate ai_asideTesting in Docker with AI-spotIf you are running both devstack and a local instance of the supporting ai-spot in docker, you need two pieces of special setup to let ai-spot call the aside handler and retrieve content.The first is to connect ai-spot to the devstack network with a docker command:docker network connect devstack_default ai-spot-server-1The second is to change the handler URLs generated by ai-aside to a URL that is accessible by ai-spot in the same docker. This is already set up for you insummaryhook_aside/settings/devstack.py. If your AI service is running locally outside of docker, you will need to change that setting.Enabling the AsideFor the summary aside to work, you will have to make two changes in the LMS admin:You must create anXBlockAsidesConfig(admin URL:/admin/lms_xblock/xblockasidesconfig/). This model has a list of blocks you do not want asides to apply to that can be left alone, and an enabled setting that unsurprisingly should be True.You must enable a course waffle flag for each course you want to summarize.summaryhook.summaryhook_enabledis the main one,summaryhook_enabled.summaryhook_staff_onlycan be used if you only want staff to see it.You must enable a course waffle flag if you want to use the feature for enabling/disabling the summary by its settings.summaryhook.summaryhook_summaries_configuration. If this flag is enabled, you can enable/disable the courses and the blocks by its settings.Aside Settings APIThere are some endpoints that can be used to pinpoint units to be either enabled or disabled based on their configs. The new settings work as follows:
- If a course is enabled, the summary for all the blocks for that course are enabled by default.
- If a course is disabled or the setting does not exists, then the summary for all the blocks from that course are disabled by default.
- If a block has its own settings, it will override any other setting with the one that is saved.
- If a block does not have any settings saved, then the enabled state will fall back to the course’s enabled state mentioned above.The new endpoints for updating these settings are:Fetch settingsMethodPathResponsesGETai_aside/v1/:course_idCode 200:{ "success": true }Code 400:{ "success": false, "message": "(description)" }Code 404:{ "success": false }GETai_aside/v1/:course_id/:unit_idUpdate settingsMethodPathPayloadResponsesPOSTai_aside/v1/:course_id{ "enabled": true|false }Code 200:{ "success": true }Code 400:{ "success": false, "message": "(description)" }POSTai_aside/v1/:course_id/:unit_id{ "enabled": true|false }Delete settingsMethodPathResponsesDELETEai_aside/v1/:course_idCode 200:{ "success": true }Code 400:{ "success": false, "message": "(description)" }Code 404:{ "success": false }DELETEai_aside/v1/:course_id/:unit_idEvery time you develop something in this repo# Activate the virtualenv
workon ai-aside

# Grab the latest code
git checkout main
git pull

# Install/update the dev requirements
make requirements

# Run the tests and quality checks (to verify the status before you make any changes)
make validate

# Make a new branch for your changes
git checkout -b <your_github_username>/<short_description>

# Using your favorite editor, edit the code to make your change.
vim ...

# Run your new tests
pytest ./path/to/new/tests

# Run all the tests and quality checks
make validate

# Commit all your changes
git commit ...
git push

# Open a PR and ask for review.DeployingThis plugin is deployed on edx.org via EDXAPP_EXTRA_REQUIREMENTS.LicenseThe code in this repository is licensed under the AGPL 3.0 unless
otherwise noted.Please seeLICENSE.txtfor details.ContributingContributions are very welcome.
Please readHow To Contributefor details.This project is currently accepting all types of contributions, bug fixes,
security fixes, maintenance work, or new features.  However, please make sure
to have a discussion about your new feature idea with the maintainers prior to
beginning development to maximize the chances of your change being accepted.
You can start a conversation by creating a new issue on this repo summarizing
your idea.The Open edX Code of ConductAll community members are expected to follow theOpen edX Code of Conduct.PeopleThe assigned maintainers for this component and other project details may be
found inBackstage. Backstage pulls this data from thecatalog-info.yamlfile in this repo.Reporting Security IssuesPlease do not report security issues in public. Please emailsecurity@tcril.org.Change LogUnreleased3.6.2 — 2023-10-12Handle rare blocks missing dates when calculating last updatedRemove log of expected “not here” exception during config3.6.1 — 2023-10-10Resolve scenario where a user has no associated enrollment value3.6.0 – 2023-10-05Include user role in summary hook HTML.Add make install-local target for easy devstack installation.3.5.0 – 2023-09-04Add edx-drf-extensions lib.Add JwtAuthentication checks before each request.Add SessionAuthentication checks before each request.Add HasStudioWriteAccess permissions checks before each request.3.4.0 – 2023-08-30Include last updated timestamp in summary hook HTML, derived from the blocks.Also somewhat reformats timestamps in the handler return to conform to ISO standard.3.3.1 – 2023-08-21Remove no longer needed first waffle flag summaryhook_enabled3.3.0 – 2023-08-16FeaturesAdd xpert summaries configuration by default for units3.2.0 – 2023-07-26FeaturesAdded the checks for the module settings behind the waffle flagsummaryhook.summaryhook_summaries_configuration.Added is this course configurable endpointError suppression logs now include block IDMissing video transcript is caught earlier in content fetch3.1.0 – 2023-07-20FeaturesAdded API endpoints for updating settings for courses and modules (enable/disable for now) (Has migrations)3.0.1 – 2023-07-20Add positive log when summary fragement decides to inject3.0.0 – 2023-07-16FeaturesSummary content handler now requires a staff user identity, otherwise returns 403. This is a breaking change.Added models to summaryhook_aside (Has migrations)Catch exceptions in a couple of locations so the aside cannot crash content.2.0.2 – 2023-07-05FixUpdated HTML parser to remove tags with their content for specific cases like<script>or<style>.2.0.1 – 2023-06-29FixFix transcript format request and conversion2.0.0 – 2023-06-28AddedAdds a handler endpoint to provide summarizable contentImproves content length checking using that summarizable content1.2.1 – 2023-05-19FixesFix summary-aside settings package1.2.0 – 2023-05-11AddedPorting over summary-aside from edx-arch-experiments version 1.2.0