Codexcoder commited on
Commit
b060a68
Β·
verified Β·
1 Parent(s): 49439f4

integration: add docs/chat.md

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