Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from utils import generate_tutor_output, generate_visual_answer | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# 🎓 Your AI Tutor by Farhan") | |
| with gr.Row(): | |
| with gr.Column(scale=2): | |
| subject = gr.Dropdown( | |
| ["Math", "Science", "History", "Literature", "Code", "AI"], | |
| label="Subject", | |
| info="Choose the subject of your lesson" | |
| ) | |
| difficulty = gr.Radio( | |
| ["Beginner", "Intermediate", "Advanced"], | |
| label="Difficulty Level", | |
| info="Select your proficiency level" | |
| ) | |
| student_input = gr.Textbox( | |
| placeholder="Type your query here...", | |
| label="Your Input", | |
| info="Enter the topic you want to learn" | |
| ) | |
| model = gr.Dropdown( | |
| ["OpenAI", "LLAMA3 70B", "Mixtral 8x7B"], | |
| label="LLM", | |
| info="Choose the language model" | |
| ) | |
| submit_button = gr.Button("Generate Lesson", variant="primary") | |
| with gr.Column(scale=3): | |
| lesson_output = gr.Markdown(label="Lesson") | |
| question_output = gr.Markdown(label="Comprehension Question") | |
| feedback_output = gr.Markdown(label="Feedback") | |
| image_output = gr.Image(label="Visual Answer", elem_id="image-output") | |
| gr.Markdown(""" | |
| ### How to Use | |
| 1. Select a subject from the dropdown. | |
| 2. Choose your difficulty level. | |
| 3. Enter the topic or question you'd like to explore. | |
| 4. Click 'Generate Lesson' to receive a personalized lesson, question, feedback, and a visual answer. | |
| 5. Review the AI-generated content to enhance your learning. | |
| 6. Feel free to ask follow-up questions or explore new topics! | |
| """) | |
| submit_button.click( | |
| fn=lambda s, d, i, m: (generate_tutor_output(s, d, i, m), generate_visual_answer(i)), | |
| inputs=[subject, difficulty, student_input, model], | |
| outputs=[lesson_output, question_output, feedback_output, image_output] | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch(server_name="0.0.0.0", server_port=7860, share=True) | |