--- 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.