File size: 1,887 Bytes
0dd4bf4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
52
53
54
55
56
57
# DeepSeek V4 Chat — Sovereign Conversational Core

> Model: **sovereign/deepseek-v4-sovereign** (304B MoE, sovereign-tuned,
> MIT lineage — see `models/deepseek-v4-sovereign/`)

## Quick start

```bash
# Local echo mode (no key needed)
python3 -c "
from chat.core import ChatSession, DeepSeekV4Client
s = ChatSession(); s.add('user', 'hello')
print(DeepSeekV4Client().complete(s)['content'][:80])
"

# API mode — set the key, then run the server
export DEEPSEEK_API_KEY=hf_or_ds_...     # DeepSeek-compatible key
export DEEPSEEK_API_BASE=https://api.deepseek.com/v1
export DEEPSEEK_MODEL=sovereign/deepseek-v4-sovereign
uvicorn chat.api.app:app --host 0.0.0.0 --port 8003
# → POST /api/v1/chat/sessions · /send · GET /models · /status
```

The router is also wired into `src/sovereign/main.py` (guarded) — the full
stack serves `/api/v1/chat/*`. Web UI: `site/chat.html`.

## Env config

| Env | Default | Purpose |
|---|---|---|
| `DEEPSEEK_API_BASE` | `https://api.deepseek.com/v1` | OpenAI-compatible base URL |
| `DEEPSEEK_API_KEY` | *(unset)* | API key — unset ⇒ local echo mode |
| `DEEPSEEK_MODEL` | `sovereign/deepseek-v4-sovereign` | Model id |

## API

| Method | Path | Purpose |
|---|---|---|
| POST | `/api/v1/chat/sessions` | Create a session |
| GET | `/api/v1/chat/sessions/{id}` | Session + history |
| POST | `/api/v1/chat/send` | Send message → reply (`{message, session_id, temperature?, max_tokens?}`) |
| GET | `/api/v1/chat/models` | Model registry |
| GET | `/api/v1/chat/status` | Mode / model / session count |

## Tests

```bash
.venv/bin/pytest tests/test_chat.py -q    # 7 tests
```

## Honesty notes

- Local echo mode is deterministic and offline — a smoke test, not a model.
- The sovereign model card (304B MoE, GPTQ 4-bit) documents the
  architecture; serving it at full scale requires the DeepSeek API or a
  compatible runtime.