mgbam commited on
Commit
d21a8df
·
verified ·
1 Parent(s): d74244d

Create agents/topic_agent.py

Browse files
Files changed (1) hide show
  1. agents/topic_agent.py +25 -29
agents/topic_agent.py CHANGED
@@ -1,38 +1,34 @@
1
- # File: agents/topic_agent.py
 
2
  import json
3
 
4
  class TopicAgent:
 
 
 
 
5
  def generate_outline(self, topic, duration, difficulty):
6
- # In production: Replace with actual LLM API call
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  return {
8
  "topic": topic,
9
  "duration": f"{duration} hours",
10
  "difficulty": difficulty,
11
- "goals": [
12
- f"Master advanced {topic} techniques",
13
- "Develop industry-specific applications",
14
- "Build and evaluate complex AI workflows",
15
- "Implement best practices for production"
16
- ],
17
- "modules": [
18
- {
19
- "title": f"Fundamentals of {topic}",
20
- "duration": "30 min",
21
- "learning_points": [
22
- "Core principles and terminology",
23
- "Patterns and anti-patterns",
24
- "Evaluation frameworks"
25
- ]
26
- },
27
- {
28
- "title": f"{topic} for Enterprise Applications",
29
- "duration": "45 min",
30
- "learning_points": [
31
- "Industry-specific use cases",
32
- "Integration with existing systems",
33
- "Scalability considerations"
34
- ]
35
- }
36
- # Additional modules would be generated here
37
- ]
38
  }
 
1
+ # agents/topic_agent.py
2
+ import openai
3
  import json
4
 
5
  class TopicAgent:
6
+ def __init__(self, api_key=None):
7
+ if api_key:
8
+ openai.api_key = api_key
9
+
10
  def generate_outline(self, topic, duration, difficulty):
11
+ if not openai.api_key:
12
+ return self._mock_outline(topic, duration, difficulty)
13
+
14
+ response = openai.ChatCompletion.create(
15
+ model="gpt-4",
16
+ messages=[
17
+ {"role": "system", "content": "You're an expert corporate trainer creating AI workshop outlines"},
18
+ {"role": "user", "content": (
19
+ f"Create a {duration}-hour {difficulty} workshop outline on {topic}. "
20
+ "Include: 1) Key learning goals, 2) 4 modules with titles and durations, "
21
+ "3) Hands-on exercises per module. Output as JSON."
22
+ )}
23
+ ]
24
+ )
25
+ return json.loads(response.choices[0].message.content)
26
+
27
+ def _mock_outline(self, topic, duration, difficulty):
28
  return {
29
  "topic": topic,
30
  "duration": f"{duration} hours",
31
  "difficulty": difficulty,
32
+ "goals": ["Goal 1", "Goal 2"],
33
+ "modules": [{"title": "Module 1", "duration": "30 min"}]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  }