Fixed Intelligent Course Generator - Real Content Analysis
Browse files- README.md +33 -26
- app.py +491 -1008
- requirements.txt +7 -5
README.md
CHANGED
|
@@ -1,34 +1,41 @@
|
|
| 1 |
-
-
|
| 2 |
-
title: Leadership Instructor Agent
|
| 3 |
-
emoji: 🎯
|
| 4 |
-
colorFrom: blue
|
| 5 |
-
colorTo: purple
|
| 6 |
-
sdk: gradio
|
| 7 |
-
sdk_version: 4.44.0
|
| 8 |
-
app_file: app.py
|
| 9 |
-
pinned: false
|
| 10 |
-
license: mit
|
| 11 |
-
---
|
| 12 |
|
| 13 |
-
#
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
##
|
| 18 |
|
| 19 |
-
|
| 20 |
-
-
|
| 21 |
-
-
|
| 22 |
-
-
|
| 23 |
-
- **Copy-Paste Friendly**: Easy to save and reference responses
|
| 24 |
|
| 25 |
-
##
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
|
| 28 |
|
| 29 |
-
**
|
| 30 |
-
-
|
| 31 |
-
-
|
| 32 |
-
-
|
|
|
|
| 33 |
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 🧠 Intelligent Course Generator - FIXED
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
## ✅ What This Fixes
|
| 4 |
|
| 5 |
+
1. **Real Topic Extraction** - Finds actual leadership topics from your corpus instead of generic "MicroLessons"
|
| 6 |
+
2. **Content Analysis** - Shows exactly what can be built and what needs AI enhancement
|
| 7 |
+
3. **Sufficiency Checking** - Determines if you have enough content for lesson/unit/course
|
| 8 |
+
4. **Gap Identification** - Shows what percentage needs ChatGPT vs corpus content
|
| 9 |
+
5. **Actual Content Generation** - Creates real lessons on real topics
|
| 10 |
|
| 11 |
+
## 🔍 How It Works
|
| 12 |
|
| 13 |
+
### Step 1: Content Analysis
|
| 14 |
+
- Enter broad search term (e.g., "communication", "leadership")
|
| 15 |
+
- System extracts actual topics from your corpus
|
| 16 |
+
- Shows buildability analysis for each topic
|
|
|
|
| 17 |
|
| 18 |
+
### Step 2: Real Content Generation
|
| 19 |
+
- Use specific topics identified in analysis
|
| 20 |
+
- Generates complete lessons with real content
|
| 21 |
+
- Shows corpus % vs AI enhancement %
|
| 22 |
|
| 23 |
+
## 🚀 Features
|
| 24 |
|
| 25 |
+
- **Topic Extraction**: Finds real leadership topics in your corpus
|
| 26 |
+
- **Sufficiency Analysis**: 50/50, 60/40, or 70/30 content standards
|
| 27 |
+
- **Gap Filling**: Uses ChatGPT only for identified gaps
|
| 28 |
+
- **Real Content**: Actual lessons, not placeholder text
|
| 29 |
+
- **Quality Standards**: Meets your corpus utilization requirements
|
| 30 |
|
| 31 |
+
## 📊 Content Standards
|
| 32 |
+
|
| 33 |
+
- **70/30**: Ideal (70% corpus, 30% AI)
|
| 34 |
+
- **60/40**: Good (60% corpus, 40% AI)
|
| 35 |
+
- **50/50**: Minimum (50% corpus, 50% AI)
|
| 36 |
+
|
| 37 |
+
## 🎯 Usage
|
| 38 |
+
|
| 39 |
+
1. **Analyze Content**: See what topics you can build
|
| 40 |
+
2. **Generate Lessons**: Create real content on those topics
|
| 41 |
+
3. **Quality Check**: Verify corpus vs AI percentages
|
app.py
CHANGED
|
@@ -18,159 +18,110 @@ model = None
|
|
| 18 |
def safe_load_resources():
|
| 19 |
"""Safely load resources with error handling"""
|
| 20 |
global dataset, model
|
| 21 |
-
|
| 22 |
try:
|
| 23 |
if dataset is None:
|
| 24 |
-
print("
|
| 25 |
from datasets import load_dataset
|
| 26 |
from sentence_transformers import SentenceTransformer
|
| 27 |
-
|
| 28 |
dataset = load_dataset("PhillyMac/Leadership_Corpus")['train']
|
| 29 |
model = SentenceTransformer('all-MiniLM-L6-v2')
|
| 30 |
-
print(f"✅ Loaded {len(dataset)} insights")
|
| 31 |
-
|
| 32 |
return dataset, model, None
|
| 33 |
-
|
| 34 |
except Exception as e:
|
| 35 |
error_msg = f"Resource loading error: {str(e)}"
|
| 36 |
print(error_msg)
|
| 37 |
return None, None, error_msg
|
| 38 |
|
| 39 |
-
def
|
| 40 |
-
"""
|
| 41 |
-
|
| 42 |
try:
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
-
|
| 68 |
-
-
|
| 69 |
-
-
|
| 70 |
-
-
|
| 71 |
-
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
],
|
| 119 |
-
max_tokens=1500,
|
| 120 |
-
temperature=0.3
|
| 121 |
-
)
|
| 122 |
-
|
| 123 |
-
content = response.choices[0].message.content
|
| 124 |
-
references = extract_references_from_content(content)
|
| 125 |
-
|
| 126 |
-
return {
|
| 127 |
-
'content': content,
|
| 128 |
-
'references': references,
|
| 129 |
-
'error': None
|
| 130 |
-
}
|
| 131 |
-
|
| 132 |
except Exception as e:
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
'references': [f"Error accessing ChatGPT: {str(e)}"],
|
| 136 |
-
'error': str(e)
|
| 137 |
-
}
|
| 138 |
-
|
| 139 |
-
def extract_references_from_content(content):
|
| 140 |
-
"""Extract academic references from ChatGPT content"""
|
| 141 |
-
|
| 142 |
-
references = []
|
| 143 |
-
|
| 144 |
-
# Look for common reference patterns
|
| 145 |
-
patterns = [
|
| 146 |
-
r'\([A-Z][a-zA-Z]+,\s*\d{4}\)', # (Author, Year)
|
| 147 |
-
r'[A-Z][a-zA-Z]+\s*\(\d{4}\)', # Author (Year)
|
| 148 |
-
r'[A-Z][a-zA-Z]+\s*et\s*al\.\s*\(\d{4}\)', # Author et al. (Year)
|
| 149 |
-
]
|
| 150 |
-
|
| 151 |
-
for pattern in patterns:
|
| 152 |
-
matches = re.findall(pattern, content)
|
| 153 |
-
references.extend(matches)
|
| 154 |
-
|
| 155 |
-
# Look for book titles in quotes or italics
|
| 156 |
-
book_patterns = [
|
| 157 |
-
r'"([A-Z][^"]*)"', # "Book Title"
|
| 158 |
-
r'_([A-Z][^_]*)_', # _Book Title_
|
| 159 |
-
]
|
| 160 |
-
|
| 161 |
-
for pattern in book_patterns:
|
| 162 |
-
matches = re.findall(pattern, content)
|
| 163 |
-
references.extend([f'"{match}"' for match in matches if len(match) > 10])
|
| 164 |
-
|
| 165 |
-
# If no references found, add placeholder
|
| 166 |
-
if not references:
|
| 167 |
-
references = ["References not properly formatted in AI response - manual verification required"]
|
| 168 |
-
|
| 169 |
-
return list(set(references)) # Remove duplicates
|
| 170 |
-
|
| 171 |
-
def analyze_corpus_sufficiency(topic):
|
| 172 |
-
"""Analyze if corpus has sufficient content for lesson/unit/course generation"""
|
| 173 |
|
|
|
|
|
|
|
|
|
|
| 174 |
try:
|
| 175 |
dataset, model, error = safe_load_resources()
|
| 176 |
if error:
|
|
@@ -178,962 +129,494 @@ def analyze_corpus_sufficiency(topic):
|
|
| 178 |
'status': 'error',
|
| 179 |
'message': error,
|
| 180 |
'corpus_percentage': 0,
|
| 181 |
-
'max_feasible': 'none'
|
|
|
|
| 182 |
}
|
| 183 |
-
|
| 184 |
-
print(f"🔍 Analyzing
|
| 185 |
-
|
| 186 |
-
#
|
| 187 |
topic_embedding = model.encode([topic])
|
| 188 |
sample_size = min(1500, len(dataset))
|
| 189 |
indices = np.random.choice(len(dataset), sample_size, replace=False)
|
| 190 |
-
|
| 191 |
content_texts = [dataset[int(idx)]['content'] for idx in indices]
|
| 192 |
content_embeddings = model.encode(content_texts)
|
| 193 |
-
|
| 194 |
similarities = cosine_similarity(topic_embedding, content_embeddings)[0]
|
| 195 |
-
|
| 196 |
-
# Classify content by relevance
|
| 197 |
-
high_relevance = similarities > 0.4 # Strong matches
|
| 198 |
-
medium_relevance = similarities > 0.3 # Good matches
|
| 199 |
-
low_relevance = similarities > 0.2 # Acceptable
|
| 200 |
-
|
| 201 |
high_count = np.sum(high_relevance)
|
| 202 |
medium_count = np.sum(medium_relevance) - high_count
|
| 203 |
low_count = np.sum(low_relevance) - medium_count - high_count
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
# Calculate content depth
|
| 208 |
relevant_indices = indices[similarities > 0.2]
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
content_analysis = []
|
| 212 |
-
themes = {}
|
| 213 |
-
source_documents = {}
|
| 214 |
-
total_content_length = 0
|
| 215 |
-
|
| 216 |
for i, idx in enumerate(relevant_indices):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 217 |
try:
|
| 218 |
-
actual_idx = int(idx)
|
| 219 |
-
content = dataset[actual_idx]['content']
|
| 220 |
metadata = json.loads(dataset[actual_idx]['metadata'])
|
| 221 |
source_topic = metadata.get('topic', 'Leadership')
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
})
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
'id': doc_id,
|
| 239 |
-
'score': float(relevant_scores[i]),
|
| 240 |
-
'content_length': len(content)
|
| 241 |
})
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
}
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
break
|
| 263 |
-
|
| 264 |
-
except Exception as e:
|
| 265 |
-
continue
|
| 266 |
-
|
| 267 |
-
# Sort content by relevance
|
| 268 |
-
content_analysis.sort(key=lambda x: x['score'], reverse=True)
|
| 269 |
-
|
| 270 |
-
# Generate lesson topics from themes
|
| 271 |
-
buildable_lessons = []
|
| 272 |
-
sorted_themes = sorted(themes.items(), key=lambda x: x[1], reverse=True)
|
| 273 |
-
|
| 274 |
-
for theme, score in sorted_themes:
|
| 275 |
-
if score > 0.5: # Substantial theme presence
|
| 276 |
-
if theme == 'communication':
|
| 277 |
-
buildable_lessons.append(f"Mastering {topic} Through Effective Communication")
|
| 278 |
-
elif theme == 'decision_making':
|
| 279 |
-
buildable_lessons.append(f"{topic} in Critical Decision-Making")
|
| 280 |
-
elif theme == 'team_building':
|
| 281 |
-
buildable_lessons.append(f"Building Team {topic} and Cohesion")
|
| 282 |
-
elif theme == 'conflict_resolution':
|
| 283 |
-
buildable_lessons.append(f"Applying {topic} in Conflict Situations")
|
| 284 |
-
elif theme == 'motivation':
|
| 285 |
-
buildable_lessons.append(f"Motivating Others Through {topic}")
|
| 286 |
-
elif theme == 'change_management':
|
| 287 |
-
buildable_lessons.append(f"Leading {topic} During Change")
|
| 288 |
-
elif theme == 'emotional_intelligence':
|
| 289 |
-
buildable_lessons.append(f"Emotional Intelligence and {topic}")
|
| 290 |
-
elif theme == 'delegation':
|
| 291 |
-
buildable_lessons.append(f"Effective Delegation with {topic}")
|
| 292 |
-
elif theme == 'performance':
|
| 293 |
-
buildable_lessons.append(f"Performance Excellence Through {topic}")
|
| 294 |
-
elif theme == 'vision':
|
| 295 |
-
buildable_lessons.append(f"Strategic Vision and {topic} Leadership")
|
| 296 |
-
|
| 297 |
-
# Add foundational lessons if needed
|
| 298 |
-
if len(buildable_lessons) < 3:
|
| 299 |
-
buildable_lessons.extend([
|
| 300 |
-
f"Foundation Principles of {topic}",
|
| 301 |
-
f"Practical Applications of {topic}",
|
| 302 |
-
f"Advanced {topic} Leadership Techniques"
|
| 303 |
-
])
|
| 304 |
-
|
| 305 |
-
# Calculate corpus percentage and determine feasibility
|
| 306 |
-
avg_relevance = np.mean([item['score'] for item in content_analysis]) if content_analysis else 0
|
| 307 |
-
|
| 308 |
-
# Corpus sufficiency calculation
|
| 309 |
-
corpus_strength = (high_count * 3 + medium_count * 2 + low_count * 1) / 10
|
| 310 |
-
content_depth = min(total_content_length / 50000, 2.0)
|
| 311 |
-
theme_diversity = len([t for t, s in themes.items() if s > 0.3]) / 5
|
| 312 |
-
|
| 313 |
-
corpus_percentage = min(100, (corpus_strength + content_depth + theme_diversity) * 20)
|
| 314 |
-
|
| 315 |
-
# Determine maximum feasible generation level
|
| 316 |
-
if corpus_percentage >= 70: # 70/30 standard
|
| 317 |
-
if len(buildable_lessons) >= 12:
|
| 318 |
-
max_feasible = 'course'
|
| 319 |
-
elif len(buildable_lessons) >= 5:
|
| 320 |
-
max_feasible = 'unit'
|
| 321 |
-
else:
|
| 322 |
-
max_feasible = 'lesson'
|
| 323 |
-
elif corpus_percentage >= 60: # 60/40 fallback
|
| 324 |
-
if len(buildable_lessons) >= 8:
|
| 325 |
-
max_feasible = 'unit'
|
| 326 |
-
else:
|
| 327 |
-
max_feasible = 'lesson'
|
| 328 |
-
else:
|
| 329 |
max_feasible = 'insufficient'
|
| 330 |
-
|
| 331 |
return {
|
| 332 |
'status': 'success',
|
| 333 |
'topic': topic,
|
| 334 |
-
'corpus_matches': len(content_analysis),
|
| 335 |
'corpus_percentage': corpus_percentage,
|
| 336 |
'max_feasible': max_feasible,
|
| 337 |
-
'
|
| 338 |
-
'
|
| 339 |
-
'
|
| 340 |
-
'
|
| 341 |
-
'
|
| 342 |
-
'standards_met': '70/30' if corpus_percentage >= 70 else '60/40' if corpus_percentage >= 60 else 'insufficient'
|
| 343 |
}
|
| 344 |
-
|
| 345 |
except Exception as e:
|
| 346 |
return {
|
| 347 |
-
'status': 'error',
|
| 348 |
'message': f"Analysis error: {str(e)}",
|
| 349 |
'corpus_percentage': 0,
|
| 350 |
'max_feasible': 'error'
|
| 351 |
}
|
| 352 |
|
| 353 |
-
def
|
| 354 |
-
"""
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
**Topic Generated From:** {topic}
|
| 388 |
-
**Corpus Coverage:** {analysis['corpus_percentage']:.1f}% | Standard: {analysis['standards_met']}
|
| 389 |
-
**Duration:** 5-8 minutes of complete content
|
| 390 |
-
**Generated:** {timestamp}
|
| 391 |
-
|
| 392 |
-
---
|
| 393 |
-
|
| 394 |
-
## 📊 Content Standards Verification
|
| 395 |
-
|
| 396 |
-
✅ **Meets {analysis['standards_met']} Standard**
|
| 397 |
-
- **Corpus Content:** {analysis['corpus_percentage']:.1f}%
|
| 398 |
-
- **AI Enhancement:** {100 - analysis['corpus_percentage']:.1f}%
|
| 399 |
-
- **Source Documents:** {len(analysis['source_documents'])} corpus documents
|
| 400 |
-
- **Evidence-Based:** All content supported by corpus evidence or academic research
|
| 401 |
-
|
| 402 |
-
---
|
| 403 |
-
|
| 404 |
-
## 🎯 Learning Objectives
|
| 405 |
-
|
| 406 |
-
By completing this lesson on **{lesson_topic}**, you will:
|
| 407 |
-
|
| 408 |
-
1. **Apply** evidence-based principles of {lesson_topic} in complex leadership scenarios
|
| 409 |
-
2. **Analyze** the impact of {lesson_topic} on team dynamics, performance, and organizational culture
|
| 410 |
-
3. **Integrate** {lesson_topic} strategies with your existing leadership competencies and style
|
| 411 |
-
4. **Evaluate** the effectiveness of different {lesson_topic} approaches across various contexts and situations
|
| 412 |
-
|
| 413 |
-
---
|
| 414 |
-
|
| 415 |
-
## 🧠 Opening Reflection & Personal Assessment (1 minute)
|
| 416 |
-
|
| 417 |
-
### Avatar Instructor Introduction
|
| 418 |
-
*"Welcome to this lesson on {lesson_topic}. I'm here to guide you through an evidence-based exploration of how this critical leadership capability can transform your effectiveness. Let's start with honest self-reflection."*
|
| 419 |
-
|
| 420 |
-
### Personal Leadership Assessment
|
| 421 |
-
**Current Confidence Scale:** Rate your current effectiveness with {lesson_topic} (1-10): ___
|
| 422 |
-
|
| 423 |
-
**Reflection Prompt:**
|
| 424 |
-
*Think of a recent leadership situation where {lesson_topic} was important. Take 30 seconds to consider:*
|
| 425 |
-
- What specific aspects went well?
|
| 426 |
-
- What challenges did you encounter?
|
| 427 |
-
- What would you approach differently if faced with the same situation again?
|
| 428 |
-
- How did {lesson_topic} (or lack thereof) impact the outcome?
|
| 429 |
-
|
| 430 |
-
**Write your reflection here:**
|
| 431 |
-
________________________________
|
| 432 |
-
________________________________
|
| 433 |
-
________________________________
|
| 434 |
-
|
| 435 |
-
### Avatar Instructor Transition
|
| 436 |
-
*"Your reflection provides the foundation for our learning journey. Keep these experiences in mind as we explore evidence-based strategies that can enhance your {lesson_topic} capabilities."*
|
| 437 |
-
|
| 438 |
-
---
|
| 439 |
-
|
| 440 |
-
## 📖 Evidence-Based Content Foundation: {lesson_topic} (3-4 minutes)
|
| 441 |
|
| 442 |
-
|
| 443 |
|
| 444 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 445 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 446 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 447 |
|
| 448 |
-
|
| 449 |
-
for i, content in enumerate(corpus_content, 1):
|
| 450 |
-
lesson += f"""
|
| 451 |
-
**💡 Corpus Insight {i}:** (Relevance: {content['score']:.3f})
|
| 452 |
-
*Source: {content['topic']} | Document ID: {content['id']}*
|
| 453 |
-
|
| 454 |
-
"{content['content'][:500]}{'...' if len(content['content']) > 500 else ''}"
|
| 455 |
-
|
| 456 |
-
**Avatar Instructor Note:** *"This insight from your corpus demonstrates {lesson_topic.lower()} in action. Notice how the specific strategies and outcomes connect to real leadership challenges you face."*
|
| 457 |
|
| 458 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 459 |
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
|
| 465 |
-
**
|
| 466 |
"""
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
{
|
| 476 |
-
|
| 477 |
-
**Avatar Instructor Note:** *"This research-based content fills gaps in your corpus coverage, providing academic validation for the practical insights from your materials."*
|
| 478 |
|
| 479 |
---
|
| 480 |
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
#
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
**Your Response:** ________________________________
|
| 490 |
-
|
| 491 |
-
**Avatar Instructor Follow-up:** *"Excellent. Notice how your lived experience provides context for the evidence-based strategies we're learning."*
|
| 492 |
-
|
| 493 |
-
**🧠 Question 2: Challenge Analysis**
|
| 494 |
-
*"What makes {lesson_topic} particularly difficult or complex in your current leadership context? What systemic or cultural factors create barriers to effective {lesson_topic}?"*
|
| 495 |
-
|
| 496 |
-
**Your Response:** ________________________________
|
| 497 |
-
|
| 498 |
-
**🧠 Question 3: Success Pattern Recognition**
|
| 499 |
-
*"Reflecting on times when you've been successful with {lesson_topic}, what specific factors contributed to that success? How can you systematically replicate those conditions?"*
|
| 500 |
-
|
| 501 |
-
**Your Response:** ________________________________
|
| 502 |
-
|
| 503 |
-
**🧠 Question 4: Growth Opportunity Identification**
|
| 504 |
-
*"If you could significantly improve one aspect of your {lesson_topic} capabilities, which would have the greatest impact on your leadership effectiveness? Why?"*
|
| 505 |
-
|
| 506 |
-
**Your Response:** ________________________________
|
| 507 |
-
|
| 508 |
-
**🧠 Question 5: Integration & Systems Thinking**
|
| 509 |
-
*"How does {lesson_topic} connect with and reinforce your other leadership strengths? Where might there be tensions between {lesson_topic} and other priorities you manage?"*
|
| 510 |
-
|
| 511 |
-
**Your Response:** ________________________________
|
| 512 |
-
|
| 513 |
-
**Avatar Instructor Transition:** *"These reflections provide the foundation for applying {lesson_topic} strategies. Now let's practice through gamified scenarios that simulate real leadership challenges."*
|
| 514 |
-
|
| 515 |
-
---
|
| 516 |
-
|
| 517 |
-
## 🎮 Complete Gamification Suite: {lesson_topic} (2-3 minutes)
|
| 518 |
-
|
| 519 |
-
### 🎯 Game 1: Strategic Leadership Challenge - Multi-Stakeholder {lesson_topic} Crisis (8 minutes)
|
| 520 |
-
|
| 521 |
-
**Avatar Instructor Setup:** *"You're about to lead your team through a complex situation where {lesson_topic} is critical to success. This scenario will test your ability to adapt {lesson_topic} strategies to different stakeholder needs while maintaining effectiveness under pressure."*
|
| 522 |
-
|
| 523 |
-
**🎬 Scenario Context:**
|
| 524 |
-
You're the Director of Operations leading a cross-functional team through a critical project. Multiple pressures are testing your {lesson_topic} capabilities:
|
| 525 |
-
|
| 526 |
-
- **Timeline Pressure:** Project deadline moved up 3 weeks due to market opportunity
|
| 527 |
-
- **Resource Constraints:** Budget reduced 20%, two key team members reassigned
|
| 528 |
-
- **Stakeholder Complexity:** Engineering, Marketing, and Sales have conflicting priorities
|
| 529 |
-
- **Performance Scrutiny:** CEO personally monitoring project success
|
| 530 |
-
- **Team Dynamics:** Mix of remote/in-office, varying experience levels, previous project failures affecting morale
|
| 531 |
-
|
| 532 |
-
**Round 1: Immediate {lesson_topic} Response** (Choose your approach)
|
| 533 |
-
|
| 534 |
-
**Avatar Instructor:** *"A crisis requires immediate action. Which {lesson_topic} approach will you take first?"*
|
| 535 |
-
|
| 536 |
-
**A)** Address {lesson_topic} challenges directly in emergency team meeting
|
| 537 |
-
- *Rationale: Transparency and collective problem-solving*
|
| 538 |
-
- *Risk: May overwhelm team or expose vulnerabilities publicly*
|
| 539 |
-
|
| 540 |
-
**B)** Handle {lesson_topic} through individual stakeholder conversations
|
| 541 |
-
- *Rationale: Customized approach to different needs and concerns*
|
| 542 |
-
- *Risk: May appear secretive or create inconsistent messaging*
|
| 543 |
-
|
| 544 |
-
**C)** Implement structured {lesson_topic} framework immediately
|
| 545 |
-
- *Rationale: Systematic approach ensures nothing is missed*
|
| 546 |
-
- *Risk: May feel rigid or slow in crisis situation*
|
| 547 |
-
|
| 548 |
-
**D)** Research best practices and consult mentors before action
|
| 549 |
-
- *Rationale: Evidence-based decision making*
|
| 550 |
-
- *Risk: Analysis paralysis while situation deteriorates*
|
| 551 |
-
|
| 552 |
-
**Your Choice:** ___ **Reasoning:** ________________________________
|
| 553 |
-
|
| 554 |
-
**Avatar Instructor Feedback:** *"Interesting choice. Now you'll see how stakeholders respond to your {lesson_topic} approach."*
|
| 555 |
-
|
| 556 |
-
**Round 2: Multi-Stakeholder {lesson_topic} Management**
|
| 557 |
-
|
| 558 |
-
Three critical stakeholders approach you with different {lesson_topic} perspectives:
|
| 559 |
-
|
| 560 |
-
**💼 Sarah Chen - Engineering Lead:**
|
| 561 |
-
*"Your {lesson_topic} approach isn't accounting for technical complexity. We need more time for quality work, not rushed solutions that will create technical debt."*
|
| 562 |
-
|
| 563 |
-
**📊 Marcus Williams - Sales Director:**
|
| 564 |
-
*"The market window is closing. Can you help my team understand how your {lesson_topic} strategy will accelerate delivery without compromising what customers need?"*
|
| 565 |
-
|
| 566 |
-
**👩💼 Dr. Lisa Rodriguez - CEO:**
|
| 567 |
-
*"I need you to prove that your {lesson_topic} approach will deliver results. Show me metrics and concrete outcomes, not just process improvements."*
|
| 568 |
-
|
| 569 |
-
**Avatar Instructor Challenge:** *"Design your response strategy for each stakeholder. Consider how {lesson_topic} principles apply differently to technical, commercial, and executive concerns."*
|
| 570 |
-
|
| 571 |
-
**Your Sarah Chen Response:** ________________________________
|
| 572 |
-
|
| 573 |
-
**Your Marcus Williams Response:** ________________________________
|
| 574 |
-
|
| 575 |
-
**Your Dr. Rodriguez Response:** ________________________________
|
| 576 |
-
|
| 577 |
-
**Round 3: Crisis Adaptation & Innovation**
|
| 578 |
-
|
| 579 |
-
**Avatar Instructor Escalation:** *"Midway through implementation, a major change forces complete strategy revision. Your {lesson_topic} approach must evolve rapidly."*
|
| 580 |
-
|
| 581 |
-
**🔥 Crisis Event:** Key technology platform fails, requiring manual processes for 2 weeks minimum. Your {lesson_topic} strategy must adapt while maintaining team confidence and stakeholder trust.
|
| 582 |
-
|
| 583 |
-
**Innovation Challenge:** Create a new {lesson_topic} approach that turns this obstacle into an opportunity for:
|
| 584 |
-
- Enhanced team resilience and problem-solving
|
| 585 |
-
- Stronger stakeholder relationships through crisis leadership
|
| 586 |
-
- Long-term competitive advantage through improved processes
|
| 587 |
-
|
| 588 |
-
**Your Crisis {lesson_topic} Strategy:**
|
| 589 |
-
1. **Immediate Actions (Today):** ________________________________
|
| 590 |
-
2. **Short-term Adaptations (This Week):** ________________________________
|
| 591 |
-
3. **Opportunity Creation (This Month):** ________________________________
|
| 592 |
-
|
| 593 |
-
**Avatar Instructor Debrief:** *"Excellent work navigating complexity. Notice how {lesson_topic} principles adapted to changing circumstances while maintaining core effectiveness."*
|
| 594 |
-
|
| 595 |
-
### 🃏 Game 2: Strategic Priority Matrix - {lesson_topic} Implementation Challenge (5 minutes)
|
| 596 |
-
|
| 597 |
-
**Avatar Instructor Introduction:** *"You're consulting with a leadership team that wants to improve their {lesson_topic} capabilities but has limited time and resources. Help them create a strategic implementation roadmap."*
|
| 598 |
-
|
| 599 |
-
**🎲 Implementation Elements for {lesson_topic}:**
|
| 600 |
-
|
| 601 |
-
**🔥 High-Impact Options:**
|
| 602 |
-
• Clear communication systems establishing {lesson_topic} expectations and feedback loops
|
| 603 |
-
• Leadership modeling of {lesson_topic} behaviors with consistent, visible demonstration
|
| 604 |
-
• Measurement and analytics systems tracking {lesson_topic} effectiveness and outcomes
|
| 605 |
-
• Cultural integration embedding {lesson_topic} principles into organizational values and recognition
|
| 606 |
-
• Strategic alignment ensuring {lesson_topic} initiatives support broader business objectives
|
| 607 |
-
|
| 608 |
-
**⚡ Medium-Impact Options:**
|
| 609 |
-
• Comprehensive training programs developing {lesson_topic} skills across all leadership levels
|
| 610 |
-
• Process optimization streamlining workflows to support effective {lesson_topic} implementation
|
| 611 |
-
• Technology tools and platforms enabling better {lesson_topic} practice and collaboration
|
| 612 |
-
• Cross-functional integration breaking down silos to enable {lesson_topic} collaboration
|
| 613 |
-
• External partnerships leveraging outside expertise for {lesson_topic} development and benchmarking
|
| 614 |
-
|
| 615 |
-
**🔧 Foundation Options:**
|
| 616 |
-
• Individual coaching providing personalized {lesson_topic} development for key leaders
|
| 617 |
-
• Team-building activities and experiences that build {lesson_topic} trust and cohesion
|
| 618 |
-
• Documentation and standardization creating clear guidelines for {lesson_topic} practices
|
| 619 |
-
• Recognition programs celebrating {lesson_topic} successes and learning from failures
|
| 620 |
-
• Regular feedback mechanisms gathering input on {lesson_topic} effectiveness and improvement
|
| 621 |
-
|
| 622 |
-
**Game Mechanics:**
|
| 623 |
-
|
| 624 |
-
**Phase 1: Strategic Prioritization** (3 points each)
|
| 625 |
-
Rank all 15 elements in order of implementation priority for {lesson_topic} development. Consider:
|
| 626 |
-
- **Speed of Impact:** Which changes improve {lesson_topic} fastest?
|
| 627 |
-
- **Resource Requirements:** What can be implemented with current capabilities?
|
| 628 |
-
- **Strategic Value:** Which elements create foundation for future {lesson_topic} growth?
|
| 629 |
-
- **Risk vs. Reward:** What offers best return on {lesson_topic} investment?
|
| 630 |
-
|
| 631 |
-
**Your Priority Ranking (1-15):**
|
| 632 |
-
High-Impact: ___, ___, ___, ___, ___
|
| 633 |
-
Medium-Impact: ___, ___, ___, ___, ___
|
| 634 |
-
Foundation: ___, ___, ___, ___, ___
|
| 635 |
-
|
| 636 |
-
**Phase 2: Implementation Matrix** (5 points)
|
| 637 |
-
Place your top 8 elements into strategic quadrants:
|
| 638 |
-
|
| 639 |
-
**🟢 Quick Wins (High Impact, Low Effort):**
|
| 640 |
-
1. _________________ 2. _________________
|
| 641 |
-
|
| 642 |
-
**🟡 Strategic Projects (High Impact, High Effort):**
|
| 643 |
-
1. _________________ 2. _________________
|
| 644 |
-
|
| 645 |
-
**🟠 Fill-In Projects (Low Impact, Low Effort):**
|
| 646 |
-
1. _________________ 2. _________________
|
| 647 |
-
|
| 648 |
-
**🔴 Questionable (Low Impact, High Effort):**
|
| 649 |
-
1. _________________ 2. _________________
|
| 650 |
-
|
| 651 |
-
**Phase 3: Timeline Development** (7 points)
|
| 652 |
-
Create 12-month {lesson_topic} implementation roadmap:
|
| 653 |
-
|
| 654 |
-
**Months 1-3 (Foundation Building):** ________________________________
|
| 655 |
-
|
| 656 |
-
**Months 4-6 (Momentum Creation):** ________________________________
|
| 657 |
-
|
| 658 |
-
**Months 7-9 (Strategic Initiatives):** ________________________________
|
| 659 |
-
|
| 660 |
-
**Months 10-12 (Integration & Evolution):** ________________________________
|
| 661 |
-
|
| 662 |
-
**Avatar Instructor Assessment:** *"Your prioritization shows strategic thinking about {lesson_topic} implementation. Notice how quick wins create momentum for larger transformations."*
|
| 663 |
-
|
| 664 |
-
### 🔗 Game 3: Dynamic Behavior-Outcome Mapping - {lesson_topic} Systems Challenge (5 minutes)
|
| 665 |
-
|
| 666 |
-
**Avatar Instructor Setup:** *"This game develops your systems thinking about {lesson_topic}. You'll map complex relationships between behaviors and outcomes, then design integrated strategies."*
|
| 667 |
-
|
| 668 |
-
**🎯 Level 1: Direct Behavior-Outcome Matching**
|
| 669 |
-
|
| 670 |
-
**{lesson_topic} Leadership Behaviors:**
|
| 671 |
-
1. **Consistent Communication:** Regular, transparent updates about {lesson_topic} expectations, progress, and challenges
|
| 672 |
-
2. **Vulnerability and Learning:** Leader openly shares {lesson_topic} mistakes, learning, and growth opportunities
|
| 673 |
-
3. **Inclusive Decision-Making:** Involving team members in {lesson_topic} choices that directly affect their work
|
| 674 |
-
4. **Recognition and Celebration:** Acknowledging both {lesson_topic} successes and meaningful learning attempts
|
| 675 |
-
5. **Development Investment:** Dedicated time and resources for growing team {lesson_topic} capabilities
|
| 676 |
-
|
| 677 |
-
**Match with Likely Outcomes:**
|
| 678 |
-
A. **Increased Psychological Safety:** Team feels safe to take {lesson_topic} risks and share concerns
|
| 679 |
-
B. **Enhanced Trust and Credibility:** Stronger stakeholder confidence in leadership {lesson_topic} decisions
|
| 680 |
-
C. **Improved Innovation and Creativity:** More breakthrough approaches and solutions using {lesson_topic}
|
| 681 |
-
D. **Better Performance and Results:** Measurable improvements in {lesson_topic} effectiveness metrics
|
| 682 |
-
E. **Sustained Culture Change:** {lesson_topic} behaviors continue even when leader isn't directly present
|
| 683 |
-
|
| 684 |
-
**Your Matching:**
|
| 685 |
-
1-___, 2-___, 3-___, 4-___, 5-___
|
| 686 |
-
|
| 687 |
-
**🎯 Level 2: Systems Integration Challenge**
|
| 688 |
-
|
| 689 |
-
**Avatar Instructor:** *"Now design reinforcing loops. How do these {lesson_topic} behaviors create positive cycles that strengthen each other?"*
|
| 690 |
|
| 691 |
-
|
| 692 |
-
Choose 3 behaviors and map how they reinforce each other:
|
| 693 |
|
| 694 |
-
**
|
| 695 |
-
**
|
| 696 |
-
**
|
| 697 |
-
**
|
| 698 |
|
| 699 |
-
**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 700 |
|
| 701 |
-
**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 702 |
|
| 703 |
-
**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 704 |
|
| 705 |
---
|
| 706 |
|
| 707 |
-
##
|
| 708 |
-
|
| 709 |
-
### Avatar Instructor Assessment Introduction
|
| 710 |
-
*"You've engaged deeply with {lesson_topic} through evidence, reflection, and practice. Now demonstrate your mastery through assessment pathways designed to match your learning goals and time availability."*
|
| 711 |
-
|
| 712 |
-
### 🏃♂️ Speed Mastery Certification (10 minutes)
|
| 713 |
-
**Avatar Instructor:** *"Quick application check for busy leaders who need immediate implementation guidance."*
|
| 714 |
-
|
| 715 |
-
1. **Evidence Integration:** What are 3 key evidence-based insights about {lesson_topic} from this lesson that challenge or confirm your previous assumptions?
|
| 716 |
-
|
| 717 |
-
**Your Response:** ________________________________
|
| 718 |
-
|
| 719 |
-
2. **Immediate Application:** Describe one current leadership challenge where you'll apply {lesson_topic} principles within the next 48 hours.
|
| 720 |
-
|
| 721 |
-
**Your Response:** ________________________________
|
| 722 |
-
|
| 723 |
-
3. **Behavioral Commitment:** What's one specific {lesson_topic} behavior you'll practice consistently this week?
|
| 724 |
-
|
| 725 |
-
**Your Response:** ________________________________
|
| 726 |
-
|
| 727 |
-
**Avatar Instructor Certification:** *"Your responses demonstrate understanding. You've earned Speed Mastery certification for {lesson_topic}."*
|
| 728 |
-
|
| 729 |
-
**Passing Standard:** Clear understanding + specific application plan + behavioral commitment
|
| 730 |
-
|
| 731 |
-
### 🎮 Complete Quest Mastery (20 minutes)
|
| 732 |
-
**Avatar Instructor:** *"Comprehensive engagement for leaders who want deep integration and implementation planning."*
|
| 733 |
-
|
| 734 |
-
**Quest Requirements:**
|
| 735 |
-
✓ Complete all 3 gamified activities with quality reflection and strategic thinking
|
| 736 |
-
✓ Answer all 5 Socratic questions with depth, connecting to personal experience
|
| 737 |
-
✓ Create detailed {lesson_topic} implementation plan with timeline and metrics
|
| 738 |
-
✓ Design approach to teach {lesson_topic} concepts to a colleague or team member
|
| 739 |
-
|
| 740 |
-
**Implementation Planning Template:**
|
| 741 |
-
|
| 742 |
-
**My {lesson_topic} Development Strategy:**
|
| 743 |
-
- **30-Day Goal:** ________________________________
|
| 744 |
-
- **Key Behaviors to Practice:** ________________________________
|
| 745 |
-
- **Success Metrics:** ________________________________
|
| 746 |
-
- **Support Resources Needed:** ________________________________
|
| 747 |
-
|
| 748 |
-
**Teaching Design Challenge:**
|
| 749 |
-
*How would you teach the most important {lesson_topic} insight to someone else?*
|
| 750 |
-
|
| 751 |
-
**Your Teaching Approach:** ________________________________
|
| 752 |
-
|
| 753 |
-
**Avatar Instructor Certification:** *"Outstanding comprehensive engagement. You've earned Complete Quest Mastery for {lesson_topic}."*
|
| 754 |
-
|
| 755 |
-
### 🏆 Innovation & Leadership Mastery Plus (30 minutes)
|
| 756 |
-
**Avatar Instructor:** *"Advanced certification for leaders who want to create value for others and drive organizational change."*
|
| 757 |
-
|
| 758 |
-
**Mastery Plus Requirements:**
|
| 759 |
-
- All Complete Quest elements PLUS:
|
| 760 |
-
- Create novel {lesson_topic} solution for your specific organizational context
|
| 761 |
-
- Design 5-minute {lesson_topic} lesson for colleagues using lesson insights
|
| 762 |
-
- Research and analyze one additional {lesson_topic} resource, comparing findings
|
| 763 |
-
- Plan comprehensive approach to develop {lesson_topic} capabilities in your team
|
| 764 |
-
|
| 765 |
-
**Innovation Challenge:**
|
| 766 |
-
*Design an original {lesson_topic} approach that addresses a specific challenge in your organization*
|
| 767 |
-
|
| 768 |
-
**Your Innovation:** ________________________________
|
| 769 |
-
|
| 770 |
-
**Leadership Development Plan:**
|
| 771 |
-
*How will you develop {lesson_topic} capabilities in others?*
|
| 772 |
-
|
| 773 |
-
**Your Plan:** ________________________________
|
| 774 |
-
|
| 775 |
-
**Avatar Instructor Certification:** *"Exceptional leadership thinking and innovation. You've earned Innovation & Leadership Mastery Plus for {lesson_topic}."*
|
| 776 |
|
| 777 |
-
|
| 778 |
|
| 779 |
-
**
|
| 780 |
-
**
|
| 781 |
-
**
|
| 782 |
-
**
|
| 783 |
|
| 784 |
---
|
| 785 |
|
| 786 |
-
##
|
| 787 |
-
|
| 788 |
-
### Avatar Instructor Final Integration
|
| 789 |
-
*"Let's consolidate your learning and create momentum for continued growth."*
|
| 790 |
-
|
| 791 |
-
### 🎯 Growth Tracking & Reflection
|
| 792 |
-
**Return to your opening assessment:**
|
| 793 |
-
- How has your understanding of {lesson_topic} evolved through this evidence-based lesson?
|
| 794 |
-
- What insights most surprised you or challenged your previous assumptions?
|
| 795 |
-
- On the 1-10 confidence scale, how would you rate your {lesson_topic} capabilities now? ___
|
| 796 |
-
|
| 797 |
-
### 🚀 Action Commitment & Implementation
|
| 798 |
-
**Avatar Instructor:** *"Learning without action is merely intellectual entertainment. Commit to specific implementation."*
|
| 799 |
-
|
| 800 |
-
**My {lesson_topic} Power Move:** What specific {lesson_topic} action will you take in the next 48 hours?
|
| 801 |
-
|
| 802 |
-
**Action:** ________________________________
|
| 803 |
-
**Context/Situation:** ________________________________
|
| 804 |
-
**Success Measure:** ________________________________
|
| 805 |
-
**Accountability Partner:** ________________________________
|
| 806 |
|
| 807 |
-
### 🔮 Future Learning Questions
|
| 808 |
-
**Avatar Instructor:** *"Curiosity drives continued growth. What questions will guide your ongoing {lesson_topic} development?"*
|
| 809 |
-
|
| 810 |
-
**Future Exploration:**
|
| 811 |
-
1. ________________________________
|
| 812 |
-
2. ________________________________
|
| 813 |
-
|
| 814 |
-
**Avatar Instructor Closing:** *"You've completed a comprehensive, evidence-based exploration of {lesson_topic}. Your corpus insights, combined with research validation and practical application, provide a solid foundation for leadership growth. Remember: mastery comes through consistent practice and reflection. You have the tools—now use them with intention and commitment."*
|
| 815 |
-
|
| 816 |
-
---
|
| 817 |
-
|
| 818 |
-
*Lesson Generated: {timestamp} | Corpus Standard: {analysis['standards_met']} | Full Content: ✅ | Avatar Integration: ✅*
|
| 819 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 820 |
|
| 821 |
-
|
| 822 |
-
lesson += generate_source_attribution_appendix(analysis, ai_enhancement, "lesson")
|
| 823 |
-
|
| 824 |
-
return lesson
|
| 825 |
-
|
| 826 |
-
def generate_source_attribution_appendix(analysis, ai_enhancement, content_type):
|
| 827 |
-
"""Generate comprehensive source attribution appendix"""
|
| 828 |
-
|
| 829 |
-
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M")
|
| 830 |
-
|
| 831 |
-
appendix = f"""
|
| 832 |
-
|
| 833 |
-
{'='*100}
|
| 834 |
-
# 📚 SOURCE ATTRIBUTION APPENDIX
|
| 835 |
-
{'='*100}
|
| 836 |
-
|
| 837 |
-
**Content Type:** {content_type.title()}
|
| 838 |
-
**Topic:** {analysis.get('topic', 'Leadership Development')}
|
| 839 |
-
**Attribution Generated:** {timestamp}
|
| 840 |
-
**Content Standards:** {analysis.get('standards_met', 'Standard')} (Corpus {analysis.get('corpus_percentage', 0):.1f}% / AI {100 - analysis.get('corpus_percentage', 0):.1f}%)
|
| 841 |
|
| 842 |
---
|
| 843 |
|
| 844 |
-
## 🎯 CORPUS SOURCE DOCUMENTATION
|
| 845 |
-
|
| 846 |
-
### Primary Source Documents from Your Leadership Corpus
|
| 847 |
-
|
| 848 |
-
**Total Corpus Documents Contributing:** {len(analysis.get('source_documents', {}))}
|
| 849 |
-
**Content Entries Analyzed:** {analysis.get('corpus_matches', 0)}
|
| 850 |
-
**Average Relevance Score:** {analysis.get('corpus_percentage', 0)/10:.3f}
|
| 851 |
-
|
| 852 |
"""
|
|
|
|
|
|
|
|
|
|
| 853 |
|
| 854 |
-
|
| 855 |
-
if analysis.get('source_documents'):
|
| 856 |
-
for doc_name, doc_entries in analysis['source_documents'].items():
|
| 857 |
-
if doc_entries:
|
| 858 |
-
top_score = max([entry['score'] for entry in doc_entries])
|
| 859 |
-
total_content = sum([entry['content_length'] for entry in doc_entries])
|
| 860 |
-
entry_count = len(doc_entries)
|
| 861 |
-
|
| 862 |
-
appendix += f"""
|
| 863 |
-
### 📄 {doc_name}
|
| 864 |
-
- **Document Type:** Corpus Source
|
| 865 |
-
- **Relevance Score:** {top_score:.3f} (0-1 scale)
|
| 866 |
-
- **Content Contributions:** {entry_count} individual entries
|
| 867 |
-
- **Total Content Used:** {total_content:,} characters
|
| 868 |
-
- **Contribution Level:** {'High' if top_score >= 0.4 else 'Moderate' if top_score >= 0.3 else 'Supporting'}
|
| 869 |
-
- **Usage Context:** {'Primary content source' if top_score >= 0.4 else 'Supporting evidence' if top_score >= 0.3 else 'Background validation'}
|
| 870 |
|
| 871 |
-
**
|
| 872 |
"""
|
| 873 |
-
|
| 874 |
-
|
| 875 |
-
|
| 876 |
-
|
| 877 |
-
|
| 878 |
-
|
| 879 |
-
appendix += "\n❌ **No Corpus Documents Contributed:** Insufficient corpus coverage for this topic\n"
|
| 880 |
-
|
| 881 |
-
appendix += f"""
|
| 882 |
-
|
| 883 |
-
### 📊 Corpus Utilization Analysis
|
| 884 |
-
|
| 885 |
-
**Content Quality Assessment:**
|
| 886 |
-
- **High Relevance Content (>0.4 score):** {len([c for c in analysis.get('content_analysis', []) if c['score'] > 0.4])} pieces
|
| 887 |
-
- **Medium Relevance Content (0.3-0.4):** {len([c for c in analysis.get('content_analysis', []) if 0.3 <= c['score'] <= 0.4])} pieces
|
| 888 |
-
- **Supporting Content (0.2-0.3):** {len([c for c in analysis.get('content_analysis', []) if 0.2 <= c['score'] < 0.3])} pieces
|
| 889 |
-
|
| 890 |
-
**Theme Integration:**
|
| 891 |
-
{f"Primary themes from corpus: {', '.join([theme for theme, score in analysis.get('themes', [])[:5]])}" if analysis.get('themes') else "Limited theme identification from corpus"}
|
| 892 |
-
|
| 893 |
-
**Content Authenticity:**
|
| 894 |
-
- **Corpus Authenticity Level:** {'High' if analysis.get('corpus_percentage', 0) >= 70 else 'Moderate' if analysis.get('corpus_percentage', 0) >= 60 else 'Limited'}
|
| 895 |
-
- **Personal Relevance:** Content aligned with themes and approaches in your leadership materials
|
| 896 |
-
- **Evidence Foundation:** Major concepts supported by corpus evidence or established research
|
| 897 |
|
| 898 |
---
|
| 899 |
|
| 900 |
-
##
|
| 901 |
|
| 902 |
-
###
|
| 903 |
|
| 904 |
-
**
|
| 905 |
-
**AI Role:** {'Minimal supplementation' if analysis.get('corpus_percentage', 0) >= 70 else 'Moderate gap filling' if analysis.get('corpus_percentage', 0) >= 60 else 'Significant content generation'}
|
| 906 |
|
| 907 |
-
|
| 908 |
-
|
| 909 |
-
# Document AI contributions with academic references
|
| 910 |
-
if ai_enhancement.get('content') and not ai_enhancement.get('error'):
|
| 911 |
-
appendix += f"""
|
| 912 |
-
### 📖 Academic References Provided by AI Enhancement
|
| 913 |
-
|
| 914 |
-
**Reference Quality:** {'High - Specific academic citations provided' if len(ai_enhancement.get('references', [])) >= 5 else 'Moderate - Some references provided' if ai_enhancement.get('references') else 'Limited - Manual verification required'}
|
| 915 |
-
|
| 916 |
-
**Specific Academic Sources Cited by ChatGPT:**
|
| 917 |
-
"""
|
| 918 |
-
|
| 919 |
-
if ai_enhancement.get('references'):
|
| 920 |
-
for i, ref in enumerate(ai_enhancement['references'][:10], 1): # Top 10 references
|
| 921 |
-
appendix += f"{i}. {ref}\n"
|
| 922 |
|
| 923 |
-
|
| 924 |
-
appendix += f"Plus {len(ai_enhancement['references'])-10} additional references in AI content\n"
|
| 925 |
-
else:
|
| 926 |
-
appendix += "❌ No specific academic references extracted from AI content\n❗ Manual verification required for all AI-generated claims\n"
|
| 927 |
|
| 928 |
-
|
| 929 |
|
| 930 |
-
|
| 931 |
|
| 932 |
-
**
|
| 933 |
-
- **Academic Claims:** All research citations require manual verification for accuracy
|
| 934 |
-
- **Statistical Data:** Numerical claims need source validation
|
| 935 |
-
- **Methodological Assertions:** Leadership frameworks require evidence confirmation
|
| 936 |
-
- **Best Practices:** Implementation recommendations need case study validation
|
| 937 |
-
|
| 938 |
-
**Verification Process:**
|
| 939 |
-
1. **Cross-Reference Citations:** Verify all academic sources exist and support claims
|
| 940 |
-
2. **Check Publication Details:** Confirm author names, publication years, and page numbers
|
| 941 |
-
3. **Validate Research Findings:** Ensure studies support the conclusions presented
|
| 942 |
-
4. **Assess Source Quality:** Evaluate credibility and relevance of cited research
|
| 943 |
-
5. **Update References:** Replace any invalid sources with verified alternatives
|
| 944 |
-
|
| 945 |
-
"""
|
| 946 |
-
else:
|
| 947 |
-
appendix += f"""
|
| 948 |
-
### ❌ Limited AI Enhancement Available
|
| 949 |
-
|
| 950 |
-
**AI Status:** {ai_enhancement.get('error', 'Content generation limited')}
|
| 951 |
-
**Impact:** Content relies more heavily on corpus sources and established leadership principles
|
| 952 |
-
**Recommendation:** Consider adding external research validation for enhanced academic rigor
|
| 953 |
-
"""
|
| 954 |
|
| 955 |
-
|
|
|
|
|
|
|
|
|
|
| 956 |
|
| 957 |
---
|
| 958 |
|
| 959 |
-
## ✅
|
| 960 |
|
| 961 |
-
|
|
|
|
|
|
|
|
|
|
| 962 |
|
| 963 |
-
**
|
| 964 |
-
|
| 965 |
-
|
| 966 |
-
|
| 967 |
-
✅ Theme analysis based on actual corpus content rather than assumptions
|
| 968 |
-
|
| 969 |
-
**AI Content Validation:**
|
| 970 |
-
{'✅ Academic references provided and listed for verification' if ai_enhancement.get('references') else '❌ Limited academic references - manual research required'}
|
| 971 |
-
{'✅ Reference extraction completed with systematic identification' if ai_enhancement.get('references') else '❌ Reference quality requires improvement'}
|
| 972 |
-
✅ AI contribution level clearly identified and separated from corpus content
|
| 973 |
-
✅ Verification requirements explicitly stated for all AI-generated claims
|
| 974 |
-
|
| 975 |
-
---
|
| 976 |
-
|
| 977 |
-
*Source Attribution Complete: {timestamp} | Corpus Sources: {len(analysis.get('source_documents', {}))} | AI References: {len(ai_enhancement.get('references', []))} | Verification: Required*
|
| 978 |
"""
|
| 979 |
-
|
| 980 |
-
return
|
| 981 |
-
|
| 982 |
-
#
|
| 983 |
-
def
|
| 984 |
-
|
| 985 |
-
|
| 986 |
-
|
| 987 |
-
|
| 988 |
-
|
| 989 |
-
|
| 990 |
-
|
| 991 |
-
|
| 992 |
-
🎮 **FULL GAMIFICATION:** All scenarios, card sorts, matching, role-plays completely written
|
| 993 |
-
📚 **SOURCE ATTRIBUTION:** Comprehensive appendix showing all corpus + AI sources
|
| 994 |
""")
|
| 995 |
-
|
| 996 |
-
with gr.
|
| 997 |
-
|
| 998 |
-
|
| 999 |
-
|
| 1000 |
-
|
| 1001 |
-
|
| 1002 |
-
)
|
| 1003 |
-
|
| 1004 |
-
gr.Markdown("### 🔍 Step 1: Content Sufficiency Analysis")
|
| 1005 |
-
|
| 1006 |
-
analyze_btn = gr.Button("📊 Analyze Corpus Sufficiency", variant="primary", size="lg")
|
| 1007 |
-
|
| 1008 |
-
gr.Markdown("### 🎮 Step 2: Generate Complete Content")
|
| 1009 |
-
|
| 1010 |
with gr.Row():
|
| 1011 |
-
|
| 1012 |
-
|
| 1013 |
-
|
| 1014 |
-
|
| 1015 |
-
|
| 1016 |
-
|
| 1017 |
-
|
| 1018 |
-
|
| 1019 |
-
|
| 1020 |
-
|
| 1021 |
-
|
| 1022 |
-
|
| 1023 |
-
|
| 1024 |
-
|
| 1025 |
-
|
| 1026 |
-
|
| 1027 |
-
|
| 1028 |
-
|
| 1029 |
-
|
| 1030 |
-
|
| 1031 |
-
|
| 1032 |
-
|
| 1033 |
-
|
| 1034 |
-
|
| 1035 |
-
|
| 1036 |
-
|
| 1037 |
-
|
| 1038 |
-
|
| 1039 |
-
|
| 1040 |
-
|
| 1041 |
-
|
| 1042 |
-
|
| 1043 |
-
|
| 1044 |
-
|
| 1045 |
-
|
| 1046 |
-
|
| 1047 |
-
|
| 1048 |
-
|
| 1049 |
-
|
| 1050 |
-
|
| 1051 |
-
|
| 1052 |
-
|
| 1053 |
-
|
| 1054 |
-
|
| 1055 |
-
|
| 1056 |
-
|
| 1057 |
-
|
| 1058 |
-
|
| 1059 |
-
|
| 1060 |
-
|
| 1061 |
-
|
| 1062 |
-
|
| 1063 |
-
{f"✅ **{analysis['max_feasible'].title()} Generation Supported**" if analysis['max_feasible'] != 'insufficient' else "❌ **Insufficient Content for Standards-Based Generation**"}
|
| 1064 |
-
|
| 1065 |
-
{"**Buildable Lesson Topics:**" if analysis['buildable_lessons'] else "**No Specific Lessons Identified**"}
|
| 1066 |
-
"""
|
| 1067 |
-
+ "\n".join([f"{i}. {lesson}" for i, lesson in enumerate(analysis['buildable_lessons'][:10], 1)]) +
|
| 1068 |
-
(f"\n...plus {len(analysis['buildable_lessons'])-10} additional lessons" if len(analysis['buildable_lessons']) > 10 else "") + f"""
|
| 1069 |
-
|
| 1070 |
-
---
|
| 1071 |
-
|
| 1072 |
-
## 📚 Corpus Content Analysis
|
| 1073 |
-
|
| 1074 |
-
**Source Documents Available:** {len(analysis['source_documents'])}
|
| 1075 |
-
**Content Matches Found:** {analysis['corpus_matches']}
|
| 1076 |
-
**Total Content Volume:** {analysis.get('total_content_length', 0):,} characters
|
| 1077 |
-
|
| 1078 |
-
**Primary Content Themes:**
|
| 1079 |
-
"""
|
| 1080 |
-
+ "\n".join([f"• {theme.replace('_', ' ').title()} (strength: {score:.2f})" for theme, score in analysis['themes'][:8]]) + f"""
|
| 1081 |
-
|
| 1082 |
-
---
|
| 1083 |
-
|
| 1084 |
-
## 🚀 Generation Recommendations
|
| 1085 |
-
|
| 1086 |
-
{"**✅ Proceed with Generation**" if analysis['max_feasible'] != 'insufficient' else "**❌ Cannot Generate with Current Standards**"}
|
| 1087 |
-
|
| 1088 |
-
{f"**Recommended Action:** Generate {analysis['max_feasible']} using available corpus content with {analysis['standards_met']} standard" if analysis['max_feasible'] != 'insufficient' else "**Required Action:** Add more corpus content for this topic to meet 60/40 minimum standard"}
|
| 1089 |
-
|
| 1090 |
-
**Content Quality:** {'High corpus authenticity with minimal AI supplementation' if analysis['standards_met'] == '70/30' else 'Good corpus foundation with moderate AI enhancement' if analysis['standards_met'] == '60/40' else 'Insufficient corpus coverage for quality generation'}
|
| 1091 |
-
|
| 1092 |
-
---
|
| 1093 |
-
|
| 1094 |
-
*Analysis Complete: {timestamp} | Standards: {analysis['standards_met']} | Feasible: {analysis['max_feasible']}*
|
| 1095 |
-
"""
|
| 1096 |
-
except Exception as e:
|
| 1097 |
-
return f"❌ Sufficiency analysis failed: {str(e)}\n\nPlease try again."
|
| 1098 |
-
|
| 1099 |
-
def generate_complete_lesson_safe(topic):
|
| 1100 |
-
if not topic.strip():
|
| 1101 |
-
return "❌ Please enter a leadership topic."
|
| 1102 |
-
try:
|
| 1103 |
-
return generate_complete_lesson(topic)
|
| 1104 |
-
except Exception as e:
|
| 1105 |
-
return f"❌ Complete lesson generation failed: {str(e)}\n\nPlease try again."
|
| 1106 |
-
|
| 1107 |
-
# Placeholder functions for unit and course (simplified for space)
|
| 1108 |
-
def generate_complete_unit_safe(topic):
|
| 1109 |
-
if not topic.strip():
|
| 1110 |
-
return "❌ Please enter a leadership topic."
|
| 1111 |
-
return "🚧 Complete unit generation - use lesson generation for now while full system is deployed."
|
| 1112 |
-
|
| 1113 |
-
def generate_complete_course_safe(topic):
|
| 1114 |
-
if not topic.strip():
|
| 1115 |
-
return "❌ Please enter a leadership topic."
|
| 1116 |
-
return "🚧 Complete course generation - use lesson generation for now while full system is deployed."
|
| 1117 |
-
|
| 1118 |
-
analyze_btn.click(fn=analyze_sufficiency_safe, inputs=topic_input, outputs=output_display)
|
| 1119 |
-
lesson_btn.click(fn=generate_complete_lesson_safe, inputs=topic_input, outputs=output_display)
|
| 1120 |
-
unit_btn.click(fn=generate_complete_unit_safe, inputs=topic_input, outputs=output_display)
|
| 1121 |
-
course_btn.click(fn=generate_complete_course_safe, inputs=topic_input, outputs=output_display)
|
| 1122 |
-
|
| 1123 |
-
gr.Markdown("""
|
| 1124 |
-
---
|
| 1125 |
-
**🧠 COMPLETE INTELLIGENT GENERATION:**
|
| 1126 |
-
• **70/30 Standards:** Preferred corpus/AI ratio with 60/40 fallback
|
| 1127 |
-
• **Complete Content:** All lessons fully written with Socratic method + full gamification
|
| 1128 |
-
• **Source Attribution:** Comprehensive appendix with corpus + AI reference documentation
|
| 1129 |
-
• **Academic Rigor:** AI references provided for manual verification
|
| 1130 |
-
• **No Summaries:** Every lesson, unit, and course completely developed
|
| 1131 |
-
|
| 1132 |
-
**🎯 Generates only what your corpus can support with complete transparency!**
|
| 1133 |
""")
|
|
|
|
|
|
|
| 1134 |
|
| 1135 |
-
|
| 1136 |
-
|
| 1137 |
if __name__ == "__main__":
|
| 1138 |
-
|
| 1139 |
-
|
|
|
|
| 18 |
def safe_load_resources():
|
| 19 |
"""Safely load resources with error handling"""
|
| 20 |
global dataset, model
|
| 21 |
+
|
| 22 |
try:
|
| 23 |
if dataset is None:
|
| 24 |
+
print("Loading resources...")
|
| 25 |
from datasets import load_dataset
|
| 26 |
from sentence_transformers import SentenceTransformer
|
| 27 |
+
|
| 28 |
dataset = load_dataset("PhillyMac/Leadership_Corpus")['train']
|
| 29 |
model = SentenceTransformer('all-MiniLM-L6-v2')
|
| 30 |
+
print(f"✅ Loaded {len(dataset)} leadership insights")
|
| 31 |
+
|
| 32 |
return dataset, model, None
|
| 33 |
+
|
| 34 |
except Exception as e:
|
| 35 |
error_msg = f"Resource loading error: {str(e)}"
|
| 36 |
print(error_msg)
|
| 37 |
return None, None, error_msg
|
| 38 |
|
| 39 |
+
def extract_real_topics_from_corpus(search_term, max_topics=20):
|
| 40 |
+
"""Extract actual leadership topics from corpus content"""
|
| 41 |
+
|
| 42 |
try:
|
| 43 |
+
dataset, model, error = safe_load_resources()
|
| 44 |
+
if error:
|
| 45 |
+
return []
|
| 46 |
+
|
| 47 |
+
# Search for content related to the term
|
| 48 |
+
search_embedding = model.encode([search_term])
|
| 49 |
+
sample_size = min(2000, len(dataset))
|
| 50 |
+
indices = np.random.choice(len(dataset), sample_size, replace=False)
|
| 51 |
+
|
| 52 |
+
content_texts = [dataset[int(idx)]['content'] for idx in indices]
|
| 53 |
+
content_embeddings = model.encode(content_texts)
|
| 54 |
+
|
| 55 |
+
similarities = cosine_similarity(search_embedding, content_embeddings)[0]
|
| 56 |
+
|
| 57 |
+
# Get highly relevant content
|
| 58 |
+
relevant_indices = indices[similarities > 0.3]
|
| 59 |
+
relevant_content = [dataset[int(idx)]['content'] for idx in relevant_indices]
|
| 60 |
+
|
| 61 |
+
# Extract actual topics using NLP patterns
|
| 62 |
+
topics = set()
|
| 63 |
+
|
| 64 |
+
# Common leadership topic patterns
|
| 65 |
+
topic_patterns = [
|
| 66 |
+
r'\b([A-Z][a-z]+ [Ll]eadership)\b', # "Strategic Leadership", "Transformational Leadership"
|
| 67 |
+
r'\b([A-Z][a-z]+ [Mm]anagement)\b', # "Change Management", "Performance Management"
|
| 68 |
+
r'\b([A-Z][a-z]+ [Ss]kills?)\b', # "Communication Skills", "Negotiation Skills"
|
| 69 |
+
r'\b([A-Z][a-z]+ [Dd]evelopment)\b', # "Team Development", "Leadership Development"
|
| 70 |
+
r'\b([A-Z][a-z]+ [Ii]ntelligence)\b', # "Emotional Intelligence"
|
| 71 |
+
r'\b([A-Z][a-z]+ [Bb]uilding)\b', # "Team Building", "Trust Building"
|
| 72 |
+
r'\b([A-Z][a-z]+ [Rr]esolution)\b', # "Conflict Resolution"
|
| 73 |
+
r'\bLeading ([A-Z][a-z]+)\b', # "Leading Change", "Leading Teams"
|
| 74 |
+
r'\bManaging ([A-Z][a-z]+)\b', # "Managing Conflict", "Managing Performance"
|
| 75 |
+
]
|
| 76 |
+
|
| 77 |
+
for content in relevant_content:
|
| 78 |
+
for pattern in topic_patterns:
|
| 79 |
+
matches = re.findall(pattern, content)
|
| 80 |
+
for match in matches:
|
| 81 |
+
if isinstance(match, tuple):
|
| 82 |
+
topic = ' '.join(match)
|
| 83 |
+
else:
|
| 84 |
+
topic = match
|
| 85 |
+
|
| 86 |
+
# Clean up and validate topic
|
| 87 |
+
topic = topic.strip()
|
| 88 |
+
if len(topic.split()) <= 4 and len(topic) > 5: # Reasonable length
|
| 89 |
+
topics.add(topic)
|
| 90 |
+
|
| 91 |
+
# Also extract key concepts that appear frequently
|
| 92 |
+
concept_words = []
|
| 93 |
+
for content in relevant_content:
|
| 94 |
+
words = re.findall(r'\b[A-Z][a-z]{4,}\b', content) # Capitalized words 5+ letters
|
| 95 |
+
concept_words.extend(words)
|
| 96 |
+
|
| 97 |
+
# Find most common concepts
|
| 98 |
+
word_counts = Counter(concept_words)
|
| 99 |
+
common_concepts = [word for word, count in word_counts.most_common(50) if count >= 3]
|
| 100 |
+
|
| 101 |
+
# Create topics from common concepts
|
| 102 |
+
leadership_contexts = [
|
| 103 |
+
"Leadership", "Management", "Development", "Skills", "Strategy",
|
| 104 |
+
"Communication", "Team Building", "Decision Making", "Innovation"
|
| 105 |
+
]
|
| 106 |
+
|
| 107 |
+
for concept in common_concepts:
|
| 108 |
+
for context in leadership_contexts:
|
| 109 |
+
potential_topic = f"{concept} {context}"
|
| 110 |
+
if len(potential_topic) < 50: # Reasonable length
|
| 111 |
+
topics.add(potential_topic)
|
| 112 |
+
|
| 113 |
+
# Convert to list and sort by relevance (you could enhance this)
|
| 114 |
+
topic_list = list(topics)[:max_topics]
|
| 115 |
+
|
| 116 |
+
return topic_list
|
| 117 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
except Exception as e:
|
| 119 |
+
print(f"Topic extraction error: {str(e)}")
|
| 120 |
+
return []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
|
| 122 |
+
def analyze_content_sufficiency(topic):
|
| 123 |
+
"""Analyze if corpus has sufficient content for different generation levels"""
|
| 124 |
+
|
| 125 |
try:
|
| 126 |
dataset, model, error = safe_load_resources()
|
| 127 |
if error:
|
|
|
|
| 129 |
'status': 'error',
|
| 130 |
'message': error,
|
| 131 |
'corpus_percentage': 0,
|
| 132 |
+
'max_feasible': 'none',
|
| 133 |
+
'buildable_content': []
|
| 134 |
}
|
| 135 |
+
|
| 136 |
+
print(f"🔍 Analyzing content sufficiency for: {topic}")
|
| 137 |
+
|
| 138 |
+
# Search corpus for topic-related content
|
| 139 |
topic_embedding = model.encode([topic])
|
| 140 |
sample_size = min(1500, len(dataset))
|
| 141 |
indices = np.random.choice(len(dataset), sample_size, replace=False)
|
| 142 |
+
|
| 143 |
content_texts = [dataset[int(idx)]['content'] for idx in indices]
|
| 144 |
content_embeddings = model.encode(content_texts)
|
| 145 |
+
|
| 146 |
similarities = cosine_similarity(topic_embedding, content_embeddings)[0]
|
| 147 |
+
|
| 148 |
+
# Classify content by relevance
|
| 149 |
+
high_relevance = similarities > 0.4 # Strong matches - can build lessons
|
| 150 |
+
medium_relevance = similarities > 0.3 # Good matches - can contribute
|
| 151 |
+
low_relevance = similarities > 0.2 # Acceptable - background info
|
| 152 |
+
|
| 153 |
high_count = np.sum(high_relevance)
|
| 154 |
medium_count = np.sum(medium_relevance) - high_count
|
| 155 |
low_count = np.sum(low_relevance) - medium_count - high_count
|
| 156 |
+
|
| 157 |
+
# Get actual content for analysis
|
|
|
|
|
|
|
| 158 |
relevant_indices = indices[similarities > 0.2]
|
| 159 |
+
relevant_content = []
|
| 160 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
for i, idx in enumerate(relevant_indices):
|
| 162 |
+
actual_idx = int(idx)
|
| 163 |
+
content = dataset[actual_idx]['content']
|
| 164 |
+
score = similarities[similarities > 0.2][i]
|
| 165 |
+
|
| 166 |
try:
|
|
|
|
|
|
|
| 167 |
metadata = json.loads(dataset[actual_idx]['metadata'])
|
| 168 |
source_topic = metadata.get('topic', 'Leadership')
|
| 169 |
+
except:
|
| 170 |
+
source_topic = 'Leadership'
|
| 171 |
+
|
| 172 |
+
relevant_content.append({
|
| 173 |
+
'content': content,
|
| 174 |
+
'score': float(score),
|
| 175 |
+
'source_topic': source_topic,
|
| 176 |
+
'length': len(content)
|
| 177 |
+
})
|
| 178 |
+
|
| 179 |
+
# Sort by relevance
|
| 180 |
+
relevant_content.sort(key=lambda x: x['score'], reverse=True)
|
| 181 |
+
|
| 182 |
+
# Calculate corpus percentage
|
| 183 |
+
total_relevant = high_count + medium_count + low_count
|
| 184 |
+
content_depth = sum(item['length'] for item in relevant_content[:10])
|
| 185 |
+
|
| 186 |
+
# Scoring factors
|
| 187 |
+
relevance_score = (high_count * 3 + medium_count * 2 + low_count) / 50 # Max 50 points
|
| 188 |
+
depth_score = min(content_depth / 10000, 30) # Max 30 points for depth
|
| 189 |
+
coverage_score = min(total_relevant / 20, 20) # Max 20 points for coverage
|
| 190 |
+
|
| 191 |
+
corpus_percentage = min(100, relevance_score + depth_score + coverage_score)
|
| 192 |
+
|
| 193 |
+
# Determine what can be built
|
| 194 |
+
buildable_content = []
|
| 195 |
+
|
| 196 |
+
if corpus_percentage >= 70: # Strong corpus coverage
|
| 197 |
+
if high_count >= 8:
|
| 198 |
+
buildable_content.append({
|
| 199 |
+
'type': 'course',
|
| 200 |
+
'title': f"Comprehensive {topic} Leadership Course",
|
| 201 |
+
'corpus_support': f"{corpus_percentage:.1f}%",
|
| 202 |
+
'ai_needed': f"{100-corpus_percentage:.1f}%"
|
| 203 |
})
|
| 204 |
+
|
| 205 |
+
if high_count >= 4:
|
| 206 |
+
buildable_content.append({
|
| 207 |
+
'type': 'unit',
|
| 208 |
+
'title': f"Strategic {topic} Leadership Unit",
|
| 209 |
+
'corpus_support': f"{corpus_percentage:.1f}%",
|
| 210 |
+
'ai_needed': f"{100-corpus_percentage:.1f}%"
|
|
|
|
|
|
|
|
|
|
| 211 |
})
|
| 212 |
+
|
| 213 |
+
buildable_content.append({
|
| 214 |
+
'type': 'lesson',
|
| 215 |
+
'title': f"Essential {topic} Leadership Principles",
|
| 216 |
+
'corpus_support': f"{corpus_percentage:.1f}%",
|
| 217 |
+
'ai_needed': f"{100-corpus_percentage:.1f}%"
|
| 218 |
+
})
|
| 219 |
+
|
| 220 |
+
max_feasible = 'course' if high_count >= 8 else 'unit' if high_count >= 4 else 'lesson'
|
| 221 |
+
|
| 222 |
+
elif corpus_percentage >= 50: # Moderate coverage
|
| 223 |
+
buildable_content.append({
|
| 224 |
+
'type': 'lesson',
|
| 225 |
+
'title': f"Foundational {topic} Leadership Concepts",
|
| 226 |
+
'corpus_support': f"{corpus_percentage:.1f}%",
|
| 227 |
+
'ai_needed': f"{100-corpus_percentage:.1f}%"
|
| 228 |
+
})
|
| 229 |
+
max_feasible = 'lesson'
|
| 230 |
+
|
| 231 |
+
else: # Insufficient coverage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
max_feasible = 'insufficient'
|
| 233 |
+
|
| 234 |
return {
|
| 235 |
'status': 'success',
|
| 236 |
'topic': topic,
|
|
|
|
| 237 |
'corpus_percentage': corpus_percentage,
|
| 238 |
'max_feasible': max_feasible,
|
| 239 |
+
'buildable_content': buildable_content,
|
| 240 |
+
'content_samples': relevant_content[:5], # Top 5 most relevant
|
| 241 |
+
'high_relevance_count': int(high_count),
|
| 242 |
+
'medium_relevance_count': int(medium_count),
|
| 243 |
+
'total_relevant_documents': len(relevant_content)
|
|
|
|
| 244 |
}
|
| 245 |
+
|
| 246 |
except Exception as e:
|
| 247 |
return {
|
| 248 |
+
'status': 'error',
|
| 249 |
'message': f"Analysis error: {str(e)}",
|
| 250 |
'corpus_percentage': 0,
|
| 251 |
'max_feasible': 'error'
|
| 252 |
}
|
| 253 |
|
| 254 |
+
def get_chatgpt_enhancement(topic, content_type, corpus_percentage, gap_description):
|
| 255 |
+
"""Get ChatGPT content to fill gaps in corpus coverage"""
|
| 256 |
+
|
| 257 |
+
try:
|
| 258 |
+
import openai
|
| 259 |
+
api_key = os.getenv("OPENAI_API_KEY")
|
| 260 |
+
|
| 261 |
+
if not api_key:
|
| 262 |
+
return {
|
| 263 |
+
'enhanced_content': f"AI enhancement unavailable for {topic}. Proceeding with {corpus_percentage:.1f}% corpus content.",
|
| 264 |
+
'gap_areas': ["AI enhancement not available"],
|
| 265 |
+
'references': ["ChatGPT unavailable - using corpus content only"]
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
openai.api_key = api_key
|
| 269 |
+
|
| 270 |
+
prompt = f"""You are creating {content_type} content for "{topic}" leadership development.
|
| 271 |
+
|
| 272 |
+
CONTEXT:
|
| 273 |
+
- Corpus provides {corpus_percentage:.1f}% coverage
|
| 274 |
+
- Need to fill {100-corpus_percentage:.1f}% gap
|
| 275 |
+
- Gap areas: {gap_description}
|
| 276 |
+
|
| 277 |
+
Create content that:
|
| 278 |
+
1. Complements existing corpus knowledge (don't duplicate)
|
| 279 |
+
2. Fills specific gaps in {topic} coverage
|
| 280 |
+
3. Provides practical, actionable strategies
|
| 281 |
+
4. Includes real-world examples and case studies
|
| 282 |
+
|
| 283 |
+
Format your response with:
|
| 284 |
+
- Clear, specific strategies for {topic}
|
| 285 |
+
- Implementation frameworks
|
| 286 |
+
- Common challenges and solutions
|
| 287 |
+
- Success metrics
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
|
| 289 |
+
CRITICAL: Provide specific citations and references for all claims."""
|
| 290 |
|
| 291 |
+
response = openai.ChatCompletion.create(
|
| 292 |
+
model="gpt-4",
|
| 293 |
+
messages=[
|
| 294 |
+
{"role": "system", "content": "You are an expert leadership development specialist with extensive research background."},
|
| 295 |
+
{"role": "user", "content": prompt}
|
| 296 |
+
],
|
| 297 |
+
max_tokens=1200,
|
| 298 |
+
temperature=0.3
|
| 299 |
+
)
|
| 300 |
+
|
| 301 |
+
content = response.choices[0].message.content
|
| 302 |
+
|
| 303 |
+
# Extract references (simplified)
|
| 304 |
+
references = re.findall(r'\([A-Za-z]+.*?\d{4}\)', content)
|
| 305 |
+
if not references:
|
| 306 |
+
references = ["AI-generated content - manual verification of sources recommended"]
|
| 307 |
+
|
| 308 |
+
return {
|
| 309 |
+
'enhanced_content': content,
|
| 310 |
+
'gap_areas': [gap_description],
|
| 311 |
+
'references': references
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
except Exception as e:
|
| 315 |
+
return {
|
| 316 |
+
'enhanced_content': f"AI enhancement error: {str(e)}",
|
| 317 |
+
'gap_areas': [f"Error: {str(e)}"],
|
| 318 |
+
'references': [f"Enhancement failed: {str(e)}"]
|
| 319 |
+
}
|
| 320 |
|
| 321 |
+
def generate_content_analysis_interface(search_term):
|
| 322 |
+
"""Main interface function for content analysis"""
|
| 323 |
+
|
| 324 |
+
if not search_term or len(search_term.strip()) < 3:
|
| 325 |
+
return "⚠️ Please enter a search term (at least 3 characters)"
|
| 326 |
+
|
| 327 |
+
try:
|
| 328 |
+
# Extract real topics from corpus
|
| 329 |
+
print(f"🔍 Extracting topics related to: {search_term}")
|
| 330 |
+
real_topics = extract_real_topics_from_corpus(search_term, max_topics=15)
|
| 331 |
+
|
| 332 |
+
if not real_topics:
|
| 333 |
+
return f"❌ No relevant topics found in corpus for '{search_term}'. Try broader terms like 'leadership', 'management', or 'communication'."
|
| 334 |
+
|
| 335 |
+
# Analyze top 5 topics for buildability
|
| 336 |
+
analysis_results = []
|
| 337 |
+
for i, topic in enumerate(real_topics[:5]):
|
| 338 |
+
analysis = analyze_content_sufficiency(topic)
|
| 339 |
+
if analysis['status'] == 'success':
|
| 340 |
+
analysis_results.append(analysis)
|
| 341 |
+
|
| 342 |
+
# Format results
|
| 343 |
+
output = f"""# 📊 INTELLIGENT CONTENT ANALYSIS: "{search_term}"
|
| 344 |
+
|
| 345 |
+
## 🎯 Available Topics from Your Corpus
|
| 346 |
+
|
| 347 |
+
**Found {len(real_topics)} relevant topics:**
|
| 348 |
"""
|
| 349 |
+
|
| 350 |
+
for i, topic in enumerate(real_topics[:10], 1):
|
| 351 |
+
output += f"{i}. {topic}\n"
|
| 352 |
+
|
| 353 |
+
if len(real_topics) > 10:
|
| 354 |
+
output += f"... and {len(real_topics)-10} more topics\n"
|
| 355 |
+
|
| 356 |
+
output += f"""
|
| 357 |
|
| 358 |
+
## 🔍 BUILDABILITY ANALYSIS (Top 5 Topics)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 359 |
|
| 360 |
"""
|
| 361 |
+
|
| 362 |
+
for analysis in analysis_results:
|
| 363 |
+
topic = analysis['topic']
|
| 364 |
+
corpus_pct = analysis['corpus_percentage']
|
| 365 |
+
max_level = analysis['max_feasible']
|
| 366 |
+
|
| 367 |
+
# Status emoji
|
| 368 |
+
if max_level == 'course':
|
| 369 |
+
status_emoji = "🏆"
|
| 370 |
+
elif max_level == 'unit':
|
| 371 |
+
status_emoji = "🎯"
|
| 372 |
+
elif max_level == 'lesson':
|
| 373 |
+
status_emoji = "📚"
|
| 374 |
+
else:
|
| 375 |
+
status_emoji = "❌"
|
| 376 |
+
|
| 377 |
+
output += f"""### {status_emoji} **{topic}**
|
| 378 |
|
| 379 |
+
**Corpus Coverage:** {corpus_pct:.1f}%
|
| 380 |
+
**Maximum Buildable:** {max_level.title()}
|
| 381 |
+
**AI Enhancement Needed:** {100-corpus_pct:.1f}%
|
| 382 |
+
**Supporting Documents:** {analysis['total_relevant_documents']} documents
|
| 383 |
|
| 384 |
+
**What Can Be Built:**
|
| 385 |
"""
|
| 386 |
+
|
| 387 |
+
for buildable in analysis['buildable_content']:
|
| 388 |
+
output += f"- **{buildable['type'].title()}:** {buildable['title']} (Corpus: {buildable['corpus_support']}, AI: {buildable['ai_needed']})\n"
|
| 389 |
+
|
| 390 |
+
if analysis['content_samples']:
|
| 391 |
+
output += f"""
|
| 392 |
+
**Sample Content Preview:**
|
| 393 |
+
"{analysis['content_samples'][0]['content'][:200]}..."
|
| 394 |
+
*(Relevance: {analysis['content_samples'][0]['score']:.3f})*
|
|
|
|
|
|
|
| 395 |
|
| 396 |
---
|
| 397 |
|
| 398 |
+
"""
|
| 399 |
+
|
| 400 |
+
# Add summary recommendations
|
| 401 |
+
best_analysis = max(analysis_results, key=lambda x: x['corpus_percentage']) if analysis_results else None
|
| 402 |
+
|
| 403 |
+
if best_analysis:
|
| 404 |
+
output += f"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 405 |
|
| 406 |
+
## 🎯 RECOMMENDATION
|
|
|
|
| 407 |
|
| 408 |
+
**Best Topic for Generation:** {best_analysis['topic']}
|
| 409 |
+
- **Corpus Coverage:** {best_analysis['corpus_percentage']:.1f}%
|
| 410 |
+
- **Recommended Build:** {best_analysis['max_feasible'].title()}
|
| 411 |
+
- **Quality Level:** {'Excellent' if best_analysis['corpus_percentage'] >= 70 else 'Good' if best_analysis['corpus_percentage'] >= 50 else 'Basic'}
|
| 412 |
|
| 413 |
+
**Next Step:** Use this topic to generate actual content with the lesson/unit/course builder.
|
| 414 |
+
"""
|
| 415 |
+
|
| 416 |
+
return output
|
| 417 |
+
|
| 418 |
+
except Exception as e:
|
| 419 |
+
return f"❌ Analysis error: {str(e)}\n\nPlease try again with a different search term."
|
| 420 |
+
|
| 421 |
+
def generate_actual_lesson(topic):
|
| 422 |
+
"""Generate actual lesson content using the topic analysis"""
|
| 423 |
+
|
| 424 |
+
# First analyze the topic
|
| 425 |
+
analysis = analyze_content_sufficiency(topic)
|
| 426 |
+
|
| 427 |
+
if analysis['status'] == 'error':
|
| 428 |
+
return f"❌ Cannot generate lesson: {analysis['message']}"
|
| 429 |
+
|
| 430 |
+
if analysis['max_feasible'] == 'insufficient':
|
| 431 |
+
return f"""❌ Insufficient Content for "{topic}"
|
| 432 |
|
| 433 |
+
**Analysis Results:**
|
| 434 |
+
- Corpus coverage: {analysis['corpus_percentage']:.1f}%
|
| 435 |
+
- Required minimum: 50% for lesson generation
|
| 436 |
+
- Supporting documents: {analysis.get('total_relevant_documents', 0)}
|
| 437 |
+
|
| 438 |
+
**Recommendation:** Try a broader topic or add more content to your corpus."""
|
| 439 |
+
|
| 440 |
+
# Get enhancement content if needed
|
| 441 |
+
gap_percentage = 100 - analysis['corpus_percentage']
|
| 442 |
+
enhancement = get_chatgpt_enhancement(
|
| 443 |
+
topic,
|
| 444 |
+
"lesson",
|
| 445 |
+
analysis['corpus_percentage'],
|
| 446 |
+
f"Fill {gap_percentage:.1f}% content gap for comprehensive {topic} lesson"
|
| 447 |
+
)
|
| 448 |
+
|
| 449 |
+
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M")
|
| 450 |
+
|
| 451 |
+
lesson_content = f"""# 🎯 COMPLETE LESSON: {topic}
|
| 452 |
|
| 453 |
+
**Generated:** {timestamp}
|
| 454 |
+
**Content Source Analysis:**
|
| 455 |
+
- 📚 Corpus Content: {analysis['corpus_percentage']:.1f}%
|
| 456 |
+
- 🤖 AI Enhancement: {100-analysis['corpus_percentage']:.1f}%
|
| 457 |
+
- 📊 Supporting Documents: {analysis['total_relevant_documents']} relevant documents
|
| 458 |
+
- ✅ Quality Standard: {'70/30' if analysis['corpus_percentage'] >= 70 else '60/40' if analysis['corpus_percentage'] >= 60 else '50/50'}
|
| 459 |
|
| 460 |
---
|
| 461 |
|
| 462 |
+
## 🎯 Learning Objectives
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 463 |
|
| 464 |
+
By the end of this lesson on **{topic}**, you will:
|
| 465 |
|
| 466 |
+
1. **Understand** the core principles and frameworks of {topic} in leadership contexts
|
| 467 |
+
2. **Apply** evidence-based {topic} strategies to real-world leadership challenges
|
| 468 |
+
3. **Analyze** the impact of {topic} on team performance and organizational outcomes
|
| 469 |
+
4. **Evaluate** different approaches to {topic} for various leadership scenarios
|
| 470 |
|
| 471 |
---
|
| 472 |
|
| 473 |
+
## 📚 Foundation Knowledge (From Your Leadership Corpus)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 474 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 475 |
"""
|
| 476 |
+
|
| 477 |
+
# Add corpus content
|
| 478 |
+
if analysis['content_samples']:
|
| 479 |
+
lesson_content += "**Key Insights from Your Corpus:**\n\n"
|
| 480 |
+
|
| 481 |
+
for i, sample in enumerate(analysis['content_samples'][:3], 1):
|
| 482 |
+
lesson_content += f"""**Insight {i}** (Relevance: {sample['score']:.3f})
|
| 483 |
+
*Source: {sample['source_topic']}*
|
| 484 |
|
| 485 |
+
"{sample['content'][:400]}{'...' if len(sample['content']) > 400 else ''}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 486 |
|
| 487 |
---
|
| 488 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 489 |
"""
|
| 490 |
+
|
| 491 |
+
# Add AI enhancement
|
| 492 |
+
lesson_content += f"""## 🤖 Enhanced Understanding
|
| 493 |
|
| 494 |
+
{enhancement['enhanced_content']}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 495 |
|
| 496 |
+
**References:**
|
| 497 |
"""
|
| 498 |
+
|
| 499 |
+
for ref in enhancement['references'][:5]:
|
| 500 |
+
lesson_content += f"- {ref}\n"
|
| 501 |
+
|
| 502 |
+
# Add interactive elements
|
| 503 |
+
lesson_content += f"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 504 |
|
| 505 |
---
|
| 506 |
|
| 507 |
+
## 🎮 Interactive Application
|
| 508 |
|
| 509 |
+
### 🤔 Reflection Questions
|
| 510 |
|
| 511 |
+
1. **Personal Experience:** Describe a situation where {topic} was critical to your leadership success or failure. What specific elements made the difference?
|
|
|
|
| 512 |
|
| 513 |
+
2. **Challenge Analysis:** What barriers in your current environment make {topic} difficult to implement effectively?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 514 |
|
| 515 |
+
3. **Implementation Planning:** Based on the evidence presented, what 2-3 specific actions will you take to improve your {topic} capabilities?
|
|
|
|
|
|
|
|
|
|
| 516 |
|
| 517 |
+
### 🎯 Practical Exercise
|
| 518 |
|
| 519 |
+
**Scenario:** You're leading a team through a complex project where {topic} is essential for success.
|
| 520 |
|
| 521 |
+
**Your Challenge:** Design a specific action plan that incorporates the {topic} principles covered in this lesson.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 522 |
|
| 523 |
+
**Consider:**
|
| 524 |
+
- How will you measure the effectiveness of your {topic} approach?
|
| 525 |
+
- What potential obstacles might you encounter?
|
| 526 |
+
- How will you adapt your {topic} strategy based on team feedback?
|
| 527 |
|
| 528 |
---
|
| 529 |
|
| 530 |
+
## ✅ Lesson Complete
|
| 531 |
|
| 532 |
+
**Next Steps:**
|
| 533 |
+
- Practice the {topic} techniques in your current leadership role
|
| 534 |
+
- Observe how {topic} impacts your team dynamics and results
|
| 535 |
+
- Consider taking the full unit or course on {topic} for deeper development
|
| 536 |
|
| 537 |
+
**Content Sources Utilized:**
|
| 538 |
+
- Corpus documents: {analysis['total_relevant_documents']}
|
| 539 |
+
- AI enhancement: {'Yes' if enhancement['enhanced_content'] else 'No'}
|
| 540 |
+
- Quality standard met: {'✅' if analysis['corpus_percentage'] >= 50 else '❌'}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 541 |
"""
|
| 542 |
+
|
| 543 |
+
return lesson_content
|
| 544 |
+
|
| 545 |
+
# Gradio Interface
|
| 546 |
+
def create_interface():
|
| 547 |
+
|
| 548 |
+
with gr.Blocks(title="🧠 Intelligent Course Generator", theme=gr.themes.Soft()) as interface:
|
| 549 |
+
|
| 550 |
+
gr.HTML("""
|
| 551 |
+
<div style='text-align: center; padding: 20px;'>
|
| 552 |
+
<h1>🧠 Intelligent Course Generator</h1>
|
| 553 |
+
<p><strong>Analyzes your corpus → Identifies buildable topics → Generates real content</strong></p>
|
| 554 |
+
</div>
|
|
|
|
|
|
|
| 555 |
""")
|
| 556 |
+
|
| 557 |
+
with gr.Tabs():
|
| 558 |
+
|
| 559 |
+
# Content Analysis Tab
|
| 560 |
+
with gr.TabItem("📊 Content Analysis"):
|
| 561 |
+
gr.HTML("<h3>Step 1: Analyze What You Can Build</h3>")
|
| 562 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 563 |
with gr.Row():
|
| 564 |
+
analysis_input = gr.Textbox(
|
| 565 |
+
label="🔍 Search Term",
|
| 566 |
+
placeholder="Enter topic area (e.g., 'communication', 'leadership', 'conflict')",
|
| 567 |
+
lines=1
|
| 568 |
+
)
|
| 569 |
+
analyze_btn = gr.Button("🔍 Analyze Content", variant="primary")
|
| 570 |
+
|
| 571 |
+
analysis_output = gr.Markdown(label="Analysis Results")
|
| 572 |
+
analyze_btn.click(generate_content_analysis_interface, analysis_input, analysis_output)
|
| 573 |
+
|
| 574 |
+
# Lesson Generator Tab
|
| 575 |
+
with gr.TabItem("📚 Lesson Generator"):
|
| 576 |
+
gr.HTML("<h3>Step 2: Generate Actual Lesson Content</h3>")
|
| 577 |
+
|
| 578 |
+
with gr.Row():
|
| 579 |
+
lesson_topic = gr.Textbox(
|
| 580 |
+
label="🎯 Specific Topic",
|
| 581 |
+
placeholder="Enter the exact topic from analysis (e.g., 'Strategic Communication')",
|
| 582 |
+
lines=1
|
| 583 |
+
)
|
| 584 |
+
generate_lesson_btn = gr.Button("📚 Generate Complete Lesson", variant="primary")
|
| 585 |
+
|
| 586 |
+
lesson_output = gr.Markdown(label="Complete Lesson Content")
|
| 587 |
+
generate_lesson_btn.click(generate_actual_lesson, lesson_topic, lesson_output)
|
| 588 |
+
|
| 589 |
+
# Quick Generator Tab
|
| 590 |
+
with gr.TabItem("⚡ Quick Generate"):
|
| 591 |
+
gr.HTML("<h3>Direct Generation (Skip Analysis)</h3>")
|
| 592 |
+
|
| 593 |
+
with gr.Row():
|
| 594 |
+
quick_topic = gr.Textbox(
|
| 595 |
+
label="🎯 Topic",
|
| 596 |
+
placeholder="Enter any leadership topic",
|
| 597 |
+
lines=1
|
| 598 |
+
)
|
| 599 |
+
quick_generate_btn = gr.Button("⚡ Generate Now", variant="secondary")
|
| 600 |
+
|
| 601 |
+
quick_output = gr.Markdown(label="Generated Content")
|
| 602 |
+
quick_generate_btn.click(generate_actual_lesson, quick_topic, quick_output)
|
| 603 |
+
|
| 604 |
+
gr.HTML("""
|
| 605 |
+
<div style='margin-top: 30px; padding: 15px; background-color: #f0f0f0; border-radius: 10px;'>
|
| 606 |
+
<h4>🔍 How This Works:</h4>
|
| 607 |
+
<ol>
|
| 608 |
+
<li><strong>Content Analysis:</strong> Searches your corpus for relevant topics</li>
|
| 609 |
+
<li><strong>Sufficiency Check:</strong> Determines what can be built with your content</li>
|
| 610 |
+
<li><strong>Gap Identification:</strong> Shows what needs AI enhancement</li>
|
| 611 |
+
<li><strong>Real Content Generation:</strong> Creates actual lessons using your topics</li>
|
| 612 |
+
</ol>
|
| 613 |
+
<p><strong>Result:</strong> Real, complete lessons on actual topics from your corpus - not generic "micro lessons"!</p>
|
| 614 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 615 |
""")
|
| 616 |
+
|
| 617 |
+
return interface
|
| 618 |
|
| 619 |
+
# Launch the interface
|
|
|
|
| 620 |
if __name__ == "__main__":
|
| 621 |
+
interface = create_interface()
|
| 622 |
+
interface.launch(share=True, server_name="0.0.0.0", server_port=7860)
|
requirements.txt
CHANGED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
gradio==4.44.0
|
| 2 |
-
datasets==2.
|
| 3 |
-
sentence-transformers==2.
|
| 4 |
-
scikit-learn==1.
|
| 5 |
-
numpy==1.
|
| 6 |
openai==0.28.1
|
| 7 |
-
|
|
|
|
|
|
|
|
|
| 1 |
gradio==4.44.0
|
| 2 |
+
datasets==2.20.0
|
| 3 |
+
sentence-transformers==2.7.0
|
| 4 |
+
scikit-learn==1.5.1
|
| 5 |
+
numpy==1.26.4
|
| 6 |
openai==0.28.1
|
| 7 |
+
huggingface-hub==0.24.0
|
| 8 |
+
transformers==4.44.0
|
| 9 |
+
torch==2.3.1
|