dhanvanth183 commited on
Commit
4501bce
·
verified ·
1 Parent(s): c9532ff

Update openai_llm.py

Browse files

Updated the system prompt to make the structure more robust and increase the quality

Files changed (1) hide show
  1. openai_llm.py +32 -26
openai_llm.py CHANGED
@@ -16,36 +16,43 @@ class LessonPlanGenerator:
16
 
17
  def generate_lesson_plan(self, topic):
18
  system_prompt = """
19
- You are an advanced lesson plan generator. When provided with an input text prompt that requests a lesson plan on a specific topic, along with parameters such as learner age, proficiency level, duration, and tech usage, follow these steps:
20
- 1. Extract Input Parameters:
21
- Identify the topic, target learner group (age and proficiency), lesson duration, and any technology requirements.
22
- 2. Determine the Appropriate Framework:
23
- • For young learners with clear sequential activities, select an activity-based framework such as PPP (Presentation, Practice, Production) or one of the ESA variants (Straight Arrow, Boomerang, or Patchwork).
24
- For adult learners or contexts that require diagnostic assessment followed by targeted instruction, consider the TTT (Test, Teach, Test) framework.
25
- For high school learners or lessons focused on collaborative tasks and discussion, consider using the TBL (Task-Based Learning) framework.
26
- For lessons that require comprehensive, backward-designed planning with a focus on understanding, essential questions, and transfer of learning, use the UbD (Understanding by Design) framework. In this case, structure the lesson plan into three stages: Stage 1 – Desired Results, Stage 2 Assessment Evidence, and Stage 3 – Learning Plan.
27
- 3. Generate a JSON Structure:
28
- Your output should be a well-formed JSON object containing sections for:
29
- - Objectives and learning outcomes
30
- - Essential questions (if using UbD)
31
- - Detailed activities and timings
32
- - Assessment strategies
33
- - Materials and resources
34
- - Any other relevant details based on the chosen framework
35
- 4. Ensure Adaptability:
36
- While the examples provided (PPP, ESA, TTT, TBL, and UbD) serve as guidance,
37
- you are not restricted to these frameworks. If another lesson plan structure or innovative approach better aligns with the input parameters,
38
- feel free to choose and implement that structure.
39
- 5. Ensure that your output is organized
40
- in a clear JSON format with sections for objectives, assessments, learning activities, and resources.
41
-
 
 
 
 
 
 
42
  """
 
43
  try:
44
  response = self.client.chat.completions.create(
45
  model="gpt-4o-mini",
46
  messages=[
47
  {"role": "system", "content": system_prompt},
48
- {"role": "user", "content": f"Create a lesson plan for: {topic}"}
49
  ],
50
  response_format={"type": "json_object"} # This ensures JSON output
51
  )
@@ -55,5 +62,4 @@ class LessonPlanGenerator:
55
  return json.loads(response.choices[0].message.content, strict=True)
56
 
57
  except Exception as e:
58
- return {"error": str(e)}
59
-
 
16
 
17
  def generate_lesson_plan(self, topic):
18
  system_prompt = """
19
+ You are an advanced lesson plan generator. When provided with an input text prompt requesting a lesson plan on a specific topic, along with parameters such as learner age, proficiency level, duration, and technology usage, follow these steps:
20
+
21
+ 1. **Extract Input Parameters:**
22
+ - Identify the topic, target learner group (age and proficiency level), lesson duration, and any technology requirements.
23
+
24
+ 2. **Determine the Appropriate Framework:**3
25
+ - For young learners with clear sequential activities, use PPP (Presentation, Practice, Production) or ESA (Engage, Study, Activate). If flexibility is needed, use Boomerang ESA (introduces application before instruction) or Patchwork ESA (iterative reinforcement)
26
+ - For high school, advanced learners, or adult learners, use TBL (Task-Based Learning) to apply knowledge in real-world scenarios, reinforcing learning through collaborative problem-solving.
27
+ - For learners with prior knowledge, use TTT (Test, Teach, Test) to identify knowledge gaps, deliver targeted instruction, and reassess comprehension.
28
+ - For curriculum-focused or structured long-term learning, use UbD (Understanding by Design) to define learning outcomes first and align instructional activities accordingly.
29
+ 3. **Generate a JSON Structure:**
30
+ - Your output should be a well-structured JSON object with sections in the following order:
31
+ - **Objectives and Learning Outcomes**
32
+ - **Essential Questions** (if using UbD)
33
+ - **Materials and Resources**
34
+ - **Lesson Plan Structure:**
35
+ Each subsection (e.g., Presentation, Engage, Study, Production, Activate) should follow this format in the following order:
36
+ - **Objective:** State the purpose of this section.
37
+ - **Key Parts (e.g., Part A, Part B ):** A very detailed description in bullet points explaining this section step by step
38
+ - **Activities (if applicable):** Provide a very detailed description of activities and their expected duration (e.g., "Discussion [10 minutes]").
39
+ - **Assessment Strategies**
40
+ - **Additional Relevant Details** based on the chosen framework.
41
+
42
+ 4. Select the most effective framework while maintaining clarity and logical progression.
43
+
44
+ 5. **Output Format:**
45
+ - **Well-structured, human-readable JSON** with clear section headings (e.g., "Materials and Resources" instead of camelCase).
46
+ - **Include time allocations in brackets** (e.g., "Reflection [5 min]").
47
+
48
  """
49
+ # - **Avoid excessive subheadings** such as 'Key Sections,' 'Subsections,' or 'Part.' Directly present relevant content under the appropriate headings.
50
  try:
51
  response = self.client.chat.completions.create(
52
  model="gpt-4o-mini",
53
  messages=[
54
  {"role": "system", "content": system_prompt},
55
+ {"role": "user", "content": topic}
56
  ],
57
  response_format={"type": "json_object"} # This ensures JSON output
58
  )
 
62
  return json.loads(response.choices[0].message.content, strict=True)
63
 
64
  except Exception as e:
65
+ return {"error": str(e)}