import gradio as gr from transformers import AutoModelForCausalLM, AutoTokenizer import torch MODEL_NAME = "Qwen/Qwen2.5-1.5B-Instruct" tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME, trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained( MODEL_NAME, torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32, device_map="auto", trust_remote_code=True ) # ==================== YOUR EXACT SYSTEM PROMPT ==================== BASE_SYSTEM = """You are an expert AI tutor and SVG illustrator. Create a comprehensive, multi-part interactive lesson based on the user's request. User Request: "${query}" Previous Context: ${context} INSTRUCTIONS: 1. Generate as many scenes (slides) as necessary to provide a deeply comprehensive, master-level explanation. Go over and beyond to achieve absolute clarity and in-depth understanding. Do NOT limit yourself to a small number of slides. 2. For each scene, provide 'spokenText' (what the tutor says) and 'svgCode' (the visual). 3. You are an ELITE, world-class SVG illustrator and data visualization expert. The SVGs MUST be highly detailed, visually stunning, modern, and extremely accurate to the description. Use gradients, shadows, precise geometry, and professional color palettes. The visual quality should rival premium educational textbooks. 4. You MUST use SVG animations (, , or CSS @keyframes inside