Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import json | |
| def analyze_ai_scenario(scenario, role): | |
| """ | |
| Analyze an AI-in-education scenario from different stakeholder perspectives | |
| """ | |
| # Base analysis framework | |
| base_benefits = [ | |
| "Increased efficiency in routine tasks", | |
| "Personalized learning experiences", | |
| "Enhanced accessibility for diverse learners", | |
| "Data-driven insights for improvement", | |
| "24/7 availability for support" | |
| ] | |
| base_risks = [ | |
| "Over-dependence on technology", | |
| "Privacy and data security concerns", | |
| "Potential for academic dishonesty", | |
| "Bias in AI algorithms", | |
| "Job displacement concerns", | |
| "Digital divide implications" | |
| ] | |
| base_ethics = [ | |
| "Transparency in AI decision-making", | |
| "Consent and data ownership", | |
| "Equity and fairness in access", | |
| "Human oversight and accountability", | |
| "Long-term impact on learning" | |
| ] | |
| # Role-specific perspectives | |
| role_perspectives = { | |
| "Teacher": { | |
| "focus": "classroom implementation and pedagogical impact", | |
| "specific_benefits": [ | |
| "Reduced grading time for objective assessments", | |
| "Real-time feedback capabilities", | |
| "Differentiated instruction support", | |
| "Professional development insights" | |
| ], | |
| "specific_risks": [ | |
| "Loss of human connection with students", | |
| "Skill atrophy in manual assessment", | |
| "Increased workload for AI management", | |
| "Student over-reliance on AI assistance" | |
| ], | |
| "specific_ethics": [ | |
| "Maintaining authentic teacher-student relationships", | |
| "Balancing AI assistance with human judgment", | |
| "Ensuring pedagogical integrity", | |
| "Protecting student learning autonomy" | |
| ] | |
| }, | |
| "Student": { | |
| "focus": "learning experience and academic development", | |
| "specific_benefits": [ | |
| "Immediate feedback and support", | |
| "Customized learning pace", | |
| "Enhanced creativity tools", | |
| "Better organization and planning" | |
| ], | |
| "specific_risks": [ | |
| "Reduced critical thinking development", | |
| "Academic integrity violations", | |
| "Decreased peer collaboration", | |
| "Dependence on AI for problem-solving" | |
| ], | |
| "specific_ethics": [ | |
| "Honest representation of own work", | |
| "Understanding AI limitations", | |
| "Respecting intellectual property", | |
| "Developing authentic skills" | |
| ] | |
| }, | |
| "Administrator": { | |
| "focus": "institutional policy and resource management", | |
| "specific_benefits": [ | |
| "Cost reduction in operations", | |
| "Improved resource allocation", | |
| "Enhanced decision-making data", | |
| "Streamlined administrative processes" | |
| ], | |
| "specific_risks": [ | |
| "High implementation and maintenance costs", | |
| "Legal and compliance challenges", | |
| "Staff resistance and training needs", | |
| "Technology infrastructure requirements" | |
| ], | |
| "specific_ethics": [ | |
| "Equitable access across student populations", | |
| "Transparent policy development", | |
| "Responsible data governance", | |
| "Long-term institutional integrity" | |
| ] | |
| } | |
| } | |
| # Get role-specific information | |
| role_info = role_perspectives.get(role, role_perspectives["Teacher"]) | |
| # Combine base and role-specific insights | |
| all_benefits = base_benefits + role_info["specific_benefits"] | |
| all_risks = base_risks + role_info["specific_risks"] | |
| all_ethics = base_ethics + role_info["specific_ethics"] | |
| # Create formatted response | |
| response = f""" | |
| ## Analysis for: "{scenario}" | |
| ### Perspective: {role} ({role_info['focus']}) | |
| ### 🌟 **Potential Benefits** | |
| """ | |
| for i, benefit in enumerate(all_benefits[:6], 1): | |
| response += f"{i}. {benefit}\n" | |
| response += "\n### ⚠️ **Potential Risks**\n" | |
| for i, risk in enumerate(all_risks[:6], 1): | |
| response += f"{i}. {risk}\n" | |
| response += "\n### 🤔 **Ethical Considerations**\n" | |
| for i, ethic in enumerate(all_ethics[:5], 1): | |
| response += f"{i}. {ethic}\n" | |
| response += f""" | |
| ### 💡 **Key Questions for {role}s to Consider** | |
| - How can we maximize benefits while minimizing risks? | |
| - What safeguards need to be in place? | |
| - How do we maintain human agency and oversight? | |
| - What training or preparation is needed? | |
| - How do we measure success and impact? | |
| """ | |
| return response | |
| def create_demo(): | |
| """Create and return the Gradio interface""" | |
| # Example scenarios for users | |
| example_scenarios = [ | |
| ["AI writing essays for grade 9 students", "Teacher"], | |
| ["Chatbot tutoring for mathematics", "Student"], | |
| ["AI-powered plagiarism detection system", "Administrator"], | |
| ["Automated grading of multiple choice tests", "Teacher"], | |
| ["AI language translation for ESL students", "Student"], | |
| ["Predictive analytics for student performance", "Administrator"] | |
| ] | |
| with gr.Blocks( | |
| title="AI-in-Education Risk Simulator", | |
| theme=gr.themes.Soft(), | |
| css=""" | |
| .container { max-width: 900px; margin: auto; } | |
| .header { text-align: center; margin-bottom: 2rem; } | |
| .scenario-input { font-size: 16px; } | |
| """ | |
| ) as demo: | |
| gr.HTML(""" | |
| <div class="header"> | |
| <h1>🎓 AI-in-Education Risk Simulator</h1> | |
| <p>Explore the benefits, risks, and ethical considerations of AI integration in educational settings</p> | |
| </div> | |
| """) | |
| with gr.Row(): | |
| with gr.Column(scale=2): | |
| scenario_input = gr.Textbox( | |
| label="AI Scenario Description", | |
| placeholder="e.g., AI writing essays for grade 9 students", | |
| lines=2, | |
| elem_classes=["scenario-input"] | |
| ) | |
| role_dropdown = gr.Dropdown( | |
| choices=["Teacher", "Student", "Administrator"], | |
| value="Teacher", | |
| label="Your Role/Perspective", | |
| info="Select your role to get a tailored analysis" | |
| ) | |
| analyze_btn = gr.Button( | |
| "🔍 Analyze Scenario", | |
| variant="primary", | |
| size="lg" | |
| ) | |
| with gr.Row(): | |
| output = gr.Markdown( | |
| label="Analysis Results", | |
| elem_classes=["output-container"] | |
| ) | |
| # Set up the interaction | |
| analyze_btn.click( | |
| fn=analyze_ai_scenario, | |
| inputs=[scenario_input, role_dropdown], | |
| outputs=output | |
| ) | |
| # Also trigger on Enter key | |
| scenario_input.submit( | |
| fn=analyze_ai_scenario, | |
| inputs=[scenario_input, role_dropdown], | |
| outputs=output | |
| ) | |
| # Add examples section | |
| gr.HTML("<hr><h3>📚 Try These Example Scenarios</h3>") | |
| gr.Examples( | |
| examples=example_scenarios, | |
| inputs=[scenario_input, role_dropdown], | |
| outputs=output, | |
| fn=analyze_ai_scenario, | |
| cache_examples=True | |
| ) | |
| # Add footer with instructions | |
| gr.HTML(""" | |
| <div style="margin-top: 2rem; padding: 1rem; background-color: #f8f9fa; border-radius: 8px;"> | |
| <h4>How to Use:</h4> | |
| <ol> | |
| <li>Describe an AI scenario in education (be specific!)</li> | |
| <li>Select your role perspective</li> | |
| <li>Click "Analyze Scenario" to get tailored insights</li> | |
| <li>Use the analysis to inform discussions and decision-making</li> | |
| </ol> | |
| </div> | |
| """) | |
| return demo | |
| # Create and launch the app | |
| if __name__ == "__main__": | |
| demo = create_demo() | |
| demo.launch( | |
| server_name="0.0.0.0", # Allow external access | |
| server_port=7860, # Default Gradio port | |
| share=True, # Create public link | |
| debug=True # Enable debug mode | |
| ) | |