SameerArz/educationalassistantSam
0
1import gradio as gr2from utils import generate_tutor_output, generate_visual_answer3 4with gr.Blocks() as demo:5 gr.Markdown("# ๐ Your AI Tutor by Farhan")6 7 with gr.Row():8 with gr.Column(scale=2):9 subject = gr.Dropdown(10 ["Math", "Science", "History", "Literature", "Code", "AI"], 11 label="Subject", 12 info="Choose the subject of your lesson"13 )14 difficulty = gr.Radio(15 ["Beginner", "Intermediate", "Advanced"], 16 label="Difficulty Level", 17 info="Select your proficiency level"18 )19 student_input = gr.Textbox(20 placeholder="Type your query here...", 21 label="Your Input", 22 info="Enter the topic you want to learn"23 )24 25 model = gr.Dropdown(26 ["OpenAI", "LLAMA3 70B", "Mixtral 8x7B"], 27 label="LLM", 28 info="Choose the language model"29 )30 31 submit_button = gr.Button("Generate Lesson", variant="primary")32 33 with gr.Column(scale=3):34 lesson_output = gr.Markdown(label="Lesson")35 question_output = gr.Markdown(label="Comprehension Question")36 feedback_output = gr.Markdown(label="Feedback")37 image_output = gr.Image(label="Visual Answer", elem_id="image-output")38 39 gr.Markdown("""40 ### How to Use41 1. Select a subject from the dropdown.42 2. Choose your difficulty level.43 3. Enter the topic or question you'd like to explore.44 4. Click 'Generate Lesson' to receive a personalized lesson, question, feedback, and a visual answer.45 5. Review the AI-generated content to enhance your learning.46 6. Feel free to ask follow-up questions or explore new topics!47 """)48 49 submit_button.click(50 fn=lambda s, d, i, m: (generate_tutor_output(s, d, i, m), generate_visual_answer(i)),51 inputs=[subject, difficulty, student_input, model],52 outputs=[lesson_output, question_output, feedback_output, image_output]53 )54 55if __name__ == "__main__":56 demo.launch(server_name="0.0.0.0", server_port=7860, share=True)57 