File size: 2,331 Bytes
3e88289
d2ebfdc
3e88289
 
d21a8df
 
 
 
3e88289
d21a8df
 
 
d2ebfdc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d21a8df
 
3e88289
 
 
 
d2ebfdc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3e88289
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import json
import openai

class TopicAgent:
    def __init__(self, api_key=None):
        if api_key:
            openai.api_key = api_key
    
    def generate_outline(self, topic, duration, difficulty):
        if not openai.api_key:
            return self._mock_outline(topic, duration, difficulty)
            
        try:
            response = openai.ChatCompletion.create(
                model="gpt-4",
                messages=[
                    {"role": "system", "content": "You're an expert corporate trainer creating AI workshop outlines"},
                    {"role": "user", "content": (
                        f"Create a {duration}-hour {difficulty} workshop outline on {topic}. "
                        "Include: 1) Key learning goals, 2) 4 modules with titles and durations, "
                        "3) Hands-on exercises per module. Output as JSON."
                    )}
                ]
            )
            return json.loads(response.choices[0].message.content)
        except:
            return self._mock_outline(topic, duration, difficulty)
    
    def _mock_outline(self, topic, duration, difficulty):
        return {
            "topic": topic,
            "duration": f"{duration} hours",
            "difficulty": difficulty,
            "goals": [
                f"Master advanced {topic} techniques",
                "Develop industry-specific applications",
                "Build and evaluate complex AI workflows",
                "Implement best practices for production"
            ],
            "modules": [
                {
                    "title": f"Fundamentals of {topic}",
                    "duration": "30 min",
                    "learning_points": [
                        "Core principles and terminology",
                        "Patterns and anti-patterns",
                        "Evaluation frameworks"
                    ]
                },
                {
                    "title": f"{topic} for Enterprise Applications",
                    "duration": "45 min",
                    "learning_points": [
                        "Industry-specific use cases",
                        "Integration with existing systems",
                        "Scalability considerations"
                    ]
                }
            ]
        }