Spaces:
Runtime error
Runtime error
Commit ·
e2bb6f4
1
Parent(s): eac2def
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import openai
|
| 3 |
+
|
| 4 |
+
openai.api_key = "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"
|
| 5 |
+
|
| 6 |
+
st.title("A.I, Lesson Plan Generator by Amaan")
|
| 7 |
+
|
| 8 |
+
age = st.number_input("Enter learner's age",min_value=6,max_value=80,step=1)
|
| 9 |
+
|
| 10 |
+
subject = st.text_area("Enter the subject")
|
| 11 |
+
|
| 12 |
+
topic = st.text_area("Enter the topic of your Subject")
|
| 13 |
+
|
| 14 |
+
complexity_levels = ["Beginner",'Intermediate','Advanced','Expert','Master']
|
| 15 |
+
complexity = st.selectbox("Select the complexity", complexity_levels)
|
| 16 |
+
|
| 17 |
+
duration = ['1 hour','1 week','1 month','6 month']
|
| 18 |
+
|
| 19 |
+
plan_duration = st.selectbox("Choose your duration", duration)
|
| 20 |
+
|
| 21 |
+
if st.button("Generate lesson plan"):
|
| 22 |
+
prompt = f"You are tasked to produce an detailed lesson plan for teaching {subject} on the topic {topic} and to age {age} year old student, The lesson plan should be designed for {plan_duration}"
|
| 23 |
+
|
| 24 |
+
response = openai.Completion.create(
|
| 25 |
+
engine = "text-davinci-003",
|
| 26 |
+
prompt = prompt,
|
| 27 |
+
max_tokens = 1500,
|
| 28 |
+
temperature = 0.7,
|
| 29 |
+
n = 1,
|
| 30 |
+
stop = None
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
lesson_plan = response.choices[0].text.strip()
|
| 34 |
+
st.subheader("Generated lesson plan: ")
|
| 35 |
+
|
| 36 |
+
st.write(lesson_plan)
|
| 37 |
+
|
| 38 |
+
|