Spaces:
Sleeping
Sleeping
Update LessonPlan.py
Browse files- LessonPlan.py +70 -69
LessonPlan.py
CHANGED
|
@@ -1,69 +1,70 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import openai
|
| 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 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
st.
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
|
|
|
|
|
| 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.")
|