dhanvanth183 commited on
Commit
b93db26
·
verified ·
1 Parent(s): 36ed9a4

Update openai_llm.py

Browse files

Updated system prompt in llms to generate output in language given by user, added more details on generating materials for activities.

Files changed (1) hide show
  1. openai_llm.py +22 -7
openai_llm.py CHANGED
@@ -14,9 +14,9 @@ class LessonPlanGenerator:
14
  # System prompt for lesson plan generation
15
 
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.
@@ -30,12 +30,27 @@ class LessonPlanGenerator:
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
 
@@ -52,9 +67,9 @@ class LessonPlanGenerator:
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
  )
59
 
60
  # If you want to strictly parse the response
@@ -62,4 +77,4 @@ class LessonPlanGenerator:
62
  return json.loads(response.choices[0].message.content, strict=True)
63
 
64
  except Exception as e:
65
- return {"error": str(e)}
 
14
  # System prompt for lesson plan generation
15
 
16
 
17
+ def generate_lesson_plan(self, topic=None, language="English"):
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, language to generate the text 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.
 
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 [DO NOT mention External platforms (e.g., Kahoot, Quizlet)]**
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
+ - **Material (if applicable):** If the activity requires instructional materials provided by the instructor, generate the actual content needed for the activity. This content should be formatted in a **structured, machine-readable format** (such as a dictionary, list, or array) based on the nature of the activity. For example:
40
+ - If the activity involves matching numbers to translations, generate a dictionary or list of the items involved, like this:
41
+ ```json
42
+ {
43
+ "1": "un",
44
+ "2": "deux",
45
+ "3": "trois",
46
+ "4": "quatre",
47
+ "5": "cinq",
48
+ ...
49
+ }
50
+ ```
51
+ - If the activity involves reading a passage, provide the passage as text.
52
+ - If the activity requires images or objects, describe those resources clearly (without mentioning external platforms).
53
+ _ If the activity does not require instructional material IGNORE Material Subsection in it.
54
  - **Assessment Strategies**
55
  - **Additional Relevant Details** based on the chosen framework.
56
 
 
67
  model="gpt-4o-mini",
68
  messages=[
69
  {"role": "system", "content": system_prompt},
70
+ {"role": "user", "content": f"{topic} completely in {language} language including section names"}
71
  ],
72
+ response_format={"type": "json_object"}
73
  )
74
 
75
  # If you want to strictly parse the response
 
77
  return json.loads(response.choices[0].message.content, strict=True)
78
 
79
  except Exception as e:
80
+ return {"error": str(e)}