import gradio as gr from transformers import pipeline # Hugging Face AI model model = pipeline( "text2text-generation", model="google/flan-t5-base" ) def generate_study_pack(topic): if not topic or not topic.strip(): return "⚠️ Please enter a topic or study notes." prompt = f""" Create a useful study guide for the following topic: {topic} Give the answer in exactly these sections: EASY EXPLANATION: Explain the topic simply for a student. SHORT SUMMARY: Give 4 important points. EXAM IMPORTANT POINTS: Give 5 important points. MCQ QUIZ: Create 5 multiple choice questions. Give 4 options for each question and clearly mention the correct answer. FLASHCARDS: Create 3 question and answer flashcards. Use simple English and clear formatting. """ try: result = model( prompt, max_new_tokens=500, do_sample=False ) return result[0]["generated_text"] except Exception as e: return f"⚠️ Error: {str(e)}" # Custom CSS css = """ body { background: #f5f7fb; } .title { text-align: center; font-size: 38px; font-weight: bold; } .subtitle { text-align: center; font-size: 18px; color: #666; } button { font-size: 18px !important; } """ with gr.Blocks( title="StudySpark AI", css=css ) as demo: gr.HTML("""