Plugin for a learning assistant backend, intended for use within edx-platform
Project description
learning-assistant
Purpose
Plugin for a learning assistant backend, intended for use within edx-platform.
This library contains data models and logic for a platform wide learning assistant.
Dependencies
In addition to the edx-platform repository in which this library is installed, this plugin also leverages the frontend-lib-learning-assistant as a frontend interface for the learning assistant.
Getting Started
Developing
One Time Setup
# Clone the repository (in the ../src relative to devstack repo)
git clone git@github.com:openedx/learning-assistant.git
cd learning-assistant
# Set up a virtualenv with the same name as the repo and activate it
# Here's how you might do that if you have virtualenvwrapper setup.
mkvirtualenv -p python3.8 learning-assistant
In your requirements/edx/private.txt requirements file in edx-platform, add:
-e /edx/src/learning-assistant
In your lms/envs/private.py settings file in edx-platform (create file if necessary), add the below settings. The value of the API key shouldn’t matter, because it’s not being used at this point, but the setting needs to be there.
CHAT_COMPLETION_API = '' # copy url from edx-internal
CHAT_COMPLETION_API_KEY = '' # add value though value itself does not matter
LEARNING_ASSISTANT_PROMPT_TEMPLATE = '' # copy value from edx-internal
LEARNING_ASSISTANT_AVAILABLE = True
In devstack, run make lms-shell and run the following command: make requirements;exit. This will install anything included in your private.txt requirements file.
In django admin, add the following waffle flag learning_assistant.enable_course_content and make sure it is turned on for Everyone. The flag should be checked on for: Superusers, Staff, and Authenticated.
This plugin depends on the lms and discovery - both should be running.
Enabling Xpert for audit learners
In addition to the “One Time Setup” instructions, the following instructions should be followed to enable Xpert for audit learners locally. In your env.development config file in frontend-app-learning, add the below setting.
ENABLE_XPERT_AUDIT='true'
Ensure that you have a non-expired verified mode set up locally for your testing course. You can do this by checking if http://localhost:18000/admin/course_modes/coursemode/ has a course mode with a future expiration date.
The Xpert for audit learner frontend code depends on the lms, discovery, and ecommerce services. Ensure that all three services are running without errors.
Every time you develop something in this repo
# Activate the virtualenv
# Here's how you might do that if you're using virtualenvwrapper.
workon learning-assistant
# 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.
License
The code in this repository is licensed under the AGPL 3.0 unless otherwise noted.
Please see LICENSE.txt for details.
Contributing
This repo is not currently accepting contributions.
The Open edX Code of Conduct
All community members are expected to follow the Open edX Code of Conduct.
Reporting Security Issues
Please do not report security issues in public. Please email security@edx.org.
Change Log
Unreleased
4.11.3 - 2025-10-08
Handle large system messages in Xpert Assistant.
4.11.1 - 2025-08-22
Fixes a linting error on the changelog that prevented the previous release.
4.11.0 - 2025-08-08
Replaced the get_audit_trial_length_days utils.py function with the AUDIT_TRIAL_MAX_DAYS = 14, as the audit trial length will be 14 days going forwards.
4.10.8 - 2025-07-31
Chat history to support XPert Chat API V2 response with a list of messages.
4.10.7 - 2025-07-15
XPert Chat API response will be message object for V1 endpoint and a list of messages for V2 endpoint.
Adds a Django setting to control the chat v2 endpoint availability in production
4.10.6 - 2025-07-01
XPert chat API responses are uniformly returned as a list, which improves compatibility between the v1 and v2 endpoints.
4.10.5 - 2025-03-06
Fixes a bug where audit trial length was defaulting to 14 days due to missing language preference for Optimizely
4.10.4 - 2025-03-05
Adds logic to trim down unit content to a maximum length of characters, specified with a Django setting to fix edge cases where the unit content is so large it leaves no room for any chat history. This typically occurs with units that contain videos with very long transcripts.
Adds user to raw_id_fields for LearningAssistantMessageAdmin form to improve performance.
4.10.3 - 2025-03-04
Adds Django admin form for LearningAssistantMessage model.
Improves Django admin form for LearningAssistantCourseEnabled model by improving display.
4.10.2 - 2025-02-19
Fixes an error when parsing dates for the chat views.
Small update in the documentation regarding Paver deprecation.
4.10.1 - 2025-02-19
Fixes a linting error on the changelog that prevented the previous release.
4.10.0 - 2025-02-19
Upgraded Python requirements.
Updated Chat Trial Audit gating consistency.
4.9.0 - 2025-02-12
Add an expiration_date field on the LearningAssistantAuditTrial model to store expiration date of a trial.
4.8.0 - 2025-02-05
If optimizely is available, use optimizely to determine length of trial period
4.7.1 - 2025-01-09
Use Django utils timezone instead of datetime to get now to prevent naive/aware comparisons.
4.7.0 - 2025-01-07
Gate use of the Xpert platform v2 endpoint with a waffle flag.
4.6.3 - 2025-01-06
Uses CourseEnrollment instead of CourseMode to get the upgrade deadline required to calculate if a learner’s audit trial is expired.
Updated setup docs
4.6.2 - 2024-12-18
Fixed the params for expiration_date in the admin table for audit trial.
Add ENABLE_XPERT_AUDIT instructions.
4.6.1 - 2024-12-17
Added an admin table for the LearningAssistantAuditTrial model. This table includes an expiration_date valued that is calculated based on the start_date.
4.6.0 - 2024-12-10
Add an audit_trial_length_days attribute to the response returned by the ChatSummaryView, representing the number of days in an audit trial as currently configured. It does not necessarily represent the number of days in the learner’s current trial.
4.5.0 - 2024-12-04
Add local setup to readme
Add a BFFE chat summary endpoint for Learning Assistant, including information about whether the Learning Assistant is enabled, Learning Assistant message history, and Learning Assistant audit trial data.
4.4.7 - 2024-11-25
Fixes the Course Chat View CourseMode concatenation issue
4.4.6 - 2024-11-22
Gates the chat history endpoint behind a waffle flag
Add LearningAssistantAuditTrial model
4.4.5 - 2024-11-12
Updated Learning Assistant History payload to return in ascending order
4.4.4 - 2024-11-06
Fixed Learning Assistant History endpoint
Added timestamp to the Learning Assistant History payload
4.4.3 - 2024-11-06
Fixed package version
4.4.2 - 2024-11-04
Added chat messages to the DB
4.4.1 - 2024-10-31
Add management command to remove expired messages
4.4.0 - 2024-10-30
Add LearningAssistantMessage model
Add new GET endpoint to retrieve a user’s message history in a given course.
4.4.0 - 2024-10-25
Upgraded to use Python 3.12
4.3.3 - 2024-10-15
Use LEARNING_ASSISTANT_PROMPT_TEMPLATE for prompt
4.3.2 - 2024-09-19
Add error handling for invalid unit usage keys
4.3.1 - 2024-09-10
Remove GPT model field as part of POST request to Xpert backend
4.3.0 - 2024-07-01
Adds optional parameter to use updated prompt and model for the chat response.
4.2.0 - 2024-02-28
Modify call to Xpert backend to prevent use of course index.
4.1.0 - 2024-02-26
Use course cache to inject course title and course skill names into prompt template.
4.0.0 - 2024-02-21
Remove use of course waffle flag. Use the django setting LEARNING_ASSISTANT_AVAILABLE to enable the learning assistant feature.
3.6.0 - 2024-02-13
Enable backend access by course waffle flag or django setting.
3.4.0 - 2024-01-30
Add new GET endpoint to retrieve whether Learning Assistant is enabled in a given course.
3.3.0 - 2024-01-30
Fix release version
3.2.0 - 2024-01-30
Remove audit access to chat view.
3.0.1 - 2024-01-29
Modify gating of learning assistant based on waffle flag and enabled value.
3.0.0 - 2024-01-23
Remove and drop the course prompt model.
2.0.3 - 2024-01-22
Remove references to the course prompt model.
2.0.1 - 2024-01-08
Gate content integration with waffle flag
2.0.0 - 2024-01-03
Add content cache
Integrate system prompt setting
1.5.0 - 2023-10-18
Add management command to generate course prompts
1.4.0 - 2023-09-11
Send reduced message list if needed to avoid going over token limit
1.3.3 - 2023-09-07
Allow any enrolled learner to access API.
1.3.2 - 2023-08-25
Remove deserialization of prompt field, as it is represented in the python native format
1.3.1 - 2023-08-24
Remove prompt field
1.3.0 - 2023-08-24
Remove references to prompt field
Create json_prompt field to allow for more flexible prompts
1.2.1 - 2023-08-24
make prompt field nullable
1.2.0 - 2023-08-22
add endpoint authentication
fix request structure required for endpoint integration
1.1.0 - 2023-08-09
fix for course id to course key conversion
1.0.0 - 2023-08-08
Add endpoint to retrieve chat response
Created model to associate course ideas with a specific prompt text
Unreleased
0.1.0 – 2023-07-26
Added
First release on PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file learning_assistant-4.11.3.tar.gz.
File metadata
- Download URL: learning_assistant-4.11.3.tar.gz
- Upload date:
- Size: 58.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f30d80fc00705ad94a932d8f5c2064ae3f6b1225dd0cd6a2d871b6f6821b130
|
|
| MD5 |
b3e9ebfd4b48ef625a406979bf60f823
|
|
| BLAKE2b-256 |
6befe7ab27b22b3142be90de25dc46a5eccca71e019147f31c7df01b728dac9a
|
File details
Details for the file learning_assistant-4.11.3-py2.py3-none-any.whl.
File metadata
- Download URL: learning_assistant-4.11.3-py2.py3-none-any.whl
- Upload date:
- Size: 46.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ee8c8ed0f86d1b8507468496f7e8c694d5794d09fa710334e0d8d827eccab3c
|
|
| MD5 |
6657acf6d5d237722a75cb330b1cef7a
|
|
| BLAKE2b-256 |
839b5d5df42b6b0234e53ecac7e653192ea6cdacfc5cb9dfebbf4770cb483575
|