Re-add vendor model Opus 4.6, update DEVELOPER_GUIDE with logs/Bedrock docs

- Re-added Opus 4.6 (JSON sanitizer now handles its output)
- Added Logs & Debugging section with docker logs commands and prefixes
- Added Bedrock Model Notes (inference profiles, maxTokens, JSON sanitization)
- Updated version history through v5.8
- Updated rate limiting docs, build/push process, current image tag
This commit is contained in:
Daniel Onyejesi 2026-03-24 19:14:00 -04:00
parent 5e3c95d163
commit feb47b5e79
2 changed files with 71 additions and 39 deletions

View file

@ -49,7 +49,7 @@ Express.js (Node.js) — server.js
|
|— Helmet (CSP, security headers)
|— CORS (restricted to APP_URL in production)
|— express-rate-limit (login: 5/hr, register: 5/hr, general: 100/15min)
|— express-rate-limit (login: 10/15min, register: 5/hr, resend-verify: 3/15min, general: 60/min)
|— cookie-parser
|— Routes (/src/routes/)
|
@ -486,6 +486,14 @@ const result = await callAI(
// result = { success: true, content: '...', model: '...', provider: '...', duration: ms }
```
### Bedrock Model Notes
**Inference Profiles:** Most newer models (Anthropic vendor model 4.x, Meta Llama 4, DeepSeek R1, Amazon Nova, Writer) require cross-region inference profiles. These use a `us.` prefix on the model ID (e.g. `us.anthropic.agent-config-sonnet-4-6`). Direct model IDs will return "on-demand throughput not supported" errors.
**Max Output Tokens:** Some models have low output limits (Cohere Command R/R+: 4096, AI21 Jamba: 4096). The `maxOut` field in `models.js` auto-clamps `maxTokens` in `callBedrock()`.
**JSON Sanitization:** Some models (notably vendor model Sonnet 4.6, Opus 4.6) output literal newline characters inside JSON string values. `learningAI.js` includes a `sanitizeJsonString()` function that escapes these before parsing.
### Prompt System
Prompts are defined in `src/utils/prompts.js`. Admins can override any prompt via the Admin panel (`/admin/config/prompts`). Overrides are stored in `app_settings` table and loaded into memory on startup (with 3s grace period for DB readiness).
@ -551,10 +559,50 @@ In the Learning Hub viewer, content `body` is rendered via `sanitizeHtml()` in `
### Local Development
```bash
cp .env.example .env # Fill in your credentials
docker-compose -f docker-compose.local.yml up -d --build
docker compose -f docker-compose.local.yml build --no-cache
docker compose -f docker-compose.local.yml up -d
# App runs at http://localhost:3552
```
### Logs & Debugging
**View container logs (live):**
```bash
docker logs -f pediatric-ai-scribe
```
**View last N lines:**
```bash
docker logs --tail 50 pediatric-ai-scribe
```
**Filter for specific issues:**
```bash
# AI/Bedrock errors
docker logs pediatric-ai-scribe 2>&1 | grep -i "Bedrock\|LearningAI\|callAI"
# Auth errors
docker logs pediatric-ai-scribe 2>&1 | grep -i "Auth\|login\|verify"
# All errors
docker logs pediatric-ai-scribe 2>&1 | grep -i "error\|ERR\|fail"
```
**Key log prefixes:**
| Prefix | Source |
|--------|--------|
| `[Bedrock] Model:` | AI response metadata (block types, stop reason) |
| `[LearningAI]` | JSON parse failures with raw output context |
| `[Auth]` | Login, registration, verification events |
| `[TTS]` | Text-to-speech generation |
| `🤖 Provider:` | Startup: which AI provider is active |
| `✅ AWS Bedrock:` | Startup: Bedrock configured successfully |
**Database logs (PostgreSQL):**
```bash
docker logs pedscribe-db
```
### Production (Docker Hub image)
```bash
# docker-compose.yml (production)
@ -579,29 +627,23 @@ services:
### Docker Hub
Repository: `danielonyejesi/pediatric-ai-scribe-v3`
Tags:
- `latest` — always points to most recent stable release
- `v3.x` — specific version tags (immutable)
Tags use versioned format: `v5.0`, `v5.1`, etc. Production should always pin to a specific tag.
### Git Repository
Repository: `ifedan-ed/pediatric-ai-scribe-v3` (private)
Version tags: `v3.1` through `v3.15` as of this writing.
### Build & Push Process
```bash
# After making changes:
git add -A && git commit -m "Description"
git push origin main && git tag v3.x && git push origin v3.x
# 1. Test locally first
docker compose -f docker-compose.local.yml build --no-cache
docker compose -f docker-compose.local.yml up -d
# Test at http://localhost:3552
docker build -t danielonyejesi/pediatric-ai-scribe-v3:v3.x \
-t danielonyejesi/pediatric-ai-scribe-v3:latest .
docker push danielonyejesi/pediatric-ai-scribe-v3:v3.x
docker push danielonyejesi/pediatric-ai-scribe-v3:latest
# 2. When ready, tag and push to Docker Hub
docker tag scribe-pediatric-scribe:latest danielonyejesi/pediatric-ai-scribe-v3:v5.x
docker push danielonyejesi/pediatric-ai-scribe-v3:v5.x
# Rebuild local for testing:
docker-compose -f docker-compose.local.yml down
docker-compose -f docker-compose.local.yml up -d --build
# 3. Update production docker-compose.yml to use new tag
```
---
@ -618,7 +660,7 @@ docker-compose -f docker-compose.local.yml up -d --build
### Security Hardening Already In Place
- Helmet.js with custom CSP (no external script sources)
- CORS restricted to `APP_URL` in production
- Rate limiting on login (5/hr), register (5/hr), forgot-password (5/hr), general API (100/15min)
- Rate limiting on login (10/15min), register (5/hr), forgot-password (5/hr), resend-verification (3/15min), general API (60/min)
- bcrypt cost 12 for password hashing
- JWT with 7-day expiry
- SQL injection protection: all queries use parameterized `?` / `$1` placeholders
@ -745,15 +787,19 @@ pool.end();
| v3.11 | AI content generation for Learning Hub (topic/file/Nextcloud, pdf-parse, pptxgenjs) |
| v3.10 | Custom 404 page; server returns 404 for unknown paths |
| v3.8 | Quill replaced with Tiptap 2 (self-hosted bundle, inline link bar) |
| v5.0 | Resend verification link on login + rate limit (3/15min) |
| v5.1v5.4 | Bedrock model fixes: inference profiles, region filtering, thinking block handling |
| v5.5 | Comprehensive Bedrock fix: all us. prefix IDs, maxTokens clamping |
| v5.6 | Re-add Qwen3 235B |
| v5.7 | Remove Opus 4.6 (JSON issues) |
| v5.8 | Fix JSON parse: sanitize literal newlines in strings; re-add Opus 4.6 |
## 16. Current Docker Image
**Latest stable:** `danielonyejesi/pediatric-ai-scribe-v3:v3.19`
**Latest stable:** `danielonyejesi/pediatric-ai-scribe-v3:v5.8`
```bash
docker pull danielonyejesi/pediatric-ai-scribe-v3:v3.19
# or always latest:
docker pull danielonyejesi/pediatric-ai-scribe-v3:latest
docker pull danielonyejesi/pediatric-ai-scribe-v3:v5.8
```
---
@ -854,23 +900,7 @@ httpOnly cookies prevent token *copying* but not token *use* — an XSS attacker
---
## 15. Version History (Recent)
| Tag | Key changes |
|-----|-------------|
| v3.19 | Login flash fixed; presentation quiz option; feed labels corrected |
| v3.18 | pdf-parse v1.1.1; WebDAV selection UX; topic context on upload/WebDAV; inline refine bar; CSP unsafe-inline removed; webdav-path auth fix |
| v3.17 | AI panel CSS cascade bug fixed; quiz card redesign |
| v3.16 | DEVELOPER_GUIDE.md created |
| v3.15 | Auth reverted to localStorage; slide preview padding |
| v3.14 | AI panel context-aware options; delete wording per type |
| v3.13 | Slide preview in-page modal (arrow/swipe/keyboard) |
| v3.12 | Delete inline confirm; lighter login; Presentation type (Marp + PPTX) |
| v3.11 | AI content generation for Learning Hub (topic/file/Nextcloud) |
| v3.10 | Custom 404 page |
| v3.8 | Tiptap 2 (self-hosted, inline link bar, no popup) |
---
*Last updated: March 2026 — v3.19*
*Last updated: March 2026 — v5.8*
*Generated for developer handover.*

View file

@ -32,6 +32,8 @@ var BEDROCK_MODELS = [
// maxOut = model's max output token limit (omit if >= 8192)
// ── Anthropic vendor model (all use inference profiles) ──
{ id: 'anthropic/vendor-model-opus-4-6', name: 'vendor model Opus 4.6', cost: '~$0.075', tag: 'BEST', category: 'premium',
bedrockId: 'us.anthropic.agent-config-opus-4-6-v1' },
{ id: 'anthropic/vendor-model-opus-4-5', name: 'vendor model Opus 4.5', cost: '~$0.075', tag: 'OPUS', category: 'premium',
bedrockId: 'us.anthropic.agent-config-opus-4-5-20251101-v1:0' },
{ id: 'anthropic/vendor-model-opus-4-1', name: 'vendor model Opus 4.1', cost: '~$0.075', tag: 'MEDICAL', category: 'premium',