-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into jenkins/zshkoor/setup-py-updated-5811f7a
- Loading branch information
Showing
57 changed files
with
3,933 additions
and
675 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
[run] | ||
branch = True | ||
data_file = .coverage | ||
relative_files = True | ||
source=learning_assistant | ||
omit = | ||
test_settings | ||
*migrations* | ||
*admin.py | ||
*static* | ||
*templates* | ||
learning_assistant/plugins.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,14 +26,37 @@ One Time Setup | |
-------------- | ||
.. code-block:: | ||
# Clone the repository | ||
# Clone the repository (in the ../src relative to devstack repo) | ||
git clone [email protected]: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: | ||
|
||
.. code-block:: | ||
-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. | ||
|
||
.. code-block:: | ||
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: ``paver install_prereqs;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. | ||
|
||
Every time you develop something in this repo | ||
--------------------------------------------- | ||
.. code-block:: | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
2. System Prompt Design Changes | ||
############################### | ||
|
||
Status | ||
****** | ||
|
||
**Accepted** *2023-12-13* | ||
|
||
Context | ||
******* | ||
|
||
A system prompt in the Learning Assistant context refers to the text-based instructions provided to the large language | ||
model (LLM) that describe the objective and proper behavior of the Learning Assistant. This prompt is provided to the | ||
LLM via 2U's Xpert Platform generic chat completion endpoint as the first set of elements in the ``message_list`` | ||
payload key. | ||
|
||
Currently, the system prompt is stored in the `CoursePrompt model`_ on a per-course basis. For each course in which the | ||
Learning Assistant is enabled, a system prompt must be stored in the associated database table. | ||
|
||
The original intention behind storing the system prompt in this way was to enable an expedited release, a greater degree | ||
of per-course customization, and a flexibility to modify the system prompt quickly in the early stages of the project. | ||
|
||
The process of releasing the Learning Assistant to a new course involves either the manual creation of the model | ||
instance via the Django admin or the use of the `set_course_prompts management command`_. The latter requires that a | ||
member of 2U's Site Reliability Engineering (SRE) team runs this command in the proper environment. | ||
|
||
The next iteration of the Learning Assistant will enable the integration of unit content into the system prompt to | ||
provide the LLM with more information about the context in which the learner is asking a question. This will require a | ||
change to the system prompt to accommodate the unit content, and will, thus, require manual work on the part of an | ||
engineer to update the existing system prompts and to create new system prompts as we approach a full roll out. This | ||
presents an opportunity to reconsider the way that we store and process the system prompt. | ||
|
||
Decision | ||
******** | ||
|
||
* We will store a system prompt template in a Django setting in the form of a Jinja template. | ||
* We will use Jinja constructs, such as variables and control structures, to implement a single system prompt template | ||
for all courses. | ||
* The system prompt template will be rendered in two steps. | ||
|
||
* The first render step will be performed by the `learning-assistant`_ code. This step will interpolate any variables | ||
for which this code has a value (e.g. unit content). | ||
* The second render step will be performed by the 2U Xpert Platform generic chat completion endpoint. This step will | ||
interpolate any variable for which the platform has a value (e.g. course title and skill names). | ||
|
||
* After the first render step, the resulting value will be a Jinja template that has been partially rendered. This | ||
template will be sent to 2U's Xpert Platform generic chat completion endpoint to be completely rendered. | ||
* We will remove the `CoursePrompt model`_ following the instructions documented in | ||
`Everything About Database Migrations`_. | ||
|
||
Consequences | ||
************ | ||
|
||
* Changes to the system prompt will require pull requests to the appropriate repository in which the prompt is stored. | ||
* Anyone with access to the appropriate repository in which the prompt is stored can change the system prompt. Members | ||
of the team will no longer require assistance from the SRE team. | ||
* The transition to a system prompt template required the 2U Xpert Platform team to provide support for accepting and | ||
rendering a system prompt template and the integration of Discovery ``skill_names`` into their index. | ||
* The use of a system prompt template will require cross-team collaboration to ensure that the same variable names are | ||
use in the system prompt template, in the `learning-assistant`_ code, and the 2U Xpert Platform generic chat | ||
completion endpoint. | ||
* Because the system prompt template will be stored in a Django setting in a private repository, and the code that | ||
renders the template is stored here, changes to the template will require careful coordination to ensure that the | ||
template is rendered properly. | ||
|
||
* For example, if a new variable is added to the template, the code must be modified and deployed in advanced of | ||
changes to the template. Otherwise, if changes to template are deployed before the related code changes, then the | ||
rendered template will contain uninterpolated variables. | ||
|
||
* It will become more difficult to enable per-course customizations because all courses will be served by a single | ||
system prompt template. | ||
|
||
Rejected Alternatives | ||
********************* | ||
|
||
* Status Quo | ||
|
||
* The main alternative to this change is to continue to use manual entry and the `set_course_prompts management command`_ | ||
to manage system prompts. | ||
* To enable unit content integration, we would need to modify the JSON string stored in the `CoursePrompt model`_ to | ||
store a JSON string with format string variable for the content, which would be interpolated at runtime. | ||
* The main advantage of this alternative is that it will require less engineering work. | ||
* The main disadvantage of this alternative is that it will become challenging to manage which prompt a course should | ||
use. For example, to do a stage released of unit content integration, we would be required to manage different | ||
templates manually. Later, a full release would require additional changes. This would make management of the | ||
templates even more tedious. | ||
* Managing system prompts in a full release would become intractable. | ||
* Additionally, in order to better operationalize the use of the management command and to reduce our reliance on the | ||
SRE team, we would likely want to invest time in setting up a Jenkins job to run the management command ad-hoc. If | ||
we will be investing engineering resources in this area anyway, we felt it was a more future-proof approach to | ||
pursue the solution described above. | ||
|
||
.. _set_course_prompts management command: https://github.com/edx/learning-assistant/blob/main/learning_assistant/management/commands/set_course_prompts.py | ||
.. _CoursePrompt model: https://github.com/edx/learning-assistant/blob/34604a0775f7bd79adb465e0ca51c7759197bfa9/learning_assistant/models.py | ||
.. _Everything About Database Migrations: https://openedx.atlassian.net/wiki/spaces/AC/pages/23003228/Everything+About+Database+Migrations#EverythingAboutDatabaseMigrations-Howtodropatable | ||
.. _learning-assistant: https://github.com/edx/learning-assistant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
3. CourseApp Use | ||
################ | ||
|
||
Status | ||
****** | ||
|
||
**Accepted** *2024-01-08* | ||
|
||
Context | ||
******* | ||
|
||
We are adding the ability for course teams to manually enable and disable the Learning Assistant in their courses via | ||
a card in the `Pages & Resources page`_ of Studio, provided that the Learning Assistant is enabled and available in | ||
a given course. | ||
|
||
The `Pages & Resources page`_ is powered on the backend by the edX Platform `CourseApp Django app`_. With one | ||
exception in the case of Xpert Unit Summaries, each card on the `Pages & Resources page`_ has a corresponding instance | ||
of the `CourseApp plugin`_ configured in the `edx-platform repository`_. The `Pages & Resources page`_ can then make | ||
calls to the `backend CourseApp REST API`_ to get necessary information about the feature described by the plugin. | ||
|
||
The one exception to this behavior is the ``Xpert unit summaries card``, which uses a `Javascript object`_ stored in a | ||
static file in the `frontend-app-course-authoring repository`_ to describe the options that would otherwise be returned | ||
by the `backend CourseApp REST API`_ using a corresponding ``CourseApp`` plugin. | ||
|
||
Currently, the only ``CourseApp`` plugins registered in the platfrom are those that are defined within the | ||
`edx-platform repository`_. There are currently no plugins that are defined outside of the `edx-platform repository`_. | ||
|
||
Decision | ||
******** | ||
|
||
* We will define an instance of the `CourseApp plugin`_ in this repository to describe the Learning Assistant feature. | ||
* We will register the `CourseApp plugin`_ as an entrypoint with the ``openedx.course_app`` key so that the `CourseApp | ||
Django app`_ will be able to pick up the plugin if the Learning Assistant plugin is installed into ``edx-platform``. | ||
|
||
Consequences | ||
************ | ||
|
||
* The Learning Assistant ``CourseApp`` plugin will only be registered with the `CourseApp Django app`_ if, and, | ||
therefore, the Learning Assistant card on the `Pages & Resources page`_ will only be visible if, the Learning | ||
Assistant plugin is installed into ``edx-platform``. | ||
* It will become slightly more difficult to know which ``CourseApps`` are available simply by reading the code, because | ||
this ``CourseApp`` plugin is not stored in the `edx-platform repository`_. | ||
* Because the `CourseApps` API is registered under the CMS application, the Learning Assistant needs to be registered as | ||
a plugin to the CMS as well. Otherwise, the plugin is not included in the CMS application's ``INSTALLED_APPS`` list. | ||
This causes a runtime error, because the Learning Assistant CourseApp plugin will refer to the Learning Assistant's | ||
models, and this are not available in the CMS if the Learning Assistant plugin is not installed. | ||
|
||
Rejected Alternatives | ||
********************* | ||
|
||
* We decided not to add in a custom backend REST API for exposing the ability to introspect the Learning Assistant | ||
feature and enable and disable it. There already exists the `CourseApp Django app`_ for this purpose, and using it | ||
allows us to avoid writing a lot of ad hoc code. | ||
|
||
.. _backend CourseApp REST API: https://github.com/openedx/edx-platform/blob/master/openedx/core/djangoapps/course_apps/rest_api/v1/views.py#L80 | ||
.. _CourseApp Django app: https://github.com/openedx/edx-platform/tree/master/openedx/core/djangoapps/course_apps | ||
.. _CourseApp plugin: https://github.com/openedx/edx-platform/blob/master/openedx/core/djangoapps/course_apps/plugins.py#L15 | ||
.. _edx-platform: https://github.com/openedx/edx-platform | ||
.. _edx-platform repository: https://github.com/openedx/edx-platform | ||
.. _frontend-app-course-authoring repository: https://github.com/openedx/frontend-app-course-authoring/tree/master | ||
.. _Javascript object: https://github.com/openedx/frontend-app-course-authoring/blob/master/src/pages-and-resources/xpert-unit-summary/appInfo.js | ||
.. _Pages & Resources page: https://github.com/openedx/frontend-app-course-authoring/tree/master/src/pages-and-resources |
Oops, something went wrong.