Monish BV commited on
Commit
83d677f
·
1 Parent(s): c2b7a7b

Add kiosk-api with HF deployment

Browse files
Files changed (4) hide show
  1. .dockerignore +10 -0
  2. .github/workflows/sync-to-hf.yml +28 -0
  3. Dockerfile +18 -0
  4. README.md +58 -0
.dockerignore ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ .env
2
+ .env.*
3
+ *.pyc
4
+ __pycache__
5
+ .venv
6
+ venv
7
+ .git
8
+ .gitignore
9
+ *.md
10
+ !README.md
.github/workflows/sync-to-hf.yml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Push to Hugging Face Space on every push to main.
2
+ # Create the Space first: huggingface.co/spaces → New Space → Docker → Blank.
3
+ # Name it e.g. monish563/NU-Kiosk-API
4
+ #
5
+ # GitHub repo: Settings → Secrets and variables → Actions → Add HF_TOKEN
6
+
7
+ name: Sync to Hugging Face
8
+
9
+ on:
10
+ push:
11
+ branches:
12
+ - main
13
+
14
+ jobs:
15
+ sync-to-hub:
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - name: Checkout repository
19
+ uses: actions/checkout@v4
20
+ with:
21
+ fetch-depth: 0
22
+ lfs: true
23
+
24
+ - name: Push to Hugging Face Space
25
+ env:
26
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
27
+ run: |
28
+ git push https://monish563:$HF_TOKEN@huggingface.co/spaces/monish563/NU-Kiosk-API main --force
Dockerfile ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ ENV PYTHONDONTWRITEBYTECODE=1 \
4
+ PYTHONUNBUFFERED=1 \
5
+ PORT=7860
6
+
7
+ WORKDIR /app
8
+
9
+ COPY requirements.txt .
10
+ RUN pip install --no-cache-dir -r requirements.txt
11
+
12
+ COPY backend backend
13
+ COPY Archive Archive
14
+
15
+ EXPOSE 7860
16
+
17
+ # HF Spaces set PORT=7860; use PORT or fallback to 7860
18
+ CMD ["sh", "-c", "uvicorn backend.main:app --host 0.0.0.0 --port ${PORT:-7860}"]
README.md CHANGED
@@ -1,3 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
1
  # Northwestern CS Kiosk API
2
 
3
  REST API backend for the Northwestern CS Department Kiosk. This is a stripped-down version optimized for integration with external systems (e.g., speech-to-text/text-to-speech).
@@ -27,6 +38,53 @@ The API will be available at `http://0.0.0.0:8000`
27
 
28
  ---
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  ## API Reference
31
 
32
  ### Health Check
 
1
+ ---
2
+ title: Northwestern CS Kiosk API
3
+ emoji: 🎙️
4
+ colorFrom: blue
5
+ colorTo: indigo
6
+ sdk: docker
7
+ sdk_version: "latest"
8
+ app_file: Dockerfile
9
+ pinned: false
10
+ ---
11
+
12
  # Northwestern CS Kiosk API
13
 
14
  REST API backend for the Northwestern CS Department Kiosk. This is a stripped-down version optimized for integration with external systems (e.g., speech-to-text/text-to-speech).
 
38
 
39
  ---
40
 
41
+ ## Deploy to Hugging Face Spaces
42
+
43
+ Deploy this API as a public endpoint so your manager (or STT/TTS systems) can send requests from anywhere.
44
+
45
+ ### 1. Create a new Space
46
+
47
+ 1. Go to [huggingface.co/spaces](https://huggingface.co/spaces)
48
+ 2. Click **Create new Space**
49
+ 3. Choose **Docker** SDK, **Blank** template
50
+ 4. Name it (e.g. `monish563/NU-Kiosk-API`)
51
+ 5. Create, then push this `kiosk-api` folder to the Space repo
52
+
53
+ ### 2. Add secrets (Settings → Variables and secrets → Secrets Private)
54
+
55
+ | Secret | Required | Description |
56
+ |--------|----------|-------------|
57
+ | `ANTHROPIC_API_KEY` | **Yes*** | Anthropic API key (starts with `sk-ant-api03-...`) |
58
+ | `KIOSK_LLM_PROVIDER` | No | Default: `anthropic` |
59
+ | `KIOSK_LLM_MODEL` | No | Default: `claude-3-5-haiku-20241022` |
60
+ | `KIOSK_LLM_SYSTEM_PROMPT` | No | Custom system prompt for the receptionist |
61
+ | `KIOSK_LLM_STYLE` | No | Style guidelines for TTS-friendly responses |
62
+ | `OPENAI_API_KEY` | No | If using `provider: "openai"` |
63
+ | `GEMINI_API_KEY` | No | If using `provider: "gemini"` |
64
+
65
+ *At least one LLM API key (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, or `GEMINI_API_KEY`) is required.
66
+
67
+ ### 3. Endpoint URL for your manager
68
+
69
+ Once the Space is built and running, the base URL will be:
70
+
71
+ ```
72
+ https://<your-username>-<space-name>.hf.space
73
+ ```
74
+
75
+ **Main endpoint (for STT → TTS flow):**
76
+
77
+ ```
78
+ POST https://<your-username>-<space-name>.hf.space/api/query
79
+ Content-Type: application/json
80
+
81
+ {"question": "Where is Professor Hammond's office?"}
82
+ ```
83
+
84
+ **Response:** `{"answer": "...", ...}` — send `answer` to your TTS system.
85
+
86
+ ---
87
+
88
  ## API Reference
89
 
90
  ### Health Check