File size: 1,741 Bytes
b060a68 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | # DeepSeek V4 Chat β Module Documentation
Status: **integrated** (v1.0.0, 2026-08-09) Β· Registry: `modules/chat-module.yaml`
## 1. Overview
The chat module integrates the DeepSeek-V4-Sovereign model into the
Sovereign stack as a conversational core: session management (bounded
history), sovereign-context system prompt, OpenAI-compatible API client,
and a deterministic local-echo fallback so the module runs β and is
testable β with zero external dependencies.
## 2. Architecture
```
chat/
βββ core.py ChatMessage Β· ChatSession Β· DeepSeekV4Client
βββ api/
βββ routes.py /api/v1/chat/* (5 endpoints)
βββ app.py standalone app (port 8003)
site/chat.html chat web UI (self-contained, responsive)
```
Wired into `src/sovereign/main.py` with a guarded include (same pattern
as matrix/kyrexis/pec5d/coldcase).
## 3. Behavior
- **API mode** β `DEEPSEEK_API_KEY` set: OpenAI-compatible
`/chat/completions` call; errors surface as 502.
- **Local mode** β no key: deterministic sovereign echo, no network.
- **Sessions** β in-memory, bounded to `max_history` (50), system prompt
always retained.
## 4. Configuration
`config/chat.yaml` β model id/base/temperature/max_tokens, session bounds,
system prompt. Keys via env only.
## 5. Verification
- `tests/test_chat.py` β 7 tests (defaults, sessions, bounding, local
echo, env config, model list, API surface).
- Registry validator covers the `chat` module entry.
## 6. Production notes
- In production set `DEEPSEEK_API_KEY` (or a gateway URL) and serve behind
TLS; the UI (`site/chat.html`) talks to `/api/v1/chat` same-origin.
- The local echo is a smoke path, not a production model answerer.
|