Spaces:
Running
Running
Download index.html from Jayaviji/StudySpark-AI: direct link, hf CLI and curl.
- Browser
- Download file 2.33 kB
-
https://huggingface.co/spaces/Jayaviji/StudySpark-AI/resolve/main/index.html
- Command line
-
hf download hf://spaces/Jayaviji/StudySpark-AI/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Jayaviji/StudySpark-AI/resolve/main/index.html
2.33 kB
| 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(""" | |
| <div class="title">π StudySpark AI</div> | |
| <div class="subtitle"> | |
| Your AI-powered study companion | |
| </div> | |
| <br> | |
| """) | |
| gr.Markdown( | |
| "### β¨ Enter any topic or paste your study notes" | |
| ) | |
| topic = gr.Textbox( | |
| label="π Topic / Study Notes", | |
| placeholder="Example: Data Mining is the process of discovering useful patterns...", | |
| lines=8 | |
| ) | |
| generate_btn = gr.Button( | |
| "π Generate Study Pack", | |
| variant="primary" | |
| ) | |
| output = gr.Textbox( | |
| label="π Your Study Pack", | |
| lines=30, | |
| show_copy_button=True | |
| ) | |
| generate_btn.click( | |
| fn=generate_study_pack, | |
| inputs=topic, | |
| outputs=output | |
| ) | |
| gr.Markdown(""" | |
| ### π‘ Try these topics | |
| `Data Mining` | |
| `Photosynthesis` | |
| `Artificial Intelligence` | |
| `Computer Networks` | |
| `Database Management System` | |
| """) | |
| demo.launch() |