import gradio as gr import google.generativeai as genai # ---------------- API ---------------- genai.configure(api_key="YOUR_GOOGLE_AI_STUDIO_KEY") model = genai.GenerativeModel("gemini-1.5-flash") # ---------------- NOTES ---------------- def process_notes(text): if not text or text.strip() == "": return "Please enter notes first." prompt = f""" Summarize these notes, create 5 questions, and study tips: {text} """ res = model.generate_content(prompt) return res.text # ---------------- CHAT ---------------- def chat(message, history): history = history or [] context = "" for u, b in history: context += f"User: {u}\nAssistant: {b}\n" prompt = f""" You are a helpful tutor. {context} User: {message} Assistant: """ res = model.generate_content(prompt) history.append((message, res.text)) return "", history # ---------------- UI ---------------- theme = gr.themes.Soft( primary_hue="blue", secondary_hue="indigo", neutral_hue="slate" ) with gr.Blocks(theme=theme) as app: # 🌈 HEADER (COLORFUL) gr.Markdown( """
Simple Notes • Smart Chat • Fast Learning