perachon commited on
Commit
660263c
·
verified ·
1 Parent(s): 1d02414

Upload 4 files

Browse files

upload manually

Files changed (4) hide show
  1. Dockerfile +29 -0
  2. README.md +48 -11
  3. requirements-api.txt +3 -0
  4. start.sh +13 -0
Dockerfile ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ ENV PYTHONDONTWRITEBYTECODE=1 \
4
+ PYTHONUNBUFFERED=1
5
+
6
+ WORKDIR /app
7
+
8
+ # System deps (kept minimal)
9
+ RUN apt-get update && apt-get install -y --no-install-recommends \
10
+ curl \
11
+ && rm -rf /var/lib/apt/lists/*
12
+
13
+ # Install Python deps first for better layer caching
14
+ COPY requirements-api.txt /app/requirements-api.txt
15
+ RUN pip install --no-cache-dir -r /app/requirements-api.txt
16
+
17
+ # Copy app code
18
+ COPY src /app/src
19
+
20
+ # Hugging Face Spaces expects the app to listen on 7860
21
+ EXPOSE 7860
22
+
23
+ ENV TRIAGE_BACKEND=stub \
24
+ PORT=7860
25
+
26
+ COPY start.sh /app/start.sh
27
+ RUN sed -i 's/\r$//' /app/start.sh && chmod +x /app/start.sh
28
+
29
+ CMD ["/app/start.sh"]
README.md CHANGED
@@ -1,11 +1,48 @@
1
- ---
2
- title: P14 Space
3
- emoji: 🐠
4
- colorFrom: pink
5
- colorTo: red
6
- sdk: docker
7
- pinned: false
8
- short_description: P14 - IA médical Finetuner
9
- ---
10
-
11
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # HF Spaces (gratuit / CPU Basic) — endpoint FastAPI (sans vLLM)
2
+
3
+ Objectif: obtenir un **endpoint cloud de démonstration** gratuit (CPU) pour l’API du POC.
4
+
5
+ Important: ce déploiement **n’utilise pas vLLM** (vLLM requiert un GPU pour être pertinent/rapide). Le rapport explique l’option vLLM (GPU) comme voie recommandée si budget.
6
+
7
+ ## Ce que ce Space fournit
8
+
9
+ - `GET /health`
10
+ - `POST /triage`
11
+ - `GET /audit/{interaction_id}`
12
+ - Swagger: `/docs`
13
+
14
+ Backend par défaut: `TRIAGE_BACKEND=stub` (ne charge pas de modèle).
15
+
16
+ ## Déploiement
17
+
18
+ Dans ton Space `perachon/p14-space` (SDK Docker, template Blank, CPU Basic):
19
+
20
+ 1) Mets un `Dockerfile` à la racine du Space.
21
+ 2) Mets `start.sh` à la racine.
22
+ 3) Copie `src/` (le package `triage_llm`) dans le Space.
23
+ 4) Copie `requirements-api.txt` dans le Space.
24
+
25
+ Astuce: le plus simple est de copier/coller le contenu des fichiers de ce dossier (`cloud/hf_spaces_cpu/`) vers la racine du repo du Space.
26
+
27
+ ## URL runtime
28
+
29
+ Quand le Space est "Running", l’URL publique est généralement:
30
+
31
+ - `https://perachon-p14-space.hf.space`
32
+
33
+ Puis:
34
+
35
+ - `https://perachon-p14-space.hf.space/health`
36
+ - `https://perachon-p14-space.hf.space/docs`
37
+
38
+ ## Test rapide (PowerShell)
39
+
40
+ ```powershell
41
+ $base = "https://perachon-p14-space.hf.space"
42
+ Invoke-RestMethod "$base/health" | ConvertTo-Json -Depth 6
43
+
44
+ $payload = @{ patient_message = "J'ai mal à la gorge depuis 2 jours, nez qui coule, pas de fièvre."; lang = "fr"; context = @{} }
45
+ $json = ($payload | ConvertTo-Json -Depth 6)
46
+ $bytes = [System.Text.Encoding]::UTF8.GetBytes($json)
47
+ Invoke-RestMethod "$base/triage" -Method Post -ContentType "application/json; charset=utf-8" -Body $bytes | ConvertTo-Json -Depth 10
48
+ ```
requirements-api.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ fastapi==0.115.6
2
+ uvicorn[standard]==0.32.1
3
+ pydantic==2.10.3
start.sh ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env sh
2
+ set -eu
3
+
4
+ # HF Spaces usually sets PORT=7860, but we default it anyway.
5
+ PORT="${PORT:-7860}"
6
+
7
+ # Use --app-dir src so imports like triage_llm.* resolve.
8
+ exec uvicorn triage_llm.api.app:app \
9
+ --app-dir /app/src \
10
+ --host 0.0.0.0 \
11
+ --port "${PORT}" \
12
+ --proxy-headers \
13
+ --forwarded-allow-ips '*'