JAEGIS Natural Language Processing Engine
Advanced NLP Engine for Automatic Workflow Path Determination
Engine Overview
🧠 INTELLIGENT INPUT ANALYSIS FRAMEWORK
Advanced NLP Processing Architecture
class JAEGISNaturalLanguageEngine:
def __init__(self):
"""
Advanced NLP engine for automatic workflow path determination
"""
self.nlp_models = {
'intent_classifier': self.initialize_intent_classifier(),
'complexity_analyzer': self.initialize_complexity_analyzer(),
'domain_detector': self.initialize_domain_detector(),
'workflow_router': self.initialize_workflow_router()
}
self.workflow_patterns = {
'documentation_mode_patterns': [
'create documentation', 'generate specs', 'write requirements',
'design architecture', 'create checklist', 'document system',
'specification for', 'requirements document', 'technical documentation'
],
'full_development_mode_patterns': [
'build application', 'develop system', 'create project',
'implement solution', 'code application', 'full development',
'complete implementation', 'build from scratch', 'develop and deploy'
],
'configuration_mode_patterns': [
'configure system', 'adjust parameters', 'customize workflow',
'optimize settings', 'modify configuration', 'tune performance',
'change settings', 'update configuration', 'personalize system'
],
'analysis_mode_patterns': [
'analyze', 'evaluate', 'assess', 'review', 'examine',
'investigate', 'study', 'research', 'audit', 'validate'
]
}
print("🧠 Natural Language Processing Engine: INITIALIZED")
print(" ✅ Intent classification: READY")
print(" ✅ Complexity analysis: READY")
print(" ✅ Domain detection: READY")
print(" ✅ Workflow routing: READY")
def analyze_input_and_route_workflow(self, user_input):
"""
Analyze natural language input and automatically route to optimal workflow
"""
print(f"🔍 Analyzing input: '{user_input[:100]}...'")
# Phase 1: Intent Classification
intent_analysis = self.classify_intent(user_input)
# Phase 2: Complexity Assessment
complexity_analysis = self.assess_complexity(user_input)
# Phase 3: Domain Detection
domain_analysis = self.detect_domain(user_input)
# Phase 4: Context Analysis
context_analysis = self.analyze_context(user_input)
# Phase 5: Workflow Routing Decision
routing_decision = self.make_routing_decision(
intent_analysis, complexity_analysis, domain_analysis, context_analysis
)
print(f"🎯 Workflow routing decision: {routing_decision['selected_workflow']}")
print(f" 📊 Confidence: {routing_decision['confidence']}%")
print(f" 🔧 Configuration: {routing_decision['configuration']}")
return routing_decision
def classify_intent(self, user_input):
"""
Classify user intent from natural language input
"""
input_lower = user_input.lower()
intent_scores = {}
# Documentation Mode Intent Detection
doc_score = sum(1 for pattern in self.workflow_patterns['documentation_mode_patterns']
if pattern in input_lower)
intent_scores['documentation_mode'] = doc_score
# Full Development Mode Intent Detection
dev_score = sum(1 for pattern in self.workflow_patterns['full_development_mode_patterns']
if pattern in input_lower)
intent_scores['full_development_mode'] = dev_score
# Configuration Mode Intent Detection
config_score = sum(1 for pattern in self.workflow_patterns['configuration_mode_patterns']
if pattern in input_lower)
intent_scores['configuration_mode'] = config_score
# Analysis Mode Intent Detection
analysis_score = sum(1 for pattern in self.workflow_patterns['analysis_mode_patterns']
if pattern in input_lower)
intent_scores['analysis_mode'] = analysis_score
# Determine primary intent
primary_intent = max(intent_scores, key=intent_scores.get) if any(intent_scores.values()) else 'general_inquiry'
return {
'primary_intent': primary_intent,
'intent_scores': intent_scores,
'confidence': max(intent_scores.values()) * 20 if intent_scores.values() else 50
}
def assess_complexity(self, user_input):
"""
Assess complexity level of the request
"""
complexity_indicators = {
'high_complexity': [
'enterprise', 'scalable', 'production', 'comprehensive', 'complete system',
'full stack', 'microservices', 'distributed', 'cloud native', 'multi-tier'
],
'medium_complexity': [
'application', 'system', 'platform', 'framework', 'integration',
'database', 'api', 'workflow', 'automation', 'dashboard'
],
'low_complexity': [
'simple', 'basic', 'quick', 'small', 'prototype',
'demo', 'example', 'test', 'minimal', 'lightweight'
]
}
input_lower = user_input.lower()
complexity_scores = {}
for level, indicators in complexity_indicators.items():
score = sum(1 for indicator in indicators if indicator in input_lower)
complexity_scores[level] = score
# Determine complexity level
if complexity_scores['high_complexity'] > 0:
complexity_level = 'high'
elif complexity_scores['medium_complexity'] > 0:
complexity_level = 'medium'
elif complexity_scores['low_complexity'] > 0:
complexity_level = 'low'
else:
# Default based on input length and technical terms
word_count = len(user_input.split())
technical_terms = ['system', 'application', 'platform', 'solution', 'architecture']
tech_score = sum(1 for term in technical_terms if term in input_lower)
if word_count > 50 or tech_score > 2:
complexity_level = 'medium'
else:
complexity_level = 'low'
return {
'complexity_level': complexity_level,
'complexity_scores': complexity_scores,
'word_count': len(user_input.split()),
'estimated_effort': self.estimate_effort(complexity_level)
}
def detect_domain(self, user_input):
"""
Detect domain/industry context from input
"""
domain_keywords = {
'software_development': [
'software', 'application', 'code', 'programming', 'development',
'api', 'database', 'frontend', 'backend', 'framework'
],
'business_analysis': [
'business', 'requirements', 'process', 'workflow', 'analysis',
'stakeholder', 'user story', 'business case', 'roi', 'strategy'
],
'data_science': [
'data', 'analytics', 'machine learning', 'ai', 'model',
'dataset', 'visualization', 'statistics', 'prediction', 'algorithm'
],
'infrastructure': [
'infrastructure', 'cloud', 'deployment', 'server', 'network',
'security', 'monitoring', 'devops', 'kubernetes', 'docker'
],
'design_ux': [
'design', 'user experience', 'interface', 'ui', 'ux',
'wireframe', 'prototype', 'usability', 'user journey', 'mockup'
]
}
input_lower = user_input.lower()
domain_scores = {}
for domain, keywords in domain_keywords.items():
score = sum(1 for keyword in keywords if keyword in input_lower)
domain_scores[domain] = score
primary_domain = max(domain_scores, key=domain_scores.get) if any(domain_scores.values()) else 'general'
return {
'primary_domain': primary_domain,
'domain_scores': domain_scores,
'multi_domain': sum(1 for score in domain_scores.values() if score > 0) > 1
}
def analyze_context(self, user_input):
"""
Analyze contextual factors for workflow optimization
"""
context_factors = {
'urgency_indicators': ['urgent', 'asap', 'immediately', 'quickly', 'fast', 'rush'],
'quality_indicators': ['high quality', 'production ready', 'enterprise grade', 'robust', 'reliable'],
'collaboration_indicators': ['team', 'collaborate', 'stakeholders', 'review', 'feedback'],
'iteration_indicators': ['iterate', 'improve', 'enhance', 'optimize', 'refine', 'update']
}
input_lower = user_input.lower()
context_analysis = {}
for factor, indicators in context_factors.items():
score = sum(1 for indicator in indicators if indicator in input_lower)
context_analysis[factor] = score > 0
return context_analysis
def make_routing_decision(self, intent_analysis, complexity_analysis, domain_analysis, context_analysis):
"""
Make intelligent workflow routing decision based on all analysis factors
"""
# Decision matrix based on analysis results
decision_factors = {
'intent_weight': 0.4,
'complexity_weight': 0.3,
'domain_weight': 0.2,
'context_weight': 0.1
}
# Calculate workflow scores
workflow_scores = {
'documentation_mode': 0,
'full_development_mode': 0,
'hybrid_mode': 0
}
# Intent-based scoring
if intent_analysis['primary_intent'] == 'documentation_mode':
workflow_scores['documentation_mode'] += 80 * decision_factors['intent_weight']
elif intent_analysis['primary_intent'] == 'full_development_mode':
workflow_scores['full_development_mode'] += 80 * decision_factors['intent_weight']
else:
workflow_scores['hybrid_mode'] += 60 * decision_factors['intent_weight']
# Complexity-based scoring
if complexity_analysis['complexity_level'] == 'high':
workflow_scores['full_development_mode'] += 70 * decision_factors['complexity_weight']
workflow_scores['documentation_mode'] += 60 * decision_factors['complexity_weight']
elif complexity_analysis['complexity_level'] == 'medium':
workflow_scores['hybrid_mode'] += 80 * decision_factors['complexity_weight']
else:
workflow_scores['documentation_mode'] += 70 * decision_factors['complexity_weight']
# Domain-based scoring
if domain_analysis['multi_domain']:
workflow_scores['full_development_mode'] += 60 * decision_factors['domain_weight']
# Context-based scoring
if context_analysis.get('urgency_indicators'):
workflow_scores['documentation_mode'] += 50 * decision_factors['context_weight']
if context_analysis.get('quality_indicators'):
workflow_scores['full_development_mode'] += 60 * decision_factors['context_weight']
# Select optimal workflow
selected_workflow = max(workflow_scores, key=workflow_scores.get)
confidence = workflow_scores[selected_workflow]
# Generate configuration recommendations
configuration = self.generate_configuration_recommendations(
intent_analysis, complexity_analysis, domain_analysis, context_analysis
)
return {
'selected_workflow': selected_workflow,
'confidence': min(100, max(50, int(confidence))),
'workflow_scores': workflow_scores,
'configuration': configuration,
'analysis_summary': {
'intent': intent_analysis['primary_intent'],
'complexity': complexity_analysis['complexity_level'],
'domain': domain_analysis['primary_domain'],
'context_factors': context_analysis
}
}
def generate_configuration_recommendations(self, intent_analysis, complexity_analysis, domain_analysis, context_analysis):
"""
Generate intelligent configuration recommendations based on analysis
"""
config_recommendations = {
'agent_activation_frequency': 80, # Default
'quality_validation_intensity': 85, # Default
'deep_web_research_frequency': 70, # Default
'task_decomposition_depth': 75, # Default
'real_time_monitoring_frequency': 80, # Default
'cross_validation_frequency': 75 # Default
}
# Adjust based on complexity
if complexity_analysis['complexity_level'] == 'high':
config_recommendations['agent_activation_frequency'] = 95
config_recommendations['quality_validation_intensity'] = 95
config_recommendations['task_decomposition_depth'] = 90
elif complexity_analysis['complexity_level'] == 'low':
config_recommendations['agent_activation_frequency'] = 60
config_recommendations['task_decomposition_depth'] = 60
# Adjust based on context
if context_analysis.get('urgency_indicators'):
config_recommendations['deep_web_research_frequency'] = 50
config_recommendations['cross_validation_frequency'] = 60
if context_analysis.get('quality_indicators'):
config_recommendations['quality_validation_intensity'] = 100
config_recommendations['cross_validation_frequency'] = 90
return config_recommendations
def estimate_effort(self, complexity_level):
"""
Estimate effort based on complexity level
"""
effort_estimates = {
'low': '1-3 hours',
'medium': '4-8 hours',
'high': '8-20 hours'
}
return effort_estimates.get(complexity_level, '4-8 hours')Automatic Workflow Initiation Protocol
Last updated