feat: add 'up_to_current_unit' retrieval mode to OpenEdXProcessor#213
Conversation
- implement new 'up_to_current_unit' retrieval mode to fetch sequence content up to the current unit
- update get_location_content tool schema to support dynamic retrieval_mode selection by the LLM
- enhance mock_keys in tests to support string comparison and make_usage_key method
- add comprehensive tests for the new retrieval mode and parameter overrides
- update implementation details documentation to reflect the three supported retrieval modes
|
Thanks for the pull request, @Pavilion4ik! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #213 +/- ##
==========================================
+ Coverage 95.08% 95.13% +0.05%
==========================================
Files 67 67
Lines 7203 7322 +119
Branches 380 387 +7
==========================================
+ Hits 6849 6966 +117
- Misses 265 267 +2
Partials 89 89
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
felipemontoya
left a comment
There was a problem hiding this comment.
This is working exactly as I would expect. Thanks a lot @Pavilion4ik.
I only have one comment that I'd like you to add before we merge. Can you add the explicit retrieval_mode to the profiles?
Since the profiles are read using json5, you could even leave a comment with options.
"OpenEdXProcessor": {
"function": "get_location_content",
"retrieval_mode": "up_to_current_unit" // "unit", "sequence", "up_to_current_unit"
},|
I would still leave the default being unit, but you can mix it up in the profile examples |
- Added retrieval_mode examples to profiles
@felipemontoya Got it - I’ve added |
Overview
The
retrieval_modefeature allows AI interactions to leverage context beyond the immediate unit where the interaction is happening. This is particularly useful for courses with granular content structures where a single unit may not provide enough context for meaningful AI responses.Configuration Options
The system now supports three primary retrieval modes:
unit(Default): Retrieves content only from the current unit.up_to_current_unit: Retrieves content from the sequence up to (and including) the current unit.sequence: Retrieves content from the entire parent sequence (e.g., all units in the same lesson/subsection).How it Works
The
OpenEdXProcessordetermines theretrieval_modefrom its configuration (typically defined in the active workflow profile's JSON file).Example: Setting in a Workflow Profile (
.jsonfile)To enable sequence-level retrieval for a specific workflow, add
"retrieval_mode": "sequence"to theOpenEdXProcessorconfiguration:{ "orchestrator_class": "DirectLLMResponse", "processor_config": { "OpenEdXProcessor": { "function": "get_location_content", "retrieval_mode": "sequence" }, "LLMProcessor": { "provider": "default", "prompt": "Summarize the lesson content provided below..." } } }Technical Implementation
openedx_processor.py, theget_location_contentmethod checksself.configforretrieval_mode.sequence, it usesstore.get_parent_location(unit_key)to find the parent sequence and retrieves content for all its child units using a new_get_unit_datahelper method.unitmode, the returned JSON contains data for a single unit.sequencemode, the returned JSON contains asequence_id,display_name, and aunitslist containing the processed content of every unit in that sequence.Issue: #173