Spaces:
Configuration error
Configuration error
Upload 3 files
Browse files- README (1).md +47 -0
- app (1).py +110 -0
- requirements (2).txt +2 -0
README (1).md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Notes Simplifier
|
| 3 |
+
emoji: π
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: teal
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: "4.44.0"
|
| 8 |
+
python_version: "3.10"
|
| 9 |
+
app_file: app.py
|
| 10 |
+
pinned: false
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# π Notes Simplifier
|
| 14 |
+
|
| 15 |
+
A smart AI-powered tool that converts complex notes into simple, easy-to-read bullet points.
|
| 16 |
+
|
| 17 |
+
## β
What it does
|
| 18 |
+
|
| 19 |
+
- Converts text into **simple, easy English**
|
| 20 |
+
- Creates **short bullet points** β only key info
|
| 21 |
+
- **Removes difficult words** and replaces with simple ones
|
| 22 |
+
- **Never copies** original sentences β always rewrites fresh
|
| 23 |
+
- Powered by **Claude AI** (Anthropic)
|
| 24 |
+
|
| 25 |
+
## π How to use
|
| 26 |
+
|
| 27 |
+
1. Paste your complex notes, article, or lecture text
|
| 28 |
+
2. Click **Simplify Notes**
|
| 29 |
+
3. Get clean bullet points instantly
|
| 30 |
+
|
| 31 |
+
## π Setup (API Key)
|
| 32 |
+
|
| 33 |
+
This app requires an Anthropic API key. Add it as a **Space Secret**:
|
| 34 |
+
|
| 35 |
+
- Go to your Space β **Settings** β **Variables and Secrets**
|
| 36 |
+
- Add a new secret: `ANTHROPIC_API_KEY` = your key
|
| 37 |
+
|
| 38 |
+
Get your API key at [console.anthropic.com](https://console.anthropic.com)
|
| 39 |
+
|
| 40 |
+
## π¦ Requirements
|
| 41 |
+
|
| 42 |
+
```
|
| 43 |
+
anthropic
|
| 44 |
+
gradio>=4.44.0
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app (1).py
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import anthropic
|
| 3 |
+
|
| 4 |
+
client = anthropic.Anthropic()
|
| 5 |
+
|
| 6 |
+
SYSTEM_PROMPT = """You are a smart notes simplifier. When given any text, you must follow these strict rules:
|
| 7 |
+
|
| 8 |
+
1. β
Convert everything into SIMPLE, EASY English (like explaining to a 12-year-old)
|
| 9 |
+
2. β
Write SHORT bullet points only β max 1-2 sentences each
|
| 10 |
+
3. β
Keep ONLY the important information β remove filler, repetition, and unnecessary details
|
| 11 |
+
4. β
REMOVE all difficult, technical, or complex words β replace them with simple everyday words
|
| 12 |
+
5. β
NEVER copy the original sentences β always rewrite completely in your own words
|
| 13 |
+
6. β
Format output as a clean bullet list using the β’ symbol
|
| 14 |
+
7. β
Start directly with bullet points β no intro, no conclusion, no extra commentary
|
| 15 |
+
|
| 16 |
+
Be concise. Aim for 5β12 bullet points depending on the length of the content."""
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def simplify_notes(text):
|
| 20 |
+
if not text or not text.strip():
|
| 21 |
+
return "β οΈ Please paste some notes or text first."
|
| 22 |
+
|
| 23 |
+
try:
|
| 24 |
+
message = client.messages.create(
|
| 25 |
+
model="claude-opus-4-5",
|
| 26 |
+
max_tokens=1024,
|
| 27 |
+
system=SYSTEM_PROMPT,
|
| 28 |
+
messages=[
|
| 29 |
+
{"role": "user", "content": f"Simplify these notes:\n\n{text}"}
|
| 30 |
+
]
|
| 31 |
+
)
|
| 32 |
+
return message.content[0].text
|
| 33 |
+
|
| 34 |
+
except anthropic.AuthenticationError:
|
| 35 |
+
return "β API key error. Please check your ANTHROPIC_API_KEY in Space secrets."
|
| 36 |
+
except anthropic.RateLimitError:
|
| 37 |
+
return "β οΈ Rate limit reached. Please wait a moment and try again."
|
| 38 |
+
except Exception as e:
|
| 39 |
+
return f"β Something went wrong: {str(e)}"
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
# --- UI ---
|
| 43 |
+
with gr.Blocks(
|
| 44 |
+
title="Notes Simplifier",
|
| 45 |
+
theme=gr.themes.Soft(
|
| 46 |
+
primary_hue="teal",
|
| 47 |
+
secondary_hue="green",
|
| 48 |
+
font=[gr.themes.GoogleFont("DM Sans"), "sans-serif"],
|
| 49 |
+
),
|
| 50 |
+
css="""
|
| 51 |
+
#title { text-align: center; margin-bottom: 4px; }
|
| 52 |
+
#subtitle { text-align: center; color: #666; margin-bottom: 20px; font-size: 15px; }
|
| 53 |
+
.tag { display: inline-block; background: #e0f2f1; color: #00695c;
|
| 54 |
+
padding: 3px 10px; border-radius: 20px; font-size: 13px; margin: 2px; }
|
| 55 |
+
#tags { text-align: center; margin-bottom: 24px; }
|
| 56 |
+
footer { display: none !important; }
|
| 57 |
+
"""
|
| 58 |
+
) as demo:
|
| 59 |
+
|
| 60 |
+
gr.Markdown("# π Notes Simplifier", elem_id="title")
|
| 61 |
+
gr.Markdown("Paste any complex notes β get clean, simple bullet points instantly", elem_id="subtitle")
|
| 62 |
+
|
| 63 |
+
gr.HTML("""
|
| 64 |
+
<div id="tags">
|
| 65 |
+
<span class="tag">β
Simple English</span>
|
| 66 |
+
<span class="tag">β
Bullet Points</span>
|
| 67 |
+
<span class="tag">β
Key Info Only</span>
|
| 68 |
+
<span class="tag">β
No Hard Words</span>
|
| 69 |
+
<span class="tag">β
Rewritten Fresh</span>
|
| 70 |
+
</div>
|
| 71 |
+
""")
|
| 72 |
+
|
| 73 |
+
with gr.Row():
|
| 74 |
+
with gr.Column():
|
| 75 |
+
input_text = gr.Textbox(
|
| 76 |
+
label="π Your Original Notes",
|
| 77 |
+
placeholder="Paste your complex notes, lecture text, article, or any paragraph here...",
|
| 78 |
+
lines=14,
|
| 79 |
+
max_lines=30,
|
| 80 |
+
)
|
| 81 |
+
with gr.Row():
|
| 82 |
+
clear_btn = gr.Button("ποΈ Clear", variant="secondary", scale=1)
|
| 83 |
+
simplify_btn = gr.Button("β¨ Simplify Notes", variant="primary", scale=3)
|
| 84 |
+
|
| 85 |
+
with gr.Column():
|
| 86 |
+
output_text = gr.Textbox(
|
| 87 |
+
label="β
Simplified Summary",
|
| 88 |
+
placeholder="Your simplified bullet points will appear here...",
|
| 89 |
+
lines=14,
|
| 90 |
+
max_lines=30,
|
| 91 |
+
show_copy_button=True,
|
| 92 |
+
)
|
| 93 |
+
|
| 94 |
+
# Example inputs
|
| 95 |
+
gr.Examples(
|
| 96 |
+
examples=[
|
| 97 |
+
["The mitochondria are membrane-bound organelles found in the cytoplasm of eukaryotic cells that generate most of the cell's supply of adenosine triphosphate (ATP), used as a source of chemical energy. In addition to supplying cellular energy, mitochondria are involved in other tasks, such as signaling, cellular differentiation, and cell death, as well as maintaining control of the cell cycle and cell growth."],
|
| 98 |
+
["Photosynthesis is a process used by plants and other organisms to convert light energy into chemical energy that, through cellular respiration, can later be released to fuel the organism's activities. Some of this chemical energy is stored in carbohydrate molecules, such as sugars and starches, which are synthesized from carbon dioxide and water β hence the name photosynthesis, from the Greek phΕs (ΟαΏΆΟ), 'light', and synthesis (ΟΟΞ½ΞΈΞ΅ΟΞΉΟ), 'putting together'."],
|
| 99 |
+
["The French Revolution was a period of radical political and societal change in France that began with the Estates General of 1789 and ended with the formation of the French Consulate in November 1799. Many of its ideas are considered fundamental principles of liberal democracy, while the Revolution is also credited as a defining moment in Western civilization that continues to have a major impact on world history."],
|
| 100 |
+
],
|
| 101 |
+
inputs=input_text,
|
| 102 |
+
label="π‘ Try an Example"
|
| 103 |
+
)
|
| 104 |
+
|
| 105 |
+
# Events
|
| 106 |
+
simplify_btn.click(fn=simplify_notes, inputs=input_text, outputs=output_text)
|
| 107 |
+
clear_btn.click(fn=lambda: ("", ""), outputs=[input_text, output_text])
|
| 108 |
+
|
| 109 |
+
if __name__ == "__main__":
|
| 110 |
+
demo.launch()
|
requirements (2).txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
anthropic
|
| 2 |
+
gradio>=4.44.0
|