File size: 1,794 Bytes
42202c9
 
 
 
 
 
 
52d60b3
42202c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
---
title: Classroom
emoji: πŸŽ“
colorFrom: indigo
colorTo: blue
sdk: gradio
sdk_version: 5.23.0
python_version: '3.12'
app_file: app.py
pinned: false
---

# Classroom

A shared prompting classroom on Hugging Face Spaces.

- **Student tab** β€” students join with their name and the class code, then chat with the model.
- **Follow the teacher tab** β€” a read-only, live feed of the teacher's prompts and answers.
- **Teacher tab** (needs the teacher code) β€” your own prompt box (feeds the live view), every
  student prompt and answer, token usage per person, and a CSV export.

Data is kept in memory only. It resets when the Space restarts or goes to sleep, so export the
CSV before the end of class.

## Setup

1. Create a new Space at https://huggingface.co/new-space and pick the **Gradio** SDK.
2. Upload `app.py`, `requirements.txt` and this `README.md` (or `git push` them to the Space repo).
3. Under **Settings β†’ Variables and secrets**, add these:

| Name | Kind | Value |
|------|------|-------|
| `OPENAI_API_KEY` | Secret | Your OpenAI API key |
| `CLASS_CODE` | Secret | The code you give students |
| `TEACHER_CODE` | Secret | Your own code for the Teacher tab |
| `OPENAI_MODEL` | Variable (optional) | Model name, default `gpt-4o-mini` |
| `TOKEN_LIMIT_PER_STUDENT` | Variable (optional) | Max tokens per student, `0` = unlimited (the default) |

4. Share the Space URL (`https://huggingface.co/spaces/<you>/<space>`) and the class code.

> The Space must be **public** (or students must have access to it) for them to open the URL.
> All usage is billed to your OpenAI key, so consider setting `TOKEN_LIMIT_PER_STUDENT`.

## Run locally

```bash
pip install gradio==5.23.0 -r requirements.txt
export OPENAI_API_KEY=... CLASS_CODE=abc TEACHER_CODE=xyz
python app.py
```