shamamanaeem03 commited on
Commit
7a2b568
Β·
verified Β·
1 Parent(s): acbd438

Upload 3 files

Browse files
Files changed (3) hide show
  1. README (1).md +47 -0
  2. app (1).py +110 -0
  3. 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