Codexcoder's picture
integration: add docs/chat.md
b060a68 verified
|
Raw History Blame Contribute Delete
1.74 kB

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.