openedx_ai_extensions.processors.openedx package#
Subpackages#
Submodules#
openedx_ai_extensions.processors.openedx.content_libraries_processor module#
Utility functions and classes for content library operations.
- class openedx_ai_extensions.processors.openedx.content_libraries_processor.ContentLibraryProcessor(library_key: str, user, config=None)#
Bases:
objectHelper class for content library operations
- create_block(data)#
Create a library block.
- create_collection_and_add_items(items, title, description='') str#
Create a collection and add items to it.
- delete_block(usage_key)#
Delete a library block.
- modify_block_olx(usage_key, data)#
Modify the OLX of a library block.
openedx_ai_extensions.processors.openedx.openedx_processor module#
Open edX Content Extraction
- class openedx_ai_extensions.processors.openedx.openedx_processor.OpenEdXProcessor(processor_config=None, location_id=None, course_id=None, user=None)#
Bases:
objectHandles Open edX content extraction
- static define_category(category)#
Define a category processor
- get_context()#
Get the context of a given Open edX location.
- get_course_info(course_id=None, fields=None)#
Retrieve metadata for a specific course.
- Parameters:
- Returns:
A dictionary containing the requested course fields.
- Return type:
- Configuration:
The returned fields can be filtered via processor_config in the workflow profile JSON.
Example:
"processor_config": { "OpenEdXProcessor": { "function": "get_course_info", "fields": ["title", "short_description"] } }
- Available Fields:
title: Course display name.
subtitle: Course subtitle.
short_description: Brief summary of the course.
description: Full-length course description.
overview: Course overview content (HTML).
syllabus: Course syllabus content.
duration: Estimated time to complete the course.
outline: Hierarchical course structure (JSON). Not included by default.
- get_course_outline(course_id=None, user=None)#
Retrieve course outline structure (Sections > Subsections > Units).
- get_location_content(location_id=None, retrieval_mode=None)#
Extract unit or sequence content from Open edX modulestore based on configuration
- get_location_link(location_id=None)#
Helper to get the URL of a given location ID
- no_context(*args, **kwargs)#
Return default message when no context is provided.
- process(*args, **kwargs)#
Process based on configured function
openedx_ai_extensions.processors.openedx.submission_processor module#
Submission processor for handling OpenEdX submissions
- class openedx_ai_extensions.processors.openedx.submission_processor.SubmissionProcessor(config=None, user_session=None)#
Bases:
objectHandles OpenEdX submission operations for chat history and persistence
- get_chat_history(_context, _user_query=None)#
Retrieve initial chat history for the user session. Returns the most recent messages up to max_context_messages.
- get_full_message_history(filters=frozenset({'non_string_content', 'system'}))#
Retrieve the full message history for the current submission.
- Parameters:
filters – Set of FILTER_* constants passed through to _process_messages. Default behaviour (FILTER_SYSTEM + FILTER_NON_STRING_CONTENT) returns only user/assistant messages with plain string content, which is what the LLM input path requires. Pass frozenset() to retrieve everything stored (system messages, function calls, block-format content) for debug/admin views.
- get_full_thread()#
Retrieve the full message history with timestamps for debugging.
Uses the submission’s own student_item to ensure the lookup key matches what was used at creation time, even if the session’s fields have changed.
- Returns:
- All messages in chronological order with role, content, and timestamp,
or None if no submission exists.
- Return type:
- get_previous_messages(current_messages_count=0)#
Retrieve previous messages for lazy loading older chat history. Takes the count of current messages from frontend and returns the next batch of older messages.
- Parameters:
current_messages_count – Number of messages currently displayed in the frontend
- Returns:
Contains ‘response’ (JSON string of new messages) and ‘metadata’ (has_more flag)
- Return type:
- get_submission()#
Retrieve the current submission associated with the user session.
- process(context, input_data=None)#
Process based on configured function
- update_chat_submission(messages)#
Create a new immutable Submission record for this interaction.
Each call stores the provided messages (prompt + AI response) as a new Submission. History is tracked implicitly via
attempt_number, which the Submissions API auto-increments for the samestudent_item.
- update_submission(data)#
Create a new Submission record with the provided data.
attempt_numberis intentionally omitted so the Submissions API auto-increments it for the givenstudent_item.