feat: implement notification routing pipeline - #14
Open
javagovindsharma wants to merge 1 commit into
Open
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Notification Routing Pipeline Implementation
Overview
This change implements the initial end-to-end notification routing pipeline for the HackerRank Orchestrate challenge. The implementation processes incoming messages, enriches them with available user and contextual information, analyzes message content, retrieves relevant historical messages, determines the appropriate notification action, selects supporting evidence, and generates the final output CSV.
The pipeline supports three notification actions:
notify— For messages that require immediate user attention.digest— For useful messages that do not require immediate notification.mute— For spam, scam, or low-value messages that should not generate notifications.Implementation Details
1. Data Loading
Implemented a centralized
DataLoaderto load all relevant CSV datasets from the repository'sdatasetdirectory.The loader supports:
messages.csvsample_messages.csvusers.csvgroups.csvgroup_members.csvbusiness_accounts.csvuser_business_history.csvmessage_history.csvmessage_events.csvimages.csvvoice_notes.csvdaily_notification_summary.csvThe implementation also handles missing files gracefully and logs the loading status of each dataset.
2. Context Building
Added
ContextBuilderto construct a contextual representation for every incoming message.The context includes, where available:
This provides the foundation for personalized notification decisions.
3. Message Analysis
Implemented
MessageAnalyzerto classify incoming messages based on their content.Supported message categories include:
personalurgenteventpaymentbusiness_updatepromotiongreetingforwardspamscamunknownThe analyzer also calculates:
Rule-based keyword detection is currently used as the baseline classification mechanism.
4. Historical Message Retrieval
Added a
Retrievercomponent using TF-IDF and cosine similarity to identify historically relevant messages.The retrieval process:
This enables historical context and evidence to be incorporated into notification decisions.
5. Evidence Selection
Implemented
EvidenceSelectorto extract relevant historicalmessage_idvalues from retrieved messages.The selected evidence is included in the final output through the
evidence_message_idsfield.6. Notification Decision Engine
Implemented
DecisionEngineto determine the final notification action.The decision engine currently evaluates:
The engine produces one of:
notifydigestmuteIt also generates:
7. Output Generation
Added
OutputGeneratorto generate the final prediction CSV.The output follows the required schema:
The output is generated as:
8. End-to-End Pipeline
The complete processing flow is:
9. Prompt Template
Added a reusable notification routing prompt template under:
The prompt defines the notification routing task, supported message categories, available actions, contextual signals, and expected JSON output format.
This provides a foundation for integrating an LLM-based decision engine in a future iteration.
Current Implementation Approach
The current version uses a hybrid baseline approach:
This approach provides a deterministic and explainable baseline while keeping the architecture modular for future AI/LLM integration.
Future Enhancements
The following improvements can be added in subsequent iterations:
Validation
The pipeline can be executed using:
cd code pip install -r requirements.txt py main.pyThe generated predictions are written to:
This implementation establishes the initial modular architecture required to evolve the notification routing system into a fully personalized, multimodal, and LLM-powered notification agent.