raymondEDS commited on
Commit
1221662
·
1 Parent(s): 37c06b2

Initial commit with API key

Browse files
Files changed (9) hide show
  1. .gitattributes +0 -35
  2. .gitignore +36 -0
  3. README.md +52 -0
  4. app.py +133 -0
  5. gpt_method.py +157 -0
  6. prompts_en.py +532 -0
  7. requirements.txt +7 -3
  8. src/streamlit_app.py +0 -40
  9. test_gemini.py +84 -0
.gitattributes DELETED
@@ -1,35 +0,0 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.gitignore ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ env/
8
+ build/
9
+ develop-eggs/
10
+ dist/
11
+ downloads/
12
+ eggs/
13
+ .eggs/
14
+ lib/
15
+ lib64/
16
+ parts/
17
+ sdist/
18
+ var/
19
+ wheels/
20
+ *.egg-info/
21
+ .installed.cfg
22
+ *.egg
23
+
24
+ # Virtual Environment
25
+ venv/
26
+ ENV/
27
+
28
+ # IDE
29
+ .idea/
30
+ .vscode/
31
+ *.swp
32
+ *.swo
33
+
34
+ # OS
35
+ .DS_Store
36
+ Thumbs.db
README.md CHANGED
@@ -17,3 +17,55 @@ Edit `/src/streamlit_app.py` to customize this app to your heart's desire. :hear
17
 
18
  If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
19
  forums](https://discuss.streamlit.io).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
  If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
19
  forums](https://discuss.streamlit.io).
20
+
21
+ # Lesson Plan Generator
22
+
23
+ A Streamlit application that generates comprehensive lesson plans using Google's Gemini AI.
24
+
25
+ ## Setup
26
+
27
+ 1. Clone this repository
28
+ 2. Install the required packages:
29
+ ```bash
30
+ pip install -r requirements.txt
31
+ ```
32
+
33
+ ## API Key Setup
34
+
35
+ ### Local Development
36
+ 1. Create a `.env` file in the root directory
37
+ 2. Add your Google AI API key:
38
+ ```
39
+ GOOGLE_API_KEY=your_api_key_here
40
+ ```
41
+
42
+ ### Hugging Face Spaces Deployment
43
+ 1. Go to your Space's settings
44
+ 2. Navigate to the "Repository secrets" section
45
+ 3. Add a new secret:
46
+ - Name: `Gemini_API_key`
47
+ - Value: Your Google AI API key
48
+
49
+ ## Running the Application
50
+
51
+ ### Local Development
52
+ ```bash
53
+ streamlit run app.py
54
+ ```
55
+
56
+ ### Hugging Face Spaces
57
+ The application will automatically use the API key from the Space's secrets.
58
+
59
+ ## Features
60
+ - Generate comprehensive lesson plans
61
+ - Automatic generation of learning objectives based on Bloom's Taxonomy
62
+ - Customizable lesson parameters
63
+ - Download lesson plans in text format
64
+
65
+ ## Deployment
66
+
67
+ This app is designed to be deployed on Hugging Face Spaces. The repository includes all necessary configuration files for deployment.
68
+
69
+ ## Contributing
70
+
71
+ Feel free to submit issues and enhancement requests!
app.py ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import numpy as np
4
+ import os
5
+ import time
6
+ from dotenv import load_dotenv
7
+ from gpt_method import (
8
+ generate_lesson_plan,
9
+ generate_objectives,
10
+ generate_materials,
11
+ generate_steps,
12
+ generate_assessment
13
+ )
14
+
15
+ # Load environment variables
16
+ load_dotenv()
17
+
18
+ # Set page config
19
+ st.set_page_config(
20
+ page_title="Lesson Plan Generator",
21
+ page_icon="📚",
22
+ layout="wide"
23
+ )
24
+
25
+ # Add custom CSS
26
+ st.markdown("""
27
+ <style>
28
+ .main {
29
+ padding: 2rem;
30
+ }
31
+ .stButton>button {
32
+ width: 100%;
33
+ }
34
+ .stTextArea>div>div>textarea {
35
+ font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
36
+ font-size: 16px;
37
+ line-height: 1.2;
38
+ font-weight: 500;
39
+ }
40
+ .stMarkdown {
41
+ font-family: 'Figtree', sans-serif;
42
+ }
43
+ </style>
44
+ """, unsafe_allow_html=True)
45
+
46
+ # Title and description
47
+ st.title("📚 Lesson Plan Generator")
48
+ st.markdown("""
49
+ Welcome to the Lesson Plan Generator! This tool helps educators create comprehensive lesson plans.
50
+ Fill out the form below to generate your lesson plan.
51
+ """)
52
+
53
+ # Create a form for lesson plan details
54
+ with st.form("lesson_plan_form"):
55
+ # Basic Information
56
+ st.subheader("Basic Information")
57
+ lesson_name = st.text_input("Course Name (Required)", placeholder="e.g., Data Structures and Algorithms")
58
+ lesson_theme = st.text_input("Course Theme (Required)", placeholder="e.g., Quick Sort")
59
+ grade_level = st.selectbox("Student Level (Required)",
60
+ ["Elementary School", "Middle School", "High School", "College", "Graduate"])
61
+
62
+ # Learning Objectives
63
+ st.subheader("Learning Objectives")
64
+ st.markdown("""
65
+ Please enter your course objectives (Optional). If left empty, we will generate them based on Bloom's Taxonomy.
66
+ Each objective should be on a new line.
67
+ """)
68
+ objectives = st.text_area("Course Objectives", height=200)
69
+
70
+ # Materials
71
+ st.subheader("Materials")
72
+ materials = st.text_area("List the materials needed for this lesson (One per line)")
73
+
74
+ # Lesson Duration
75
+ st.subheader("Lesson Duration")
76
+ duration = st.number_input("Duration (in minutes)", min_value=15, step=15)
77
+
78
+ # Lesson Steps
79
+ st.subheader("Lesson Steps")
80
+ steps = st.text_area("Describe the lesson steps (One per line)")
81
+
82
+ # Assessment
83
+ st.subheader("Assessment")
84
+ assessment = st.text_area("How will you assess student learning?")
85
+
86
+ # Submit button
87
+ submitted = st.form_submit_button("Generate Lesson Plan")
88
+
89
+ if submitted:
90
+ # Show a spinner while generating the lesson plan
91
+ with st.spinner("Generating your lesson plan..."):
92
+ try:
93
+ # Generate missing components if needed
94
+ if not objectives.strip():
95
+ objectives = generate_objectives(lesson_theme)
96
+
97
+ if not materials.strip():
98
+ materials = generate_materials(lesson_theme, grade_level)
99
+
100
+ if not steps.strip():
101
+ steps = generate_steps(lesson_theme, grade_level, duration)
102
+
103
+ if not assessment.strip():
104
+ assessment = generate_assessment(lesson_theme, grade_level)
105
+
106
+ # Generate the complete lesson plan
107
+ lesson_plan = generate_lesson_plan(
108
+ lesson_name,
109
+ lesson_theme,
110
+ grade_level,
111
+ objectives,
112
+ materials,
113
+ duration,
114
+ steps,
115
+ assessment
116
+ )
117
+
118
+ # Create a container for the generated lesson plan
119
+ with st.container():
120
+ st.markdown("## Generated Lesson Plan")
121
+ st.markdown(lesson_plan)
122
+
123
+ # Add a download button for the lesson plan
124
+ st.download_button(
125
+ label="Download Lesson Plan",
126
+ data=lesson_plan,
127
+ file_name=f"lesson_plan_{lesson_name.lower().replace(' ', '_')}.txt",
128
+ mime="text/plain"
129
+ )
130
+
131
+ except Exception as e:
132
+ st.error(f"An error occurred while generating the lesson plan: {str(e)}")
133
+ st.info("Please try again or contact support if the issue persists.")
gpt_method.py ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import google.generativeai as genai
2
+ from concurrent.futures import ThreadPoolExecutor
3
+ import threading
4
+ from collections import deque
5
+ import os
6
+
7
+ # Configure Google AI API
8
+ GOOGLE_API_KEY = os.getenv('Gemini_API_key')
9
+ if not GOOGLE_API_KEY:
10
+ raise ValueError("GOOGLE_API_KEY environment variable is not set")
11
+ genai.configure(api_key=GOOGLE_API_KEY)
12
+
13
+ # Set up the model
14
+ generation_config = {
15
+ "temperature": 0.8,
16
+ "top_p": 1,
17
+ "top_k": 1,
18
+ "max_output_tokens": 2048,
19
+ }
20
+
21
+ safety_settings = [
22
+ {
23
+ "category": "HARM_CATEGORY_HARASSMENT",
24
+ "threshold": "BLOCK_MEDIUM_AND_ABOVE"
25
+ },
26
+ {
27
+ "category": "HARM_CATEGORY_HATE_SPEECH",
28
+ "threshold": "BLOCK_MEDIUM_AND_ABOVE"
29
+ },
30
+ {
31
+ "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
32
+ "threshold": "BLOCK_MEDIUM_AND_ABOVE"
33
+ },
34
+ {
35
+ "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
36
+ "threshold": "BLOCK_MEDIUM_AND_ABOVE"
37
+ },
38
+ ]
39
+
40
+ # Initialize Gemini model with configuration
41
+ model = genai.GenerativeModel(
42
+ model_name="gemini-2.5-flash",
43
+ generation_config=generation_config,
44
+ safety_settings=safety_settings
45
+ )
46
+
47
+ class History:
48
+ def __init__(self, max_save_round):
49
+ self.max_save_round = max_save_round
50
+ self.history = deque(maxlen=self.max_save_round)
51
+
52
+ def get_from_list(self, lst):
53
+ for item in lst[:-1]:
54
+ if item['type'] == 'request':
55
+ self.history.append({'role': 'user', 'content': item['content']})
56
+ else:
57
+ self.history.append({'role': 'model', 'content': item['content']})
58
+
59
+ def save_history(self, role, content):
60
+ self.history.append({'role': role, 'content': content})
61
+
62
+ def clear_history(self):
63
+ self.history.clear()
64
+
65
+ def get_histories(self, n=None):
66
+ n = n if n is not None and n < len(self.history) else len(self.history)
67
+ return list(self.history)[-n:]
68
+
69
+ def append_to_last_history(self, increment):
70
+ if not self.history:
71
+ raise IndexError("No history to append to.")
72
+ last_record = self.history[-1]
73
+ last_record['content'] += increment
74
+ self.history[-1] = last_record
75
+
76
+ history_rounds = 20
77
+
78
+ def get_answer(client, history, system_prompt, user_prompt, printing=True, save=True):
79
+ '''
80
+ Generate a response using Gemini model
81
+ '''
82
+ # Combine system prompt and user prompt
83
+ full_prompt = f"{system_prompt}\n\n{user_prompt}"
84
+
85
+ # Generate response
86
+ response = model.generate_content(full_prompt, stream=True)
87
+
88
+ answer = ''
89
+ for chunk in response:
90
+ if chunk.text:
91
+ answer += chunk.text
92
+ if printing:
93
+ print(chunk.text, end="")
94
+
95
+ if save:
96
+ history.save_history('user', user_prompt)
97
+ history.save_history('model', answer)
98
+
99
+ return answer
100
+
101
+ def get_answer_generator(client, history, system_prompt, user_prompt, printing=True):
102
+ '''
103
+ Generator function for streaming responses
104
+ '''
105
+ # Combine system prompt and user prompt
106
+ full_prompt = f"{system_prompt}\n\n{user_prompt}"
107
+
108
+ # Save initial history
109
+ history.save_history('user', user_prompt)
110
+ history.save_history('model', '')
111
+
112
+ # Generate streaming response
113
+ response = model.generate_content(full_prompt, stream=True)
114
+
115
+ for chunk in response:
116
+ if chunk.text:
117
+ history.append_to_last_history(chunk.text)
118
+ if printing:
119
+ print(chunk.text, end='')
120
+ yield chunk.text
121
+
122
+ def get_answer_single(client, system_prompt, user_prompt, printing=False):
123
+ '''
124
+ Get a single response without streaming
125
+ '''
126
+ # Combine system prompt and user prompt
127
+ full_prompt = f"{system_prompt}\n\n{user_prompt}"
128
+
129
+ # Generate response
130
+ response = model.generate_content(full_prompt)
131
+ answer = response.text
132
+
133
+ if printing:
134
+ print(answer)
135
+
136
+ return answer
137
+
138
+ def get_answers_parallel(client, system_prompt, user_prompt, n=1, printing=False):
139
+ '''
140
+ Get multiple responses in parallel
141
+ '''
142
+ answers = []
143
+ print_lock = threading.Lock()
144
+
145
+ def get_and_print_answer():
146
+ answer = get_answer_single(client, system_prompt, user_prompt, printing=False)
147
+ if printing:
148
+ with print_lock:
149
+ print(answer)
150
+ return answer
151
+
152
+ with ThreadPoolExecutor(max_workers=n) as executor:
153
+ futures = [executor.submit(get_and_print_answer) for _ in range(n)]
154
+ for future in futures:
155
+ answers.append(future.result())
156
+
157
+ return answers
prompts_en.py ADDED
@@ -0,0 +1,532 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ events_dict = {
2
+ "Gain Attention": "- Gain Attention: Open-ended questions related to teaching content, provide detailed questions that teachers can directly ask students; related application cases, provide detailed application cases that teachers can directly present to students.",
3
+ "Inform Objectives": "- Inform Objectives: Use ordered or unordered lists to inform objectives, provide course objectives directly.",
4
+ "Recall Prior Knowledge": "- Recall Prior Knowledge: Present 'prerequisite knowledge list', provide specific list of prerequisites; recall learned knowledge through relevant examples, based on a prerequisite, provide detailed examples that can be directly presented in class, along with analysis and answers.",
5
+ "Present Content": "- Present Content: New definitions, provide specific, rigorous definitions; algorithms to be introduced, provide specific, rigorous algorithm descriptions; code, provide detailed code or pseudocode; formulas, provide formulas relevant to the class, if there are no formulas related to this class, they can be omitted.",
6
+ "Provide Learning Guidance": "- Provide Learning Guidance: Examples, provide specific examples that can be directly presented to students, not general discussions; related cases, provide related cases with detailed information; suggestions for visualization animations; suggestions for video resources.",
7
+ "Elicit Practice": "- Elicit Practice: Multiple choice questions, provide questions with specific data or detailed knowledge points, with at least 4 options; essay questions, provide detailed essay questions; possible group discussion topics; if code is mentioned, generate code questions (if not mentioned, no need to generate).",
8
+ "Provide Feedback": "- Provide Feedback: Answers and analysis for the practice questions in the elicit practice section.",
9
+ "Assess Performance": "- Assess Performance: Homework exercises, provide homework exercises with specific data, suggested to include different difficulty levels.",
10
+ "Enhance Retention and Transfer": "- Enhance Retention and Transfer: Major assignments, papers.",
11
+ }
12
+
13
+ generate_outline_prompt = """
14
+ Please write a course outline for "{lesson_name}" on "{lesson_theme}" with course objectives "{lesson_goal}" for {lesson_type} students.
15
+
16
+ A good course outline should meet the following requirements:
17
+
18
+ 1. Output in Markdown format.
19
+ 2. Divide the lesson into several parts according to teaching sequence, each part containing 1-5 sentences summarizing that part's content.
20
+ 3. Each part must include "Events" and estimated teaching duration. Assume each lesson is 90 minutes total.
21
+ 4. No prefixes or suffixes needed.
22
+ 5. Events refer to teaching events from Gagne's Nine Events theory. Each part can include several Gagne's Nine Events, and if there are multiple events, they must be separated by " & ".
23
+ 6. Note: In my markdown editor, '**' must be followed by a space to trigger correctly, i.e., '** '.
24
+ 7. Please ensure the first 8 lines follow this format:
25
+ # No numbering needed, subtitle
26
+
27
+
28
+ ## Gagne's Nine Events
29
+
30
+
31
+ ### X minutes
32
+
33
+ Please remember to leave two blank lines between each of the first eight lines for formatting purposes.
34
+
35
+ Here's an introduction to Gagne's Nine Events:
36
+ Gagne listed each element necessary for a meaningful learning experience. However, these nine events don't need to occur in the order we present them. Instead, you can incorporate these events into each step of your lesson plan—wherever it makes sense. The nine events are: Gain Attention, Inform Objectives, Recall Prior Knowledge, Present Content, Provide Learning Guidance, Elicit Practice, Provide Feedback, Assess Performance, and Enhance Retention and Transfer.
37
+ In teaching, these nine events are typically manifested in lesson plans through the following examples:
38
+
39
+ 1. Gain Attention: Open-ended questions related to teaching content; related application cases.
40
+ 2. Inform Objectives: Use ordered/unordered lists to inform objectives; display section directory in lesson plan.
41
+ 3. Recall Prior Knowledge: Present "prerequisite knowledge list"; recall learned knowledge through relevant examples.
42
+ 4. Present Content: New definitions; algorithms to be introduced; code; formulas.
43
+ 5. Provide Learning Guidance: Examples; related cases; suggestions for visualization animations; suggestions for video resources.
44
+ 6. Elicit Practice: Multiple choice questions; essay questions; possible group discussion topics.
45
+ 7. Provide Feedback: Answers and analysis for practice questions.
46
+ 8. Assess Performance: Homework exercises.
47
+ 9. Enhance Retention and Transfer: Major assignments, papers.
48
+
49
+ Here are two example sections to ensure correct format and clear content requirements:
50
+
51
+ This is from the "Data Structures" course on "Merge Sort".
52
+
53
+ # Introduction to Application Cases and Open-ended Questions
54
+
55
+
56
+ ## Gain Attention
57
+
58
+
59
+ ### 5 minutes
60
+
61
+
62
+ **Related Application Case:**
63
+ Imagine you have a deck of cards that isn't completely shuffled, with some parts still in order. Is there a way to quickly reorder this deck?
64
+
65
+ **Open-ended Question Related to Teaching Content:**
66
+ Different sorting algorithms have different performance characteristics. Think about which scenarios the algorithms we've learned before perform well in? Can we optimize them?
67
+
68
+
69
+ # Review of Previous Sorting Algorithms
70
+
71
+
72
+ ## **Recall Prior Knowledge**
73
+
74
+
75
+ ### 5 minutes
76
+
77
+
78
+ Review previously learned bubble sort and insertion sort, have students consider their time complexity.
79
+
80
+
81
+ """
82
+
83
+
84
+ generate_lesson_plan_prompt = """
85
+ Now, please help me complete the teaching content for my current section based on my teaching objectives.
86
+ Course "{lesson_name}" on topic "{lesson_theme}", here is the complete course outline
87
+ "{lesson_outline}"
88
+
89
+ This is the overview of the current section's teaching content
90
+ "{lesson_content}"
91
+
92
+
93
+
94
+ Here are the specific format requirements:
95
+ 1. Return content in Markdown format, only return the lesson plan content section.
96
+ 2. Course design must follow the theory I provided.
97
+ 3. When outputting, don't repeat the first three lines (h2 and h3 titles). Only output the main content.
98
+ 4. Don't use level 2 headings in the output!
99
+ 5. **No additional explanatory text, and don't return in quote format!!!**
100
+ 6. **Special Note**: Formatting requirements: Don't use level 1 or 2 headings in any generated content!
101
+
102
+ Here are the specific content design requirements:
103
+
104
+ 1. Teachers may not be familiar with the course, if the lesson plan includes questions for students or complex problems, be sure to include answers in the lesson plan.
105
+ 2. We emphasize the process of "knowledge transfer", please be sure to tell teachers how to explain problems and knowledge points to students.
106
+ 3. The returned section should strictly follow the teaching outline and current section overview, don't generate any content outside this section.
107
+ 4. The numbering in the course outline indicates the order of appearance in the entire lesson plan. Please only generate the teaching content for the current section, don't generate content for any other sections! Otherwise, there will be a lot of repetition, which is not what I want to see.
108
+ 5. We specify that "three consecutive line breaks" clearly represent paragraph breaks. If you think the context of the content is not closely related, you can use "three consecutive line breaks" to separate them.
109
+
110
+
111
+ The educational theory involved in this section is as follows, please construct strictly around the following events, you cannot use events or methods not mentioned.
112
+
113
+ {lesson_events}
114
+
115
+
116
+ Here is an example:
117
+
118
+ **Input:**
119
+ Data Structures Quick Sort
120
+
121
+
122
+ **Current Section Teaching Content Overview:**
123
+
124
+ # 1. Stimulating Interest: Applications of Quick Sort in Practice
125
+ ## Gain Attention
126
+ ## 5 minutes
127
+
128
+ **Thought-provoking Question:**
129
+ During the sorting process, would you like to know the final position of a specific element in the entire sequence before the sorting is complete?
130
+
131
+
132
+ **Output:**
133
+
134
+
135
+ 1. **Preparation Materials**:
136
+ - Whiteboard or blackboard or PPT.
137
+ - A set of sortable numbers, for example: [3, 6, 2, 9, 5, 8, 7, 1, 4]
138
+ 2. **Question Presentation**:
139
+ - Write down a set of unsorted numbers, such as the sequence above.
140
+ - Ask students: "Suppose we need to sort this set of numbers, but before the entire sorting process is complete, we want to know where the number 5 will be positioned. Do you think this is possible?"
141
+ 3. **Discussion and Thinking**:
142
+ - Invite students to think about and discuss this question. Let them try to guess whether it's possible to determine the final position of a specific element without completing the sort.
143
+ - Have students share their thoughts, whether intuitive, guesses, or based on their existing knowledge of sorting algorithms.
144
+
145
+ **Special Note**: Formatting requirements: Don't use level 1 or 2 headings in any generated content!
146
+
147
+ """
148
+
149
+
150
+ eventPrompts = {
151
+ "Open-ended Questions or Application Cases": """
152
+ Now, please provide an open-ended question related to {lesson_name}-{lesson_theme} for {lesson_type} students based on my lesson plan content and teaching outline. This is my lesson plan content "{lesson_outline}", this is my current selected content "{selection}", I want to generate open-ended questions or application cases based on my selected content and lesson plan content.
153
+ Here are the specific requirements:
154
+
155
+ 1. Return content in Markdown format, only return the open-ended question section.
156
+ 2. The returned section should strictly follow the given lesson plan content.
157
+ 3. This open-ended question should be based on students' unfamiliarity with the teaching content included in the teaching outline, focusing on attracting the interest of those being questioned in the teaching content, rather than testing knowledge points.
158
+ 4. The question should focus on combining learned knowledge with specific examples, not deep application of knowledge points.
159
+ 5. **No additional explanatory text, and don't return in quote format!!!**
160
+ 6. We specify that "three consecutive line breaks" clearly represent paragraph breaks. If you think the context of the content is not closely related, you can use "three consecutive line breaks" to separate them.
161
+
162
+ Here is an example:
163
+ Input:
164
+
165
+ Lesson Plan Content:
166
+ # Data Structures: Quick Sort
167
+
168
+ ## 1. Introduction to Quick Sort
169
+
170
+ ### Gain Attention
171
+
172
+ #### 5 minutes
173
+
174
+ **Related Application Case:**
175
+ In data science, machine learning, and other fields, we often need to process large amounts of data and sort this data. How can we find an algorithm that can quickly and effectively sort large datasets?
176
+
177
+ **Open-ended Question Related to Teaching Content:**
178
+ For datasets with many duplicate elements, which sorting algorithm would be better?
179
+
180
+ ## 2. Basic Concepts and Algorithm Steps of Quick Sort
181
+
182
+ ### Inform Objectives & Present Content
183
+
184
+ #### 15 minutes
185
+
186
+ **Learning Objectives:**
187
+ Understand the basic concepts of quick sort, master its algorithm steps and divide-and-conquer strategy.
188
+
189
+ **Content Presentation:**
190
+ Through PPT and board writing,详细介绍快速排序的原理,including "partition" operation and how to recursively sort each subsequence. Also, demonstrate the entire process of quick sort through examples.
191
+
192
+ ## 3. Writing Quick Sort Code
193
+
194
+ ### Provide Learning Guidance & Elicit Practice
195
+
196
+ #### 20 minutes
197
+
198
+ **Learning Guidance:**
199
+ Teacher writes quick sort code on the spot and explains the thinking and code implementation at each step.
200
+
201
+ **Practice:**
202
+ Students try to write quick sort code following the teacher's guidance and run and verify results on example data.
203
+
204
+ ## 4. Analyzing Time and Space Complexity of Quick Sort
205
+
206
+ ### Provide Learning Guidance & Elicit Practice
207
+
208
+ #### 15 minutes
209
+
210
+ **Learning Guidance:**
211
+ Teacher explains how to analyze the time and space complexity of quick sort, and its performance in best, average, and worst cases.
212
+
213
+ **Practice:**
214
+ Students try to analyze the time and space complexity of quick sort themselves and compare it with bubble sort and merge sort.
215
+
216
+ ## 5. Optimizing Quick Sort and Choosing Appropriate Sorting Algorithms
217
+
218
+ ### Provide Learning Guidance & Elicit Practice
219
+
220
+ #### 20 minutes
221
+
222
+ **Learning Guidance:**
223
+ Teacher introduces how to optimize quick sort, such as choosing pivot through median-of-three method, and using insertion sort when subsequence length is less than a certain threshold. Also, discuss how to choose appropriate sorting algorithms under different data characteristics.
224
+
225
+ **Practice:**
226
+ Students try to optimize their quick sort code and think about when they would choose to use quick sort.
227
+
228
+ ## 6. Homework and Assessment
229
+
230
+ ### Assess Performance & Enhance Retention and Transfer
231
+
232
+ #### 10 minutes
233
+
234
+ **Homework:**
235
+ Students need to submit a report including their quick sort code and analysis of quick sort's time and space complexity.
236
+
237
+ **Assessment:**
238
+ Teacher will assess whether students have achieved learning objectives based on their reports.
239
+
240
+ **Knowledge Transfer:**
241
+ In subsequent data structures and algorithm design courses, students will need to use their quick sort knowledge to solve more complex problems.
242
+
243
+ **Note**: At this stage, we don't expect students to give completely correct answers, as they may not have learned quick sort yet. The purpose of this question is to stimulate their curiosity and guide them to think about the choice and optimization of sorting algorithms, preparing them for the upcoming learning content.
244
+
245
+ **Special Note**: Formatting requirements: Don't use level 1 or 2 headings in any generated content!
246
+ Output:
247
+
248
+ Would you like to know an element's position in the entire sequence before sorting is complete? In real life, teachers grading papers face this problem. For example, in the score array [91, 92, 68, 71, 88], I want to know what rank 91 is before sorting is complete.
249
+
250
+ """,
251
+ "Ordered List of All Knowledge Points": """Now, please extract an ordered list of teaching directory for this course based on my teaching outline. This is my teaching outline "{lesson_outline}".
252
+ Here are the specific requirements:
253
+
254
+ 1. Return content in Markdown format, only return the extracted teaching directory section.
255
+ 2. The returned section should strictly follow the given teaching outline.
256
+ 3. The directory should fully simplify the steps in the outline, each item in the directory cannot exceed 10 words.
257
+ 4. **No additional explanatory text, and don't return in quote or code block format!!!**
258
+ 5. We specify that "three consecutive line breaks" clearly represent paragraph breaks. If you think the context of the content is not closely related, you can use "three consecutive line breaks" to separate them.
259
+
260
+ **Special Note**: Formatting requirements: Don't use level 1 or 2 headings in any generated content!
261
+ """,
262
+ "Prerequisite Knowledge List": """**Inform Objectives:** Required prerequisite knowledge list
263
+
264
+ Now, I'm teaching {lesson_name}-{lesson_theme} to {lesson_type} students. Please analyze the prerequisite knowledge needed before this course based on my teaching outline, and return a prerequisite knowledge list in list format. This is my teaching outline "{lesson_outline}".
265
+ Here are the specific requirements:
266
+
267
+ 1. Only return the prerequisite knowledge list section.
268
+ 2. Please strictly analyze the required prerequisite knowledge based on the given teaching outline.
269
+ 3. When analyzing the required prerequisite knowledge, please summarize all prerequisite knowledge as concisely as possible, but avoid content repetition.
270
+ 4. **No additional explanatory text, and don't return in quote format!!!**
271
+ 5. Please refer to the following understanding for the definition of prerequisite knowledge, please strictly check that the generated prerequisite knowledge doesn't include any knowledge points from this course!!!
272
+ 6. We specify that "three consecutive line breaks" clearly represent paragraph breaks. If you think the context of the content is not closely related, you can use "three consecutive line breaks" to separate them.
273
+
274
+ Prerequisite Knowledge Definition: Prerequisite knowledge specifically refers to the knowledge content that needs to be mastered before learning the knowledge points of this course. If prerequisite knowledge is not fully mastered, it will directly affect the learning of the current course.
275
+ **Special Note**: Formatting requirements: Don't use level 1, 2, or 3 headings in any generated content!
276
+ """,
277
+ "Prerequisite Knowledge Examples": """
278
+ Now, I'm teaching {lesson_name}-{lesson_theme} to {lesson_type} students. Please analyze the prerequisite knowledge needed before this course based on my teaching outline, and return a list of prerequisite knowledge in list format, and set an example question and reference answer for each item in the list. This is my teaching outline "{lesson_outline}", this is my current selected content {selection}, I want to generate prerequisite knowledge examples based on my selected content and teaching outline.
279
+ Here are the specific requirements:
280
+
281
+ 1. Only return the prerequisite knowledge list section and corresponding example questions and reference answers.
282
+ 2. Please strictly analyze the required prerequisite knowledge based on the given teaching outline.
283
+ 3. When analyzing the required prerequisite knowledge, please summarize all prerequisite knowledge as concisely as possible, but avoid content repetition.
284
+ 4. **No additional explanatory text, and don't return in quote format!!!**
285
+ 5. Please refer to the following understanding for the definition of prerequisite knowledge, please strictly check that the generated prerequisite knowledge doesn't include any knowledge points from this course!!!
286
+ 6. Return prerequisite knowledge in Markdown format ordered list, return example questions and answers in Markdown format, not the word markdown.
287
+ 7. We specify that "three consecutive line breaks" clearly represent paragraph breaks. If you think the context of the content is not closely related, you can use "three consecutive line breaks" to separate them.
288
+
289
+ Prerequisite Knowledge Definition: Prerequisite knowledge specifically refers to the knowledge content that needs to be mastered before learning the knowledge points of this course. If prerequisite knowledge is not fully mastered, it will directly affect the learning of the current course.
290
+ **Special Note**: Formatting requirements: Don't use level 1 or 2 headings in any generated content!
291
+ """,
292
+ "Generate Definition": """
293
+ Now, I'm teaching {lesson_name}-{lesson_theme} to {lesson_type} students. Please provide an authoritative definition based on the knowledge point I provide. This is the knowledge point "{selection}"
294
+
295
+ To help you generate, I provide the context of this section
296
+
297
+ "{text_area}"
298
+
299
+ Here are the specific requirements:
300
+
301
+ 1. Return content in Markdown format, not the word markdown.
302
+ 2. Only return the definition section.
303
+ 2. The returned definition must be authoritative and formal, don't appear ambiguous.
304
+ 3. **No additional explanatory text, and don't return in quote format!!!**
305
+ 4. We specify that "three consecutive line breaks" clearly represent paragraph breaks. If you think the context of the content is not closely related, you can use "three consecutive line breaks" to separate them.
306
+
307
+ Here is an example:
308
+ Input:
309
+ Knowledge point: Quick Sort
310
+
311
+ Output:
312
+ **Quick Sort**:
313
+
314
+ - **Definition**: Quick Sort is a sorting algorithm based on the divide-and-conquer approach, proposed by C. A. R. Hoare in 1960. Its main idea is to divide the data to be sorted into two independent parts through one sorting pass, where all data in one part is smaller than all data in the other part, then sort these two parts separately using the same method, to achieve an ordered sequence of the entire data.
315
+
316
+ **Special Note**: Formatting requirements: Don't use level 1 or 2 headings in any generated content!
317
+
318
+ Now, please generate an authoritative definition for "{selection}"!
319
+ """,
320
+ "Generate Formula": """
321
+ Now, I'm teaching {lesson_name}-{lesson_theme} to {lesson_type} students, please provide the mathematical formula corresponding to the knowledge point I provide. This is the knowledge point {selection}
322
+
323
+ To help you generate, I provide the context of this section
324
+ "{text_area}"
325
+
326
+ Here are the specific requirements:
327
+
328
+ 1. Return formulas in Markdown format that can be correctly recognized, not the word markdown.
329
+ 2. Only return the formula section.
330
+ 2. The returned formula must be authoritative and formal, don't appear ambiguous.
331
+ 3. **No additional explanatory text, and don't return in quote format!!!**
332
+ 4. We specify that "three consecutive line breaks" clearly represent paragraph breaks. If you think the context of the content is not closely related, you can use "three consecutive line breaks" to separate them.
333
+ **Special Note**: Formatting requirements: Don't use level 1 or 2 headings in any generated content!
334
+
335
+ Now, please provide the mathematical formula corresponding to the knowledge point {selection}.
336
+ """,
337
+ "Generate Code": """
338
+ Now, I'm teaching {lesson_name}-{lesson_theme} to {lesson_type} students, please provide the code implementation corresponding to the knowledge point I provide and the desired programming language, for the example requirements. This is the knowledge point "{selection}",
339
+
340
+ This is the context of this section "{text_area}".
341
+
342
+ Here are the specific requirements:
343
+
344
+ 1. The code example for this knowledge point must be concise and complete.
345
+ 2. Only return the code in the required language.
346
+ 3. The returned code must be authoritative and formal, don't appear ambiguous.
347
+ 4. If there are example requirements, please generate corresponding code according to the requirements. If there are no requirements, then complete a typical code for this knowledge point and return its corresponding typical problem description.
348
+ 5. We specify that "three consecutive line breaks" clearly represent paragraph breaks. If you think the context of the content is not closely related, you can use "three consecutive line breaks" to separate them.
349
+ **Special Note**: Formatting requirements: Don't use level 1 or 2 headings in any generated content!
350
+
351
+ Now, please provide the code corresponding to the knowledge point {selection}.
352
+ """,
353
+ "Generate Algorithm": """
354
+ Now, I'm teaching {lesson_name}-{lesson_theme} to {lesson_type} students, please provide a detailed algorithm introduction based on the knowledge point I provide. This is the knowledge point {selection}
355
+
356
+
357
+ To help you generate, I provide the context
358
+ {text_area}
359
+
360
+ Here are the specific requirements:
361
+
362
+ 1. The algorithm introduction for this knowledge point must be concise and complete.
363
+ 2. Only return the algorithm introduction section, no code needed.
364
+ 3. The returned algorithm must be authoritative and formal, don't appear ambiguous.
365
+ 4. **No additional explanatory text, and don't return in quote format!!!**
366
+ 5. Return content in Markdown format, not the word markdown.
367
+ 6. We specify that "three consecutive line breaks" clearly represent paragraph breaks. If you think the context of the content is not closely related, you can use "three consecutive line breaks" to separate them.
368
+ **Special Note**: Formatting requirements: Don't use level 1 or 2 headings in any generated content!
369
+
370
+ Now, please provide the algorithm corresponding to {selection}.
371
+ """,
372
+ "Generate Example": """Now, I'm teaching {lesson_name}-{lesson_theme} to {lesson_type} students, please generate **1** example question and its corresponding answer based on my provided teaching content, to improve students' mastery of this part of knowledge.
373
+ This is my teaching content "{selection}", to help you generate, I provide the context of this section "{text_area}".
374
+ Here are the specific requirements:
375
+
376
+ 1. Only return the example question and explanation method, not too long.
377
+ 2. Please strictly follow my provided teaching content to generate the example.
378
+ 3. The example question is a question that teachers present in class to explain a certain knowledge point. It should be a subjective question, not a multiple choice question. The analysis of this question should be step-by-step, explaining this knowledge point clearly.
379
+ 4. **No additional explanatory text, and don't return in quote format!!!**
380
+ 5. Return content in Markdown format, not the word markdown.
381
+ 6. We specify that "three consecutive line breaks" clearly represent paragraph breaks. If you think the context of the content is not closely related, you can use "three consecutive line breaks" to separate them.
382
+ 7. **Special Note**: Formatting requirements: Don't use level 1 or 2 headings in any generated content!
383
+
384
+ Now, please provide the example corresponding to {selection}. Since it's for classroom explanation, include detailed analysis.
385
+
386
+ """,
387
+ "Generate Slide Presentation Suggestions...": """
388
+ Now, I'm teaching {lesson_name}-{lesson_theme} to {lesson_type} students, please return suggestions for combining this part of teaching content with visualization based on my provided teaching content. This is my teaching content "{selection}",
389
+ This is the context of this section "{text_area}".
390
+ Here are the specific requirements:
391
+
392
+ 1. Only return the suggested part.
393
+ 2. Please strictly follow my provided teaching content to make suggestions.
394
+ 3. The suggested content should be limited to conventional multimedia teaching scope.
395
+ 4. **No additional explanatory text, and don't return in quote format!!!**
396
+ 5. We specify that "three consecutive line breaks" clearly represent paragraph breaks. If you think the context of the content is not closely related, you can use "three consecutive line breaks" to separate them.
397
+ 6. **Special Note**: Formatting requirements: Don't use level 1 or 2 headings in any generated content!
398
+ """,
399
+ "Generate Multiple Choice Question": """
400
+ Now, I'm teaching {lesson_name}-{lesson_theme} to {lesson_type} students, please generate a multiple choice question highly related to the current lesson plan content based on my lesson plan content, and provide the corresponding answer and answer analysis.
401
+ This is my current lesson plan content "{selection}", this is the context for your reference "{text_area}".
402
+ Here are the specific requirements:
403
+
404
+ 1. Return text content in Markdown format, don't mention markdown in the returned text, only return the multiple choice question and answer and answer analysis section.
405
+ 2. Please strictly follow my provided teaching content to generate the multiple choice question.
406
+ 3. The difficulty of the multiple choice question should be at beginner to intermediate level. This question should fully reflect the teaching effect of this part of the lesson plan content, and to some extent reflect students' mastery of knowledge.
407
+ 4. **No additional explanatory text, and don't return in quote format!!!**
408
+ 5. We specify that "three consecutive line breaks" clearly represent paragraph breaks. If you think the context of the content is not closely related, you can use "three consecutive line breaks" to separate them.
409
+ 6. **Special Note**: Formatting requirements: Don't use level 1 or 2 headings in any generated content!
410
+ """,
411
+ "Generate Fill-in-the-blank Question": """
412
+ Now, I'm teaching {lesson_name}-{lesson_theme} to {lesson_type} students, please generate a fill-in-the-blank question highly related to the current lesson plan content based on my lesson plan content, and provide the corresponding answer and answer analysis. This is my current lesson plan content "{selection}", this is the context "{text_area}".
413
+ Here are the specific requirements:
414
+
415
+ 1. Return text content in Markdown format, don't mention markdown in the returned text, only return the fill-in-the-blank question and answer and answer analysis section.
416
+ 2. Please strictly follow my provided teaching content to generate the fill-in-the-blank question.
417
+ 3. The difficulty of the fill-in-the-blank question should be at beginner to intermediate level. This question should fully reflect the teaching effect and reflect students' mastery of knowledge.
418
+ 4. **No additional explanatory text, and don't return in quote format!!!**
419
+ 5. The generated fill-in-the-blank question must be concise, directly testing the key points of the knowledge.
420
+ 6. We specify that "three consecutive line breaks" clearly represent paragraph breaks. If you think the context of the content is not closely related, you can use "three consecutive line breaks" to separate them.
421
+ 7. **Special Note**: Formatting requirements: Don't use level 1 or 2 headings in any generated content!
422
+ """,
423
+ "Generate Essay Question": """
424
+ Now, I'm teaching {lesson_name}-{lesson_theme} to {lesson_type} students, please generate an essay question highly related to the current lesson plan content based on my lesson plan content, and provide the corresponding answer and answer analysis. This is my current lesson plan content "{selection}", this is the context "{text_area}".
425
+ Here are the specific requirements:
426
+
427
+ 1. Return text content in Markdown format, don't mention markdown in the returned text, only return the essay question and answer and answer analysis section.
428
+ 2. Please strictly follow my provided teaching content to generate the essay question.
429
+ 3. The essay question should fully engage students' interest in answering the question and improve their mastery of knowledge points.
430
+ 4. **No additional explanatory text, and don't return in quote format!!!**
431
+ 5. The generated essay question and answer and answer analysis must be concise, directly testing the key points of the knowledge.
432
+ 6. We specify that "three consecutive line breaks" clearly represent paragraph breaks. If you think the context of the content is not closely related, you can use "three consecutive line breaks" to separate them.
433
+ 7. **Special Note**: Formatting requirements: Don't use level 1 or 2 headings in any generated content!
434
+ """,
435
+ "Group Discussion Suggestions": """
436
+ Now, I'm teaching {lesson_name}-{lesson_theme} to {lesson_type} students, please generate a group discussion topic highly related to the current lesson plan content based on my lesson plan content, and return a sharing format for the discussion results, as well as guiding remarks that teachers might need during the process. This is my current lesson plan content "{selection}", this is the context "{text_area}".
437
+ Here are the specific requirements:
438
+
439
+ 1. Return text content in Markdown format, don't mention markdown in the returned text, only return the required section.
440
+ 2. Please follow my provided teaching content to generate the group discussion topic.
441
+ 3. This group discussion topic should fully engage group members in the discussion and increase students' classroom participation.
442
+ 4. **No additional explanatory text, and don't return in quote format!!!**
443
+ 5. The total group discussion time should be limited to 7-15 minutes. The generated discussion topic and sharing format should be completable within this time range, and the sharing format should meet the standard of being quickly completable.
444
+ 6. Guiding remarks should mainly be open-ended questions, serving to correct deviation when students' discussion content deviates too much from the topic.
445
+ 7. We specify that "three consecutive line breaks" clearly represent paragraph breaks. If you think the context of the content is not closely related, you can use "three consecutive line breaks" to separate them.
446
+ 8. **Special Note**: Formatting requirements: Don't use level 1 or 2 headings in any generated content!
447
+ """,
448
+ "Generate Calculation Question": """
449
+ Now, I'm teaching {lesson_name}-{lesson_theme} to {lesson_type} students, please generate a calculation question highly related to the current lesson plan content based on my lesson plan content, and provide the corresponding answer and answer analysis. This is my current lesson plan content "{selection}", this is the context "{text_area}".
450
+ Here are the specific requirements:
451
+
452
+ 1. Return text content in Markdown format, don't mention markdown in the returned text, only return the calculation question and answer and answer analysis section.
453
+ 2. Please strictly follow my provided teaching content to generate the calculation question.
454
+ 3. The difficulty of the calculation question should be at beginner to intermediate level, balancing the examination of teaching effect and students' understanding of knowledge.
455
+ 4. **No additional explanatory text, and don't return in quote format!!!**
456
+ 5. The numerical values involved in the calculation question must be simple, focusing on testing knowledge points rather than students' calculation ability.
457
+ 6. The formulas appearing in the calculation question must be formal and standard.
458
+ 7. We specify that "three consecutive line breaks" clearly represent paragraph breaks. If you think the context of the content is not closely related, you can use "three consecutive line breaks" to separate them.
459
+ 8. **Special Note**: Formatting requirements: Don't use level 1 or 2 headings in any generated content!
460
+ """,
461
+ "Homework Questions and Answers": """
462
+ Now, I'm teaching {lesson_name}-{lesson_theme} to {lesson_type} students, please generate three homework questions highly related to the current lesson plan content based on my lesson plan content, and provide the corresponding answers and answer analysis. This is my current lesson plan content "{selection}", this is the context "{text_area}".
463
+ Here are the specific requirements:
464
+
465
+ 1. Return text content in Markdown format, don't mention markdown in the returned text, only return the questions and answers and answer analysis section.
466
+ 2. Please strictly follow my provided teaching content to generate the homework questions.
467
+ 3. The difficulty of the three homework questions should increase from easy to difficult, and the questions should fully examine students' mastery of knowledge.
468
+ 4. Question types are not limited, if the difficulty is too high, the question can be set as a thinking question.
469
+ 5. **No additional explanatory text, and don't return in quote format!!!**
470
+ 6. If formulas appear in the questions, please ensure they are formal and standard, and in Markdown format.
471
+ 7. We specify that "three consecutive line breaks" clearly represent paragraph breaks. If you think the context of the content is not closely related, you can use "three consecutive line breaks" to separate them.
472
+ 8. **Special Note**: Formatting requirements: Don't use level 1 or 2 headings in any generated content!
473
+ """,
474
+ "Thinking Questions Related to Course Content": """
475
+ Now, I'm teaching {lesson_name}-{lesson_theme} to {lesson_type} students, please generate a thinking question highly related to the current lesson plan content based on my lesson plan content, and provide text to help students analyze step by step. This is my current lesson plan content "{selection}", this is the context "{text_area}".
476
+ Here are the specific requirements:
477
+
478
+ 1. Return text content in Markdown format, don't mention markdown in the returned text, only return the analysis section.
479
+ 2. Please strictly follow my provided teaching content to generate the thinking question.
480
+ 3. The difficulty of the thinking question should be relatively high, and closely related to reality.
481
+ 4. The purpose of the thinking question is to ensure knowledge retention and knowledge transfer, please design with this in mind.
482
+ 5. **No additional explanatory text, and don't return in quote format!!!**
483
+ 6. If formulas appear in the questions, please ensure they are formal and standard, and in Markdown format.
484
+ 7. We specify that "three consecutive line breaks" clearly represent paragraph breaks. If you think the context of the content is not closely related, you can use "three consecutive line breaks" to separate them.
485
+ 8. **Special Note**: Formatting requirements: Don't use level 1 or 2 headings in any generated content!
486
+ """,
487
+ "Generate Slide Presentation Suggestions...": """
488
+ Now, I'm teaching {lesson_name}-{lesson_theme} to {lesson_type} students, please return PPT visualization suggestions for the current content based on my provided complete lesson plan. This is my lesson plan section "{selection}".
489
+ Here are the specific requirements:
490
+
491
+ 1. Only return the PPT visualization suggestions section, don't return any content beyond this lesson plan section!
492
+ 2. Please strictly follow my provided teaching content to make suggestions.
493
+ 3. The suggested content should be limited to conventional multimedia teaching scope, with the ultimate goal of fully mobilizing classroom enthusiasm and improving teaching effectiveness.
494
+ 4. After each suggestion, please explain the motivation and specific implementation requirements and methods.
495
+ 5. **No additional explanatory text, and don't return in quote format!!!**
496
+ 6. We specify that "three consecutive line breaks" clearly represent paragraph breaks. If you think the context of the content is not closely related, you can use "three consecutive line breaks" to separate them.
497
+ 7. **Special Note**: Formatting requirements: Don't use level 1 or 2 headings in any generated content!""",
498
+ "Content Evaluation and Teaching Suggestions": """
499
+ Now, assume you are a {lesson_type} student learning this course for the first time. I am a teacher preparing lessons, please provide teaching suggestions for this part of the lesson plan content based on the lesson plan content I provide to you. This is the lesson plan content
500
+ {selection}.
501
+
502
+ This is the context of this section: "{text_area}".
503
+
504
+ Here are the specific requirements:
505
+
506
+ 1. Return content in Markdown format, never return content contained in code blocks.
507
+ 2. First evaluate (no title needed, just provide a paragraph): Is the current lesson plan content clear enough? Can students easily understand it? You need to return such a brief evaluation content within 50 words.
508
+ 3. Then, you can provide some teaching suggestions (no title needed): Provide specific lecture notes for this paragraph, that is, how to specifically interact with students on stage, must be within 150 words.
509
+ 4. You can make good use of lists and ** to make your answer more structured.
510
+ 5. Note that what you provide is **not** teaching suggestions for the entire lesson plan, but for the current content! You need to closely follow the current teaching events, don't exceed the content of this part.
511
+ 6. **No additional explanatory text, and don't return in quote format!!!**
512
+ 7. **Special Note**: Formatting requirements: Don't use level 1 or 2 headings in any generated content!
513
+ 8. Please note, must be within 150 words!
514
+ """,
515
+ }
516
+
517
+
518
+ ask_prompt = """
519
+ Now, please provide an answer to a new teacher's question based on my course content: "{lesson_name}"--"{lesson_theme}", and the context.
520
+
521
+ This is the question asked by the teacher, it must be closely related to the context, it might be an intention to modify the above content, or it might need supplementation based on the above content:
522
+
523
+ "{prompt}"
524
+
525
+ Here are the specific requirements:
526
+
527
+ 1. Return text content in Markdown format, don't mention markdown in the returned text, only return the analysis section.
528
+ 2. No additional explanatory text needed, and don't return in quote or markdown code block format.
529
+ 3. We specify that "three consecutive line breaks" clearly represent paragraph breaks. If you think the context of the content is not closely related, you can use "three consecutive line breaks" to separate them.
530
+ 4. **Special Note**: Formatting requirements: Don't use level 1 or 2 headings in any generated content!
531
+
532
+ """
requirements.txt CHANGED
@@ -1,3 +1,7 @@
1
- altair
2
- pandas
3
- streamlit
 
 
 
 
 
1
+ streamlit==1.32.0
2
+ pandas==2.2.1
3
+ numpy==1.26.4
4
+ requests==2.31.0
5
+ beautifulsoup4==4.12.3
6
+ google-generativeai==0.3.2
7
+ python-dotenv==1.0.1
src/streamlit_app.py DELETED
@@ -1,40 +0,0 @@
1
- import altair as alt
2
- import numpy as np
3
- import pandas as pd
4
- import streamlit as st
5
-
6
- """
7
- # Welcome to Streamlit!
8
-
9
- Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
10
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
11
- forums](https://discuss.streamlit.io).
12
-
13
- In the meantime, below is an example of what you can do with just a few lines of code:
14
- """
15
-
16
- num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
17
- num_turns = st.slider("Number of turns in spiral", 1, 300, 31)
18
-
19
- indices = np.linspace(0, 1, num_points)
20
- theta = 2 * np.pi * num_turns * indices
21
- radius = indices
22
-
23
- x = radius * np.cos(theta)
24
- y = radius * np.sin(theta)
25
-
26
- df = pd.DataFrame({
27
- "x": x,
28
- "y": y,
29
- "idx": indices,
30
- "rand": np.random.randn(num_points),
31
- })
32
-
33
- st.altair_chart(alt.Chart(df, height=700, width=700)
34
- .mark_point(filled=True)
35
- .encode(
36
- x=alt.X("x", axis=None),
37
- y=alt.Y("y", axis=None),
38
- color=alt.Color("idx", legend=None, scale=alt.Scale()),
39
- size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
40
- ))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test_gemini.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from genmi_method import History, get_answer, get_answer_generator, get_answer_single, get_answers_parallel
2
+
3
+ import google.generativeai as genai
4
+ from google.generativeai import types
5
+
6
+ # Configure the API
7
+ genai.configure(api_key="AIzaSyBkA8hnF1ZNLzUPu9nDiEOwpSOHlyxfnTs")
8
+
9
+ # Initialize the model
10
+ model = genai.GenerativeModel('gemini-2.5-flash')
11
+
12
+ def test_basic_response():
13
+ print("\n=== Testing Basic Response ===")
14
+ system_prompt = "You are a helpful teaching assistant."
15
+ user_prompt = "What are the key principles of effective teaching?"
16
+ full_prompt = f"{system_prompt}\n\n{user_prompt}"
17
+
18
+ response = model.generate_content(full_prompt)
19
+ print("\nResponse:", response.text)
20
+
21
+ def test_streaming_response():
22
+ print("\n=== Testing Streaming Response ===")
23
+ system_prompt = "You are a helpful teaching assistant."
24
+ user_prompt = "Explain the concept of active learning in 3 points."
25
+ full_prompt = f"{system_prompt}\n\n{user_prompt}"
26
+
27
+ print("Streaming response:")
28
+ response = model.generate_content(full_prompt, stream=True)
29
+ for chunk in response:
30
+ print(chunk.text, end="")
31
+
32
+ def test_single_response():
33
+ print("\n=== Testing Single Response ===")
34
+ system_prompt = "You are a helpful teaching assistant."
35
+ user_prompt = "What is the difference between formative and summative assessment?"
36
+ full_prompt = f"{system_prompt}\n\n{user_prompt}"
37
+
38
+ response = model.generate_content(full_prompt)
39
+ print("\nResponse:", response.text)
40
+
41
+ def test_parallel_responses():
42
+ print("\n=== Testing Parallel Responses ===")
43
+ system_prompt = "You are a helpful teaching assistant."
44
+ user_prompt = "Give me 3 tips for classroom management."
45
+ full_prompt = f"{system_prompt}\n\n{user_prompt}"
46
+
47
+ responses = []
48
+ for _ in range(2):
49
+ response = model.generate_content(full_prompt)
50
+ responses.append(response.text)
51
+
52
+ print("\nResponses:")
53
+ for i, response in enumerate(responses, 1):
54
+ print(f"\nResponse {i}:", response)
55
+
56
+ def test_conversation_history():
57
+ print("\n=== Testing Conversation History ===")
58
+ system_prompt = "You are a helpful teaching assistant."
59
+
60
+ # First message
61
+ user_prompt1 = "What is the importance of lesson planning?"
62
+ full_prompt1 = f"{system_prompt}\n\n{user_prompt1}"
63
+ response1 = model.generate_content(full_prompt1)
64
+ print("\nFirst response:", response1.text)
65
+
66
+ # Follow-up message with context
67
+ user_prompt2 = "How can I improve my lesson planning based on your previous answer?"
68
+ full_prompt2 = f"{system_prompt}\n\nPrevious context: {response1.text}\n\n{user_prompt2}"
69
+ response2 = model.generate_content(full_prompt2)
70
+ print("\nFollow-up response:", response2.text)
71
+
72
+ if __name__ == "__main__":
73
+ print("Starting Gemini API Tests...")
74
+
75
+ try:
76
+ test_basic_response()
77
+ test_streaming_response()
78
+ test_single_response()
79
+ test_parallel_responses()
80
+ test_conversation_history()
81
+
82
+ print("\nAll tests completed successfully!")
83
+ except Exception as e:
84
+ print(f"\nError during testing: {str(e)}")