oc_chat
Loading...
Searching...
No Matches
models.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# providers/deepseek/models.py
4
5"""
6DeepSeek model registry — typed.
7
8Purpose
9-------
10:data:`MODELS` is the canonical, single-source-of-truth registry of
11DeepSeek models with their capabilities. It is consumed by
12:meth:`DeepSeekProvider.models` and through that by
13:class:`oc_chat.core.models.ModelManager`.
14
15:data:`TIER_MAP` records the semantic-tier → model-id mapping that
16:meth:`DeepSeekProvider.tier` returns. ``step_routing.py`` reads
17from this via ``provider.tier("cheap")`` /
18``provider.tier("reasoning")`` to choose the per-iteration model.
19
20Responsibilities
21----------------
22- :data:`MODELS` — typed ``dict[str, ModelCaps]`` covering the only two
23 selectable DeepSeek models, ``deepseek-v4-pro`` and ``deepseek-v4-flash``
24 (in menu order). ``deepseek-v3`` / ``deepseek-coder`` / ``deepseek-chat`` /
25 ``deepseek-reasoner`` are retired aliases that migrate on load.
26- :data:`TIER_MAP` — semantic-tier to model-id lookup
27 (``default`` / ``cheap`` / ``reasoning`` / ``summary``).
28- :data:`RETIRED_ALIASES` — retired model id → replacement id, used to
29 filter live discovery and to migrate saved sessions deterministically
30 (plan 135 §4.6): ``deepseek-chat`` → ``deepseek-v4-flash`` (keeps the
31 cheap/non-thinking-default character), ``deepseek-reasoner`` →
32 ``deepseek-v4-pro`` (keeps the thinking/reasoning character). The
33 TUI-polish pass further retires the legacy non-V4 ids so only the two
34 V4 models are selectable: ``deepseek-v3`` → ``deepseek-v4-flash`` (cheap,
35 non-thinking) and ``deepseek-coder`` → ``deepseek-v4-pro`` (the V4 set is
36 the coding-capable line now).
37
38Diagnostics
39-----------
40Domain: OC_CHAT.CLIENT
41Levels:
42 L2 — lifecycle events
43 L3 — semantic details
44 L4 — deep tracing
45
46Contracts
47---------
48- ``MODELS`` keys are exact DeepSeek API model ids — never aliases.
49- Capability flags are immutable: edit this file to update a model's
50 capabilities; do not mutate the dataclass at runtime.
51- ``TIER_MAP`` values must always reference keys in ``MODELS``.
52- ``RETIRED_ALIASES`` keys are NOT in ``MODELS`` (they are retired); each
53 value MUST be a key in ``MODELS``. Migration is deterministic per alias
54 — never collapse both aliases to one shared target.
55
56Dependencies
57------------
58- oc_diagnostics (structured debug logging via _dbg)
59- option_c_agent_contracts (ModelCaps capability record for each model)
60"""
61from __future__ import annotations
62
63from oc_diagnostics import _dbg
64
65from option_c_agent_contracts import ModelCaps
66
67_dbg("OC_CHAT.CLIENT", "module", "loaded", 4)
68
69
70# Canonical typed registry for all DeepSeek models. Edit here to add /
71# adjust capabilities; nothing in ``oc_chat/core/`` mirrors this anymore.
72MODELS: dict[str, ModelCaps] = {
73 "deepseek-v4-pro": ModelCaps(supports_thinking=True, supports_reasoning=True, supports_tools=True, max_context_tokens=1_000_000, max_output_tokens=384_000, reasoning_state="text", cache_strategy="automatic"),
74 "deepseek-v4-flash": ModelCaps(supports_thinking=False, supports_reasoning=False, supports_tools=True, max_context_tokens=1_000_000, max_output_tokens=384_000, cache_strategy="automatic"),
75}
76
77
78# Semantic tier map — DeepSeek's answer to "give me your cheap/reasoning model".
79# Other providers will define their own; the rest of the app talks only via
80# ``provider.tier(name)``. ``default`` is the reasoning tier (plan 135 §4.6,
81# operator-confirmed): a deliberate capability↑/cost↑/latency↑ change from the
82# old ``deepseek-chat`` default.
83TIER_MAP: dict[str, str] = {
84 "default": "deepseek-v4-pro",
85 "cheap": "deepseek-v4-flash",
86 "reasoning": "deepseek-v4-pro",
87 "summary": "deepseek-v4-flash",
88}
89
90
91# Retired model ids → replacement id (plan 135 §4.6). Deterministic per alias;
92# used both to filter live discovery and to migrate saved sessions on load.
93RETIRED_ALIASES: dict[str, str] = {
94 "deepseek-chat": "deepseek-v4-flash",
95 "deepseek-reasoner": "deepseek-v4-pro",
96 "deepseek-v3": "deepseek-v4-flash",
97 "deepseek-coder": "deepseek-v4-pro",
98}
99
100
101__all__ = ["MODELS", "TIER_MAP", "RETIRED_ALIASES"]