Spaces:
Sleeping
Sleeping
raymondEDS commited on
Commit ·
05245c5
1
Parent(s): b11119e
hiding gemini key
Browse files- src/gpt_method.py +77 -1
- src/test_gemini.py +5 -2
src/gpt_method.py
CHANGED
|
@@ -154,4 +154,80 @@ def get_answers_parallel(client, system_prompt, user_prompt, n=1, printing=False
|
|
| 154 |
for future in futures:
|
| 155 |
answers.append(future.result())
|
| 156 |
|
| 157 |
-
return answers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
for future in futures:
|
| 155 |
answers.append(future.result())
|
| 156 |
|
| 157 |
+
return answers
|
| 158 |
+
|
| 159 |
+
def generate_lesson_plan(lesson_name, lesson_theme, grade_level, objectives, materials, duration, steps, assessment):
|
| 160 |
+
"""
|
| 161 |
+
Generate a complete lesson plan using the provided components.
|
| 162 |
+
"""
|
| 163 |
+
system_prompt = """You are an expert educator. Create a comprehensive lesson plan using the provided components.
|
| 164 |
+
Format the output in a clear, professional manner with appropriate sections and bullet points."""
|
| 165 |
+
|
| 166 |
+
user_prompt = f"""Create a lesson plan with the following details:
|
| 167 |
+
|
| 168 |
+
Course Name: {lesson_name}
|
| 169 |
+
Theme: {lesson_theme}
|
| 170 |
+
Grade Level: {grade_level}
|
| 171 |
+
|
| 172 |
+
Learning Objectives:
|
| 173 |
+
{objectives}
|
| 174 |
+
|
| 175 |
+
Materials Needed:
|
| 176 |
+
{materials}
|
| 177 |
+
|
| 178 |
+
Duration: {duration} minutes
|
| 179 |
+
|
| 180 |
+
Lesson Steps:
|
| 181 |
+
{steps}
|
| 182 |
+
|
| 183 |
+
Assessment:
|
| 184 |
+
{assessment}
|
| 185 |
+
|
| 186 |
+
Please format this into a professional lesson plan with clear sections and bullet points."""
|
| 187 |
+
|
| 188 |
+
return get_answer_single(None, system_prompt, user_prompt)
|
| 189 |
+
|
| 190 |
+
def generate_objectives(lesson_theme):
|
| 191 |
+
"""
|
| 192 |
+
Generate learning objectives based on Bloom's Taxonomy.
|
| 193 |
+
"""
|
| 194 |
+
system_prompt = """You are an expert educator. Generate clear, measurable learning objectives based on Bloom's Taxonomy
|
| 195 |
+
for the given lesson theme. Include objectives at different levels of Bloom's Taxonomy."""
|
| 196 |
+
|
| 197 |
+
user_prompt = f"Generate 3-5 learning objectives for teaching {lesson_theme}. Format each objective as a bullet point."
|
| 198 |
+
|
| 199 |
+
return get_answer_single(None, system_prompt, user_prompt)
|
| 200 |
+
|
| 201 |
+
def generate_materials(lesson_theme, grade_level):
|
| 202 |
+
"""
|
| 203 |
+
Generate a list of required materials for the lesson.
|
| 204 |
+
"""
|
| 205 |
+
system_prompt = """You are an expert educator. Generate a comprehensive list of materials needed for the lesson,
|
| 206 |
+
considering the grade level and theme. Include both physical materials and digital resources if applicable."""
|
| 207 |
+
|
| 208 |
+
user_prompt = f"List all materials needed to teach {lesson_theme} to {grade_level} students. Format as bullet points."
|
| 209 |
+
|
| 210 |
+
return get_answer_single(None, system_prompt, user_prompt)
|
| 211 |
+
|
| 212 |
+
def generate_steps(lesson_theme, grade_level, duration):
|
| 213 |
+
"""
|
| 214 |
+
Generate detailed lesson steps with timing.
|
| 215 |
+
"""
|
| 216 |
+
system_prompt = """You are an expert educator. Create a detailed, step-by-step lesson plan that includes timing
|
| 217 |
+
for each activity. Consider the grade level and ensure the steps are age-appropriate."""
|
| 218 |
+
|
| 219 |
+
user_prompt = f"""Create a {duration}-minute lesson plan for teaching {lesson_theme} to {grade_level} students.
|
| 220 |
+
Include specific timing for each step and clear instructions. Format as numbered steps with timing."""
|
| 221 |
+
|
| 222 |
+
return get_answer_single(None, system_prompt, user_prompt)
|
| 223 |
+
|
| 224 |
+
def generate_assessment(lesson_theme, grade_level):
|
| 225 |
+
"""
|
| 226 |
+
Generate assessment methods for the lesson.
|
| 227 |
+
"""
|
| 228 |
+
system_prompt = """You are an expert educator. Create appropriate assessment methods for the lesson,
|
| 229 |
+
considering the grade level and learning objectives. Include both formative and summative assessments."""
|
| 230 |
+
|
| 231 |
+
user_prompt = f"Generate assessment methods for evaluating student understanding of {lesson_theme} at the {grade_level} level. Include both formative and summative assessments."
|
| 232 |
+
|
| 233 |
+
return get_answer_single(None, system_prompt, user_prompt)
|
src/test_gemini.py
CHANGED
|
@@ -2,10 +2,13 @@ from genmi_method import History, get_answer, get_answer_generator, get_answer_s
|
|
| 2 |
|
| 3 |
import google.generativeai as genai
|
| 4 |
from google.generativeai import types
|
|
|
|
| 5 |
|
| 6 |
# Configure the API
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
| 9 |
# Initialize the model
|
| 10 |
model = genai.GenerativeModel('gemini-2.5-flash')
|
| 11 |
|
|
|
|
| 2 |
|
| 3 |
import google.generativeai as genai
|
| 4 |
from google.generativeai import types
|
| 5 |
+
import os
|
| 6 |
|
| 7 |
# Configure the 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 |
# Initialize the model
|
| 13 |
model = genai.GenerativeModel('gemini-2.5-flash')
|
| 14 |
|