Spaces:
Sleeping
Sleeping
metadata
title: Educational Assistant
emoji: π
colorFrom: purple
colorTo: green
sdk: docker
app_port: 7860
pinned: false
Quick start (clone for your own course)
- Duplicate this Space on Hugging Face.
- In your Space β Settings β Variables and secrets, add:
HF_TOKENβ required; use a token with write access so the app can create/sync the dataset.APP_PASSWORDβ strongly recommended if the Space is public/protected; default ispassword.
- Optional overrides:
APP_USERNAMEβ defaults tostudent.DATASET_IDβ defaults to<SPACE_ID>-corpuson Spaces and is created automatically when needed.ADMIN_PASSCODEβ defaults topassword; set this for real deployments.- (optional)
LLM_MODELβ defaults toQwen/Qwen2.5-7B-Instruct. - (optional)
EMBED_MODELβ defaults toBAAI/bge-small-en-v1.5.
- Restart the Space. Open
/admin, sign in with the passcode, drag in PDFs. - Share the root URL with your students β they land on the chat UI.
Local development
Requires Python 3.13, Node 20+, and uv.
cp .env.example .env # fill in HF_TOKEN; other values have defaults
# Backend
cd backend && uv sync && uv run uvicorn main:app --port 8000 --reload
# Frontend (in another shell)
cd frontend && npm install && npm run dev
Visit http://localhost:7860. Next.js proxies /api/* to 127.0.0.1:8000.
Or with Docker (matches the HF Space environment exactly)
docker build -t iamearthdev .
docker run --rm -p 7860:7860 --env-file .env iamearthdev
Customizing personas
Edit frontend/lib/personas.ts β each persona is just an
id, name, description, and a prompt that gets prepended to the system message.
Rebuild the Space to deploy.
Repo layout
/
βββ Dockerfile # multi-stage: Next build β Python+Node runtime
βββ start.sh # launches FastAPI (:8000) and Next.js (:7860)
βββ .env.example
βββ backend/
β βββ pyproject.toml # uv-managed deps
β βββ main.py # FastAPI app, /chat streams NDJSON
β βββ rag.py # PyMuPDF4LLM β LlamaIndex β LanceDB
β βββ hf_sync.py # Dataset upload/download/list/delete
β βββ auth.py # passcode cookie middleware
βββ frontend/
βββ next.config.js # /api/* β http://127.0.0.1:8000/*
βββ package.json
βββ app/
β βββ page.tsx # chat UI
β βββ admin/page.tsx # upload + file list
β βββ admin/login/page.tsx
βββ components/ # chat-interface, persona-selector, file-uploader, β¦