from transformers import pipeline import gradio as gr # Load QA model qa_model = pipeline("question-answering") # TutorPal AI logic def tutor_bot(question): context = """ Newton's laws of motion are three physical laws that together laid the foundation for classical mechanics. Photosynthesis is the process by which green plants use sunlight to synthesize food from carbon dioxide and water. The mitochondrion is the powerhouse of the cell. The speed of light is approximately 3.0 × 10^8 m/s. """ result = qa_model(question=question, context=context) return f"Hi, I'm TutorPal 👋\n\nHere's your answer:\n{result['answer']}" # Gradio app gr.Interface(fn=tutor_bot, inputs="text", outputs="text", title="📘 TutorPal - Assignment Helper").launch()