Turbiling commited on
Commit
65d089d
·
verified ·
1 Parent(s): 63c3776

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -158
app.py DELETED
@@ -1,158 +0,0 @@
1
- import os
2
- import datetime
3
- import gradio as gr
4
- from docx import Document
5
- from groq import Groq
6
-
7
- # ============ Initialize Groq Client ============
8
- GROQ_API_KEY = os.getenv("GROQ_API_KEY")
9
- client = Groq(api_key=GROQ_API_KEY)
10
-
11
- # ============ Generate Backward Design Lesson Plans ============
12
- def generate_backward_plan(class_, subject, topic, students, duration, date, teacher):
13
- # ---------- English Version ----------
14
- prompt_en = f"""
15
- Generate a detailed lesson plan for Pakistani Curriculum using the BACKWARD DESIGN model.
16
- Follow these three stages clearly:
17
-
18
- 1. Stage 1 – Identify Desired Results (Learning Outcomes aligned with Pakistan Curriculum)
19
- 2. Stage 2 – Determine Acceptable Evidence (Assessment aligned with SLOs)
20
- 3. Stage 3 – Plan Learning Experiences and Instruction (Activities, Methods, Resources)
21
-
22
- Lesson Information:
23
- Class: {class_}
24
- Subject: {subject}
25
- Topic: {topic}
26
- Number of Students: {students}
27
- Duration: {duration} minutes
28
- Date: {date}
29
- Teacher: {teacher}
30
-
31
- Ensure relevance to Pakistani educational context.
32
- """
33
-
34
- completion_en = client.chat.completions.create(
35
- model="llama-3.1-8b-instant",
36
- messages=[
37
- {"role": "system", "content": "You are an expert Pakistani curriculum lesson planner."},
38
- {"role": "user", "content": prompt_en},
39
- ],
40
- )
41
-
42
- english_plan = completion_en.choices[0].message.content.strip()
43
-
44
- # ---------- Save English Word File ----------
45
- docx_file = f"Backward_Design_Lesson_{teacher}_EN.docx"
46
- doc = Document()
47
- doc.add_heading("Backward Design Lesson Plan (Pakistan Curriculum)", 0)
48
- doc.add_paragraph(f"Class: {class_}")
49
- doc.add_paragraph(f"Subject: {subject}")
50
- doc.add_paragraph(f"Topic: {topic}")
51
- doc.add_paragraph(f"Number of Students: {students}")
52
- doc.add_paragraph(f"Duration: {duration} minutes")
53
- doc.add_paragraph(f"Date: {date}")
54
- doc.add_paragraph(f"Teacher: {teacher}")
55
- doc.add_paragraph("\n" + english_plan)
56
- doc.add_paragraph("\nDeveloped by Najaf Ali Sharqi")
57
- doc.save(docx_file)
58
-
59
- # ---------- Urdu Version ----------
60
- prompt_ur = f"""
61
- پاکستان کے نصاب (کریکولم) کے مطابق "بیکورڈ ڈیزائن" ماڈل پر مبنی تفصیلی سبق کا منصوبہ اردو میں تیار کریں۔
62
- تین مراحل کو واضح طور پر شامل کریں:
63
-
64
- 1. مرحلہ اوّل – مطلوبہ نتائج کی شناخت (مقاصدِ سبق / ایس ایل اوز)
65
- 2. مرحلہ دوم – قابلِ قبول شواہد کا تعین (تشخیص)
66
- 3. مرحلہ سوم – تدریسی تجربات اور سرگرمیوں کی منصوبہ بندی (طرزِ تدریس، وسائل، طلباء کی شرکت)
67
-
68
- معلومات:
69
- کلاس: {class_}
70
- مضمون: {subject}
71
- موضوع: {topic}
72
- طلباء کی تعداد: {students}
73
- دورانیہ: {duration} منٹ
74
- تاریخ: {date}
75
- استاد: {teacher}
76
-
77
- سب کچھ خالص اردو میں لکھیں۔ انگریزی الفاظ اردو رسم الخط میں لکھے جائیں۔
78
- ناستعلیق انداز اپنائیں۔
79
- """
80
-
81
- completion_ur = client.chat.completions.create(
82
- model="openai/gpt-oss-120b",
83
- messages=[
84
- {"role": "system", "content": "آپ ایک ماہر پاکستانی نصاب کے استاد ہیں۔"},
85
- {"role": "user", "content": prompt_ur},
86
- ],
87
- )
88
-
89
- urdu_plan = completion_ur.choices[0].message.content.strip()
90
-
91
- # ---------- Save Urdu Markdown File ----------
92
- md_file = f"Backward_Design_Lesson_{teacher}_UR.md"
93
- with open(md_file, "w", encoding="utf-8") as f:
94
- f.write("# سبق کا منصوبہ (بیکورڈ ڈیزائن – پاکستانی نصاب)\n\n")
95
- f.write(f"**کلاس:** {class_}\n\n")
96
- f.write(f"**مضمون:** {subject}\n\n")
97
- f.write(f"**موضوع:** {topic}\n\n")
98
- f.write(f"**طلباء کی تعداد:** {students}\n\n")
99
- f.write(f"**دورانیہ:** {duration} منٹ\n\n")
100
- f.write(f"**تاریخ:** {date}\n\n")
101
- f.write(f"**استاد:** {teacher}\n\n")
102
- f.write("\n---\n\n")
103
- f.write(urdu_plan)
104
- f.write("\n\n---\n\n**تیار کنندہ:** نجف علی شرقی")
105
-
106
- # ---------- Return Outputs ----------
107
- return english_plan, urdu_plan, docx_file, md_file
108
-
109
-
110
- # ============ Gradio App Interface ============
111
- with gr.Blocks(title="Backward Design Lesson Plan Generator (Pakistan Curriculum)") as app:
112
- gr.Markdown(
113
- """
114
- # 📘 Backward Design Lesson Plan Generator
115
- **Generate bilingual lesson plans aligned with Pakistan Curriculum (Grades 1–12)**
116
- Developed by **Najaf Ali Sharqi**
117
- """
118
- )
119
-
120
- with gr.Row():
121
- class_ = gr.Dropdown(
122
- [f"Grade {i}" for i in range(1, 13)],
123
- label="Class / جماعت"
124
- )
125
- subject = gr.Dropdown(
126
- [
127
- "Urdu", "English", "Arabic", "Science", "Mathematics", "Biology",
128
- "Chemistry", "Physics", "Zoology", "Botany", "Civics", "Islamiat",
129
- "Pakistan Studies", "Computer Science"
130
- ],
131
- label="Subject / مضمون",
132
- )
133
-
134
- with gr.Row():
135
- topic = gr.Textbox(label="Topic / موضوع")
136
- teacher = gr.Textbox(label="Teacher Name / استاد کا نام")
137
-
138
- with gr.Row():
139
- date = gr.Textbox(label="Date (YYYY-MM-DD) / تاریخ")
140
- students = gr.Slider(1, 200, step=1, label="Number of Students / طلباء کی تعداد")
141
- duration = gr.Slider(30, 60, step=5, label="Time Duration (minutes) / دورانیہ")
142
-
143
- generate_btn = gr.Button("✨ Generate Lesson Plans")
144
- theme_toggle = gr.Radio(["Light 🌞", "Dark 🌙"], label="Theme")
145
-
146
- english_output = gr.Textbox(label="English Lesson Plan", lines=15)
147
- urdu_output = gr.Textbox(label="اردو سبق کا منصوبہ", lines=15, rtl=True)
148
-
149
- english_file = gr.File(label="📘 Download English Plan (Word)")
150
- urdu_file = gr.File(label="📗 اردو منصوبہ (Markdown)")
151
-
152
- generate_btn.click(
153
- generate_backward_plan,
154
- inputs=[class_, subject, topic, students, duration, date, teacher],
155
- outputs=[english_output, urdu_output, english_file, urdu_file],
156
- )
157
-
158
- app.launch()