A comprehensive three-layer AI system designed to protect children online through intelligent content analysis, decision-making, and coordinated response actions. KidShield combines advanced LLM capabilities with robust safety mechanisms to provide real-time protection against digital threats.
This system receives incoming messages that have already been classified as suspicious and focuses on:
- Detects Threats: Uses advanced agents to analyze text and images for potential dangers
- Makes Smart Decisions: AI-enhanced decision engine determines appropriate protective actions
- Coordinates Responses: Manages communications with parents, children, and relevant authorities
- Provides Education: Delivers age-appropriate safety resources and guidance
- Ensures Safety: Maintains comprehensive audit trails and fallback mechanisms
KidShield implements a clean three-layer architecture for maximum modularity and scalability:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ APP LAYER โ
โ User Interfaces โข APIs โข Authentication โข Dashboards โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ GUARDIAN LAYER โ
โ Agent Analysis โข Threat Detection โข Content Classification โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ AGENT LAYER โ
โ Decision Making โข Communication โข Action Coordination โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ฅ๏ธ App Layer: User-facing interfaces, authentication, and application logic
๐ก๏ธ Guardian Layer: AI-powered content analysis and threat detection
๐ค Agent Layer: Intelligent decision-making and response coordination
The system integrates with BlackBox AI to provide enhanced capabilities:
- Enhanced Decision Reasoning: AI-generated explanations for all decisions
- Personalized Communications: Context-aware messages for parents, children, and senders
- Age-Appropriate Content: Automatically adapted messaging based on child's age and situation
- Fallback Safety: Graceful degradation to template-based responses if LLM is unavailable
- Message Processor - Handles incoming suspicious messages with metadata
- Decision Engine - Analyzes context and selects appropriate actions
- Communication Generator - Creates tailored messages for different stakeholders
- Action Manager - Coordinates and executes chosen actions
- Educational Content Library - Age-appropriate safety resources
- Logging & Audit System - Tracks decisions and actions for transparency
- โ Multi-stakeholder communication (parents, children, senders)
- โ Age-appropriate content generation
- โ Severity assessment algorithms
- โ Educational resource matching
- โ Action justification and audit trails
- โ Configurable response templates
- โ Comprehensive logging and monitoring
The three layers work together in a coordinated flow:
1. ๐ฑ App Layer receives user input (message, image, etc.)
โ
2. ๐ก๏ธ Guardian Layer analyzes content using LLM models
โ (threat detected)
3. ๐ค Agent Layer makes decisions and coordinates responses
โ
4. ๐ฑ App Layer delivers notifications and educational content
- App โ Guardian: Content submission for analysis
- Guardian โ Agent: Threat detection results and risk scores
- Agent โ App: Action plans and communication content
- Cross-Layer: Comprehensive logging and audit trails
- Python 3.8+
- BlackBox AI API key
- Required packages (see requirements.txt)
- Clone the repository:
git clone https://github.com/jermiah/kidshield_app.git
cd kidshield_app- Install dependencies:
python -m venv myenv
source myenv/bin/activate
pip install -r requirements.txt- Set up your BlackBox API key:
# Create .env file with your API key
touch .env
echo "BLACKBOX_API_KEY=your_api_key_here" > .env- Run fastapi server:
cd guardian_layer/api
fastapi run guardian_api.py- Run nodejs server to connect to WhatsApp
cd app_layer/nodejs
npm i
npm run devfrom src.agents.ai_agent import AIAgent
from src.models.message import SuspiciousMessage, ChildProfile, MessageMetadata, ThreatType, SeverityLevel
# Initialize the AI agent with LLM enhancement
agent = AIAgent(use_llm=True)
# Create a suspicious message (normally received from detection system)
message = SuspiciousMessage(
message_id="msg_001",
content="Suspicious content here",
threat_type=ThreatType.BULLYING,
severity=SeverityLevel.HIGH,
child_profile=child_profile,
metadata=metadata
)
# Process the message
action_plan = agent.process_suspicious_message(message)
# Review the action plan with AI-enhanced reasoning
print(f"Generated {len(action_plan.decisions)} decisions")
print(f"Created {len(action_plan.communications)} communications")
# View enhanced reasoning
for decision in action_plan.decisions:
print(f"Action: {decision.action_type.value}")
print(f"AI Reasoning: {decision.reasoning}")The system can be configured to use or disable LLM features:
# Enable LLM (default)
agent = AIAgent(use_llm=True)
# Disable LLM (use templates only)
agent = AIAgent(use_llm=False)
# Configure via config file
config = {
"llm": {
"enabled": True,
"fallback_to_templates": True,
"temperature": {
"decision_reasoning": 0.3,
"parent_messages": 0.4,
"child_messages": 0.5
}
}
}
agent = AIAgent(config, use_llm=True)The system uses BlackBox AI for enhanced capabilities:
from src.utils.blackbox_client import BlackBoxClient
# Direct LLM usage
client = BlackBoxClient()
# Generate enhanced decision reasoning
reasoning = client.generate_decision_reasoning(
message_content="Inappropriate message",
threat_type="bullying",
severity="high",
child_age=12,
context={"sender_type": "stranger"}
)
# Generate personalized parent message
parent_msg = client.generate_parent_message(
child_name="Emma",
threat_type="bullying",
severity="high",
action_taken="Sender blocked",
tone="urgent"
)The system handles various types of suspicious content:
- Bullying/Harassment - Cyberbullying and online harassment
- Inappropriate Requests - Requests from strangers or inappropriate contacts
- Sexual/Violent Content - Explicit or harmful content
- Manipulation/Scams - Attempts to manipulate or defraud
- Stranger Contact - Unsolicited contact from unknown individuals
{
"decision_engine": {
"severity_thresholds": {
"critical": 0.9,
"high": 0.7,
"medium": 0.4,
"low": 0.0
},
"immediate_action_triggers": [
"sexual_content",
"violent_content",
"manipulation"
]
}
}Contains age-appropriate safety tips, educational modules, and crisis resources.
The AI agent follows a structured decision-making process:
- Risk Assessment - Calculates risk score based on multiple factors
- Action Selection - Determines appropriate actions based on threat type and severity
- Communication Planning - Generates targeted messages for stakeholders
- Timeline Creation - Schedules actions based on priority
- Follow-up Planning - Determines if ongoing monitoring is needed
- Threat type and severity level
- Child's age and vulnerability
- Sender history and behavior patterns
- Message frequency and context
- Previous incidents involving the child
- Urgent Notifications - Immediate alerts for high-risk situations
- Standard Notifications - Regular updates on incidents
- Educational Resources - Guidance on digital safety and communication
- Age-Appropriate Alerts - Gentle notifications tailored to age group
- Educational Content - Safety tips and awareness information
- Supportive Messages - Reassurance and guidance
- Warning Messages - Firm warnings about inappropriate behavior
- Educational Information - Guidelines on acceptable online conduct
Run the test suite:
# Run all tests
python -m pytest tests/
# Run specific test file
python -m pytest tests/test_decision_engine.py
# Run with coverage
python -m pytest tests/ --cov=srcThe system includes comprehensive logging and auditing:
- Decision Tracking - All decisions are logged with reasoning
- Communication Logs - Record of all messages sent
- Action Execution - Tracking of action implementation
- Performance Metrics - System performance and effectiveness
- Child Privacy - Age-appropriate communication that respects privacy
- Data Protection - Secure handling of sensitive information
- Transparency - Clear reasoning for all decisions and actions
- Non-Stigmatizing - Supportive approach that doesn't blame victims
- Input: Bullying message to 14-year-old
- Actions: Notify parent, educate child, warn sender, provide resources
- Communications: Supportive message to teen, informative alert to parent
- Input: Stranger requesting personal meeting with 12-year-old
- Actions: Block sender, immediate parent notification, educate child
- Communications: Age-appropriate safety reminder, urgent parent alert
- Input: Adult attempting to manipulate vulnerable child
- Actions: Block sender, escalate to authorities, comprehensive support
- Communications: Crisis resources, immediate intervention
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For questions or support:
- Check the examples in the
examples/directory - Review the test cases in
tests/ - Consult the configuration files in
config/
- Machine learning integration for improved decision-making
- Real-time threat intelligence integration
- Advanced natural language processing for content analysis
- Integration with external safety platforms
- Mobile app for parent notifications
- Dashboard for monitoring and analytics
Note: This system is designed to work with pre-classified suspicious messages. It focuses on response coordination rather than initial threat detection.
