saniplus-chatbot / README.md
Sebacu's picture
Claude Opus 4.8
Add Hugging Face Spaces metadata (sdk: docker, app_port: 8100)
88a18c6
|
Raw History Blame Contribute Delete
2.85 kB
---
title: SaniPlus Chatbot
emoji: πŸ’Š
colorFrom: green
colorTo: blue
sdk: docker
app_port: 8100
pinned: false
---
# SaniPlus Apotheken β€” KI-Assistent (LLM-backed)
A working showcase of the scoped pharmacy chatbot, now powered by a **real large
language model (Claude)** behind a secure backend. It keeps the exact safety
design from the decision brief: a deterministic classifier gates every message
server-side, clinical and emergency questions never reach the model, and the
model answers **only** from SaniPlus's verified knowledge base.
## Architecture
```
Browser (public/index.html)
β”‚ POST /api/chat (conversation history + language)
β–Ό
Node + Express backend (server.js) ← API key lives here, never in the browser
β”‚ 1) Deterministic safety classifier (EMERGENCY / CLINICAL / PII / SAFE)
β”‚ β€’ EMERGENCY β†’ fixed "call 112 + Notdienst" message (no model call)
β”‚ β€’ CLINICAL β†’ fixed "see a pharmacist" referral (no model call)
β”‚ β€’ PII β†’ consent-first callback flow
β”‚ β€’ SAFE β†’ Claude, grounded on the knowledge base (kb.js)
β–Ό
Claude (claude-opus-4-8) β€” streams the answer back as Server-Sent Events
```
Two safety layers (defense in depth):
1. **Server-side classifier** β€” clinical/emergency input is answered by a fixed
template and never sent to the model.
2. **System prompt** β€” even on the SAFE path, the model is instructed to refuse
medical advice and answer only from the supplied knowledge base.
## Run it
```powershell
# 1. install
npm install
# 2. set your Anthropic API key
$env:ANTHROPIC_API_KEY = "sk-ant-..."
# 3. start
npm start
# β†’ http://localhost:8100
```
Without a key the server still runs: the safety gate (emergency/clinical/PII)
works fully, and SAFE questions return a friendly "no key configured" message
instead of a model answer. Useful for demoing the guardrails offline.
## Files
| File | Purpose |
|------|---------|
| `server.js` | Express app, safety classifier, SSE chat endpoint, Claude call |
| `kb.js` | Verified knowledge base (6 branches + services) and the system prompt |
| `public/index.html` | Chat UI (streaming, multilingual, quick replies, classifier tags) |
## Notes for production
- Opening hours are the site's blanket "Mo–Sa 9–20" statement β€” verify per
branch (the airport branch differs) before going live.
- Add GDPR/HWG compliance: EU data residency, DPA with the vendor, no training
on user data, consent capture for callbacks, minimal logging.
- Consider prompt-caching the system prompt (already marked `cache_control`),
rate limiting, and a real callback/booking integration for the PII path.
- The classifier is intentionally tuned to over-refer: a wrongly deferred safe
question costs a click; a wrongly answered clinical one is a liability.