Kamyar-zeinalipour commited on
Commit
702ea2f
·
verified ·
1 Parent(s): e87b3f8

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +143 -1
README.md CHANGED
@@ -10,4 +10,146 @@ pinned: false
10
  license: mit
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  license: mit
11
  ---
12
 
13
+ ---
14
+ title: 🎓 Educational Tutor
15
+ emoji: 🎯
16
+ colorFrom: indigo
17
+ colorTo: yellow
18
+ sdk: gradio
19
+ app_file: app.py
20
+ pinned: false
21
+ license: mit
22
+ ---
23
+
24
+ # 🎓 Educational Text Tutor — Hugging Face Space
25
+
26
+ Turn any educational text into targeted practice: **extract subtopics → generate questions → simulate students → grade & analyze → prescribe homework → personalized study summaries**.
27
+
28
+ This Space is built with **Gradio** and **OpenAI**. It works out of the box on Spaces, and you can also run it locally.
29
+
30
+ ---
31
+
32
+ ## ✨ What it does
33
+
34
+ - **Subtopic extraction** from your pasted learning material
35
+ - **Question generation** per selected subtopic (MCQ or Short Answer)
36
+ - **Student simulation** from brief persona prompts
37
+ - **Auto-grading** with per-subtopic accuracy tables
38
+ - **Homework prescription** (weak areas & concrete tasks)
39
+ - **Personalized Study Summary** for each student (strengths, weak spots, 3 goals, 7‑day micro‑plan)
40
+
41
+ ---
42
+
43
+ ## 🚀 Using this Space
44
+
45
+ 1. Paste your **OpenAI API key** on the **Setup** tab (format: `sk-...`), or store it as a Space **Secret** named `OPENAI_API_KEY` (recommended, see below).
46
+ 2. Paste the **educational text** and **extract subtopics**.
47
+ 3. **Select** subtopics to include and **generate questions** (choose MCQ/Short Answer, counts, difficulty).
48
+ 4. Enter short **profiles** for Student 1 and Student 2 and **simulate** answers (you can edit).
49
+ 5. Click **Grade & Analyze** to see per-subtopic accuracy, homework plans, and each student’s **personalized summary**.
50
+
51
+ > The app supports both the classic Chat Completions and the newer Responses API with an automatic fallback.
52
+
53
+ ---
54
+
55
+ ## 🧰 Files you should have in this Space
56
+
57
+ ```
58
+ app.py # Entry point (rename your main file to app.py)
59
+ requirements.txt # Python deps
60
+ README.md # This file
61
+ ```
62
+
63
+ - If your current file is `gradio_edu_app_fixed.py`, **rename it to `app.py`**.
64
+ - Spaces automatically runs `app.py` when `sdk: gradio` is set in the front‑matter above.
65
+
66
+ **Minimal `requirements.txt`:**
67
+ ```
68
+ gradio>=4.0.0
69
+ openai>=1.0.0
70
+ ```
71
+
72
+ (Optional) If you want to pin Python, add a `runtime.txt` (e.g., `python-3.10`).
73
+
74
+ ---
75
+
76
+ ## 🔐 Secrets & configuration (recommended)
77
+
78
+ To avoid pasting keys in the UI on every run:
79
+
80
+ 1. Go to your Space **Settings → Variables and secrets**.
81
+ 2. Add a **Secret** with key `OPENAI_API_KEY` and your value `sk-...`.
82
+ 3. (Optional) Add a **Variable** `MODEL_NAME` to override the default model (e.g., `gpt-4o`).
83
+
84
+ ### Optional code tweak to auto-use the secret
85
+ If your UI shows a textbox for the key, you can prefill it from the environment:
86
+
87
+ ```python
88
+ import os
89
+ api_key_in = gr.Textbox(
90
+ label="OpenAI API Key",
91
+ type="password",
92
+ value=os.getenv("OPENAI_API_KEY", ""),
93
+ placeholder="sk-..."
94
+ )
95
+ ```
96
+
97
+ The rest of the app can keep using the saved key from state.
98
+
99
+ ---
100
+
101
+ ## 🧭 App flow at a glance
102
+
103
+ 1) **Setup** → Save API key & model
104
+ 2) **Subtopics** → Paste text → Extract & select subtopics
105
+ 3) **Generate Questions** → Choose type/count/difficulty → Edit if needed
106
+ 4) **Simulate Students** → Provide two short profiles → Auto-fill and/or edit answers
107
+ 5) **Analysis & Homework** → Grade, per-subtopic tables, homework JSON, and **personalized summaries**
108
+
109
+ The **Personalized Study Summary** contains:
110
+ - Strengths (2–3 bullets)
111
+ - Weak spots (2–3 bullets)
112
+ - 3 measurable study goals
113
+ - A 7‑day micro‑plan (one action per day)
114
+ - A short motivation tip
115
+
116
+ ---
117
+
118
+ ## 🛠️ Notes for maintainers
119
+
120
+ - Default model is `gpt-4o-mini` (changeable in the UI or via env var `MODEL_NAME`).
121
+ - If responses get long or time out, try reducing **questions per subtopic** or switching to a larger model.
122
+ - All prompts are near the top of the file for easy editing (`*_PROMPT` constants).
123
+ - The grading step aggregates by subtopic and feeds that into homework and the personalized summaries.
124
+
125
+ ---
126
+
127
+ ## 🧪 Run locally (optional)
128
+
129
+ ```bash
130
+ pip install -U gradio openai
131
+ python app.py
132
+ # then open the local URL printed by Gradio
133
+ ```
134
+
135
+ ---
136
+
137
+ ## 🩺 Troubleshooting
138
+
139
+ - **Build errors on Spaces**: Ensure `requirements.txt` is present; optionally add `runtime.txt` with a supported Python.
140
+ - **OpenAI auth errors**: Save your key as `OPENAI_API_KEY` in Space secrets, or paste it on the Setup tab.
141
+ - **“Invalid JSON from the model”**: Reduce the number of generated questions, shorten the source text, or use a more robust model.
142
+ - **MCQ parsing**: Keep `options` a valid JSON dict with exactly `A`, `B`, `C`, `D` and set a single `correct_key`.
143
+
144
+ ---
145
+
146
+ ## 🧾 License
147
+
148
+ MIT — reuse and adapt freely.
149
+
150
+ ---
151
+
152
+ ## 🙋 Acknowledgements
153
+
154
+ Built using **Gradio** + **OpenAI**. Contributions welcome!
155
+