isana25 commited on
Commit
a7b4181
·
verified ·
1 Parent(s): c65ba30

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +244 -0
app.py ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import json
3
+
4
+ def analyze_ai_scenario(scenario, role):
5
+ """
6
+ Analyze an AI-in-education scenario from different stakeholder perspectives
7
+ """
8
+
9
+ # Base analysis framework
10
+ base_benefits = [
11
+ "Increased efficiency in routine tasks",
12
+ "Personalized learning experiences",
13
+ "Enhanced accessibility for diverse learners",
14
+ "Data-driven insights for improvement",
15
+ "24/7 availability for support"
16
+ ]
17
+
18
+ base_risks = [
19
+ "Over-dependence on technology",
20
+ "Privacy and data security concerns",
21
+ "Potential for academic dishonesty",
22
+ "Bias in AI algorithms",
23
+ "Job displacement concerns",
24
+ "Digital divide implications"
25
+ ]
26
+
27
+ base_ethics = [
28
+ "Transparency in AI decision-making",
29
+ "Consent and data ownership",
30
+ "Equity and fairness in access",
31
+ "Human oversight and accountability",
32
+ "Long-term impact on learning"
33
+ ]
34
+
35
+ # Role-specific perspectives
36
+ role_perspectives = {
37
+ "Teacher": {
38
+ "focus": "classroom implementation and pedagogical impact",
39
+ "specific_benefits": [
40
+ "Reduced grading time for objective assessments",
41
+ "Real-time feedback capabilities",
42
+ "Differentiated instruction support",
43
+ "Professional development insights"
44
+ ],
45
+ "specific_risks": [
46
+ "Loss of human connection with students",
47
+ "Skill atrophy in manual assessment",
48
+ "Increased workload for AI management",
49
+ "Student over-reliance on AI assistance"
50
+ ],
51
+ "specific_ethics": [
52
+ "Maintaining authentic teacher-student relationships",
53
+ "Balancing AI assistance with human judgment",
54
+ "Ensuring pedagogical integrity",
55
+ "Protecting student learning autonomy"
56
+ ]
57
+ },
58
+ "Student": {
59
+ "focus": "learning experience and academic development",
60
+ "specific_benefits": [
61
+ "Immediate feedback and support",
62
+ "Customized learning pace",
63
+ "Enhanced creativity tools",
64
+ "Better organization and planning"
65
+ ],
66
+ "specific_risks": [
67
+ "Reduced critical thinking development",
68
+ "Academic integrity violations",
69
+ "Decreased peer collaboration",
70
+ "Dependence on AI for problem-solving"
71
+ ],
72
+ "specific_ethics": [
73
+ "Honest representation of own work",
74
+ "Understanding AI limitations",
75
+ "Respecting intellectual property",
76
+ "Developing authentic skills"
77
+ ]
78
+ },
79
+ "Administrator": {
80
+ "focus": "institutional policy and resource management",
81
+ "specific_benefits": [
82
+ "Cost reduction in operations",
83
+ "Improved resource allocation",
84
+ "Enhanced decision-making data",
85
+ "Streamlined administrative processes"
86
+ ],
87
+ "specific_risks": [
88
+ "High implementation and maintenance costs",
89
+ "Legal and compliance challenges",
90
+ "Staff resistance and training needs",
91
+ "Technology infrastructure requirements"
92
+ ],
93
+ "specific_ethics": [
94
+ "Equitable access across student populations",
95
+ "Transparent policy development",
96
+ "Responsible data governance",
97
+ "Long-term institutional integrity"
98
+ ]
99
+ }
100
+ }
101
+
102
+ # Get role-specific information
103
+ role_info = role_perspectives.get(role, role_perspectives["Teacher"])
104
+
105
+ # Combine base and role-specific insights
106
+ all_benefits = base_benefits + role_info["specific_benefits"]
107
+ all_risks = base_risks + role_info["specific_risks"]
108
+ all_ethics = base_ethics + role_info["specific_ethics"]
109
+
110
+ # Create formatted response
111
+ response = f"""
112
+ ## Analysis for: "{scenario}"
113
+ ### Perspective: {role} ({role_info['focus']})
114
+
115
+ ### 🌟 **Potential Benefits**
116
+ """
117
+ for i, benefit in enumerate(all_benefits[:6], 1):
118
+ response += f"{i}. {benefit}\n"
119
+
120
+ response += "\n### ⚠️ **Potential Risks**\n"
121
+ for i, risk in enumerate(all_risks[:6], 1):
122
+ response += f"{i}. {risk}\n"
123
+
124
+ response += "\n### 🤔 **Ethical Considerations**\n"
125
+ for i, ethic in enumerate(all_ethics[:5], 1):
126
+ response += f"{i}. {ethic}\n"
127
+
128
+ response += f"""
129
+ ### 💡 **Key Questions for {role}s to Consider**
130
+ - How can we maximize benefits while minimizing risks?
131
+ - What safeguards need to be in place?
132
+ - How do we maintain human agency and oversight?
133
+ - What training or preparation is needed?
134
+ - How do we measure success and impact?
135
+ """
136
+
137
+ return response
138
+
139
+ def create_demo():
140
+ """Create and return the Gradio interface"""
141
+
142
+ # Example scenarios for users
143
+ example_scenarios = [
144
+ ["AI writing essays for grade 9 students", "Teacher"],
145
+ ["Chatbot tutoring for mathematics", "Student"],
146
+ ["AI-powered plagiarism detection system", "Administrator"],
147
+ ["Automated grading of multiple choice tests", "Teacher"],
148
+ ["AI language translation for ESL students", "Student"],
149
+ ["Predictive analytics for student performance", "Administrator"]
150
+ ]
151
+
152
+ with gr.Blocks(
153
+ title="AI-in-Education Risk Simulator",
154
+ theme=gr.themes.Soft(),
155
+ css="""
156
+ .container { max-width: 900px; margin: auto; }
157
+ .header { text-align: center; margin-bottom: 2rem; }
158
+ .scenario-input { font-size: 16px; }
159
+ """
160
+ ) as demo:
161
+
162
+ gr.HTML("""
163
+ <div class="header">
164
+ <h1>🎓 AI-in-Education Risk Simulator</h1>
165
+ <p>Explore the benefits, risks, and ethical considerations of AI integration in educational settings</p>
166
+ </div>
167
+ """)
168
+
169
+ with gr.Row():
170
+ with gr.Column(scale=2):
171
+ scenario_input = gr.Textbox(
172
+ label="AI Scenario Description",
173
+ placeholder="e.g., AI writing essays for grade 9 students",
174
+ lines=2,
175
+ elem_classes=["scenario-input"]
176
+ )
177
+
178
+ role_dropdown = gr.Dropdown(
179
+ choices=["Teacher", "Student", "Administrator"],
180
+ value="Teacher",
181
+ label="Your Role/Perspective",
182
+ info="Select your role to get a tailored analysis"
183
+ )
184
+
185
+ analyze_btn = gr.Button(
186
+ "🔍 Analyze Scenario",
187
+ variant="primary",
188
+ size="lg"
189
+ )
190
+
191
+ with gr.Row():
192
+ output = gr.Markdown(
193
+ label="Analysis Results",
194
+ elem_classes=["output-container"]
195
+ )
196
+
197
+ # Set up the interaction
198
+ analyze_btn.click(
199
+ fn=analyze_ai_scenario,
200
+ inputs=[scenario_input, role_dropdown],
201
+ outputs=output
202
+ )
203
+
204
+ # Also trigger on Enter key
205
+ scenario_input.submit(
206
+ fn=analyze_ai_scenario,
207
+ inputs=[scenario_input, role_dropdown],
208
+ outputs=output
209
+ )
210
+
211
+ # Add examples section
212
+ gr.HTML("<hr><h3>📚 Try These Example Scenarios</h3>")
213
+ gr.Examples(
214
+ examples=example_scenarios,
215
+ inputs=[scenario_input, role_dropdown],
216
+ outputs=output,
217
+ fn=analyze_ai_scenario,
218
+ cache_examples=True
219
+ )
220
+
221
+ # Add footer with instructions
222
+ gr.HTML("""
223
+ <div style="margin-top: 2rem; padding: 1rem; background-color: #f8f9fa; border-radius: 8px;">
224
+ <h4>How to Use:</h4>
225
+ <ol>
226
+ <li>Describe an AI scenario in education (be specific!)</li>
227
+ <li>Select your role perspective</li>
228
+ <li>Click "Analyze Scenario" to get tailored insights</li>
229
+ <li>Use the analysis to inform discussions and decision-making</li>
230
+ </ol>
231
+ </div>
232
+ """)
233
+
234
+ return demo
235
+
236
+ # Create and launch the app
237
+ if __name__ == "__main__":
238
+ demo = create_demo()
239
+ demo.launch(
240
+ server_name="0.0.0.0", # Allow external access
241
+ server_port=7860, # Default Gradio port
242
+ share=True, # Create public link
243
+ debug=True # Enable debug mode
244
+ )