MujtabaAhmed commited on
Commit
218bf53
·
verified ·
1 Parent(s): 1c265ea

Update LessonPlan.py

Browse files
Files changed (1) hide show
  1. LessonPlan.py +70 -69
LessonPlan.py CHANGED
@@ -1,69 +1,70 @@
1
- import streamlit as st
2
- import openai
3
-
4
- # Set up OpenAI API key
5
- openai.api_key = "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"
6
-
7
- def generate_lesson_plan(unit_details, session_duration, num_sessions):
8
- prompt = f"""
9
- Unit Details:
10
- {unit_details}
11
-
12
- Session Duration: {session_duration} hours
13
- Number of Sessions: {num_sessions}
14
-
15
- The lesson plan should include:
16
- 1. Learning objectives
17
- 2. Lesson activities and descriptions
18
- 3. Teaching strategies to increase student engagement
19
- 4. Assessment methods
20
- 5. Estimated time for each section
21
- 6. A reference URL from YouTube for the topic of that specific session
22
- 7. Cross-verify the URLs being provided by you to ensure they are valid and working
23
-
24
- For each session, provide a relevant and engaging YouTube video that aligns with the topic and learning objectives. Ensure that the video is of high quality, up-to-date, and appropriate for the target audience.
25
-
26
- After generating the lesson plan, please double-check all the YouTube URLs to confirm they are working and accessible. If any URLs are broken or unavailable, replace them with alternative working links that cover the same topic.
27
-
28
- The lesson plan should be well-structured, easy to follow, and include engaging and relevant YouTube resources to enhance the learning experience.
29
- """
30
-
31
- response = openai.chat.completions.create(
32
- model="gpt-3.5-turbo",
33
- messages=[
34
- {"role": "user", "content": prompt}
35
- ],
36
- max_tokens=2048,
37
- temperature=0.7,
38
- )
39
-
40
- lesson_plan = response.choices[0].message.content
41
- return lesson_plan
42
-
43
-
44
- def get_motivational_content():
45
- prompt = "Give a motivational quote for a teacher who is nervous for presentation"
46
- response = openai.chat.completions.create(
47
- model="gpt-3.5-turbo",
48
- messages=[
49
- {"role": "user", "content": prompt}
50
- ]
51
- )
52
- return response.choices[0].message.content
53
-
54
- def lessonplan():
55
- # st.title("Lesson Plan Generator")
56
-
57
- unit_details = st.text_area("Provide details about the unit you want to teach:", height=200)
58
- session_duration = st.number_input("Enter the duration of each session (in hours):", min_value=1, step=1)
59
- num_sessions = st.number_input("Enter the number of sessions to complete the topic:", min_value=1, step=1)
60
-
61
- if st.button("Generate Lesson Plan"):
62
- if unit_details and session_duration and num_sessions:
63
- lesson_plan = generate_lesson_plan(unit_details, session_duration, num_sessions)
64
- st.header("Lesson Plan")
65
- st.write(lesson_plan)
66
- motivation = get_motivational_content()
67
- st.success(motivation)
68
- else:
69
- st.warning("Please provide all the required information.")
 
 
1
+ import streamlit as st
2
+ import openai
3
+ import os
4
+
5
+ # Set up OpenAI API key
6
+ openai.api_key = os.environ['key']
7
+
8
+ def generate_lesson_plan(unit_details, session_duration, num_sessions):
9
+ prompt = f"""
10
+ Unit Details:
11
+ {unit_details}
12
+
13
+ Session Duration: {session_duration} hours
14
+ Number of Sessions: {num_sessions}
15
+
16
+ The lesson plan should include:
17
+ 1. Learning objectives
18
+ 2. Lesson activities and descriptions
19
+ 3. Teaching strategies to increase student engagement
20
+ 4. Assessment methods
21
+ 5. Estimated time for each section
22
+ 6. A reference URL from YouTube for the topic of that specific session
23
+ 7. Cross-verify the URLs being provided by you to ensure they are valid and working
24
+
25
+ For each session, provide a relevant and engaging YouTube video that aligns with the topic and learning objectives. Ensure that the video is of high quality, up-to-date, and appropriate for the target audience.
26
+
27
+ After generating the lesson plan, please double-check all the YouTube URLs to confirm they are working and accessible. If any URLs are broken or unavailable, replace them with alternative working links that cover the same topic.
28
+
29
+ The lesson plan should be well-structured, easy to follow, and include engaging and relevant YouTube resources to enhance the learning experience.
30
+ """
31
+
32
+ response = openai.chat.completions.create(
33
+ model="gpt-3.5-turbo",
34
+ messages=[
35
+ {"role": "user", "content": prompt}
36
+ ],
37
+ max_tokens=2048,
38
+ temperature=0.7,
39
+ )
40
+
41
+ lesson_plan = response.choices[0].message.content
42
+ return lesson_plan
43
+
44
+
45
+ def get_motivational_content():
46
+ prompt = "Give a motivational quote for a teacher who is nervous for presentation"
47
+ response = openai.chat.completions.create(
48
+ model="gpt-3.5-turbo",
49
+ messages=[
50
+ {"role": "user", "content": prompt}
51
+ ]
52
+ )
53
+ return response.choices[0].message.content
54
+
55
+ def lessonplan():
56
+ # st.title("Lesson Plan Generator")
57
+
58
+ unit_details = st.text_area("Provide details about the unit you want to teach:", height=200)
59
+ session_duration = st.number_input("Enter the duration of each session (in hours):", min_value=1, step=1)
60
+ num_sessions = st.number_input("Enter the number of sessions to complete the topic:", min_value=1, step=1)
61
+
62
+ if st.button("Generate Lesson Plan"):
63
+ if unit_details and session_duration and num_sessions:
64
+ lesson_plan = generate_lesson_plan(unit_details, session_duration, num_sessions)
65
+ st.header("Lesson Plan")
66
+ st.write(lesson_plan)
67
+ motivation = get_motivational_content()
68
+ st.success(motivation)
69
+ else:
70
+ st.warning("Please provide all the required information.")