File size: 1,847 Bytes
ddebc3e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"""Control-plane model enumerations."""

from enum import IntEnum, IntFlag


class ModeId(IntEnum):
    """Upstream ``modeId`` parameter values.

    Integer values are stable — used as array indices in the hot path.
    """

    AUTO = 0  # modeId="auto"
    FAST = 1  # modeId="fast"
    EXPERT = 2  # modeId="expert"
    HEAVY = 3  # modeId="heavy"    — only available on heavy-pool accounts
    GROK_4_3 = 4  # modeId="grok-420-computer-use-sa" — super/heavy only
    CONSOLE = 5  # console.x.ai 独立配额 — basic pool console 模型专用

    def to_api_str(self) -> str:
        _OVERRIDES: dict[int, str] = {
            ModeId.GROK_4_3: "grok-420-computer-use-sa",
        }
        return _OVERRIDES.get(self, self.name.lower())  # type: ignore[arg-type]


class Tier(IntEnum):
    """Account tier — determines which pool is selected."""

    BASIC = 0  # pool="basic"
    SUPER = 1  # pool="super"
    HEAVY = 2  # pool="heavy"


class Capability(IntFlag):
    """Bitmask of features a model supports."""

    CHAT = 1
    IMAGE = 2
    IMAGE_EDIT = 4
    VIDEO = 8
    VOICE = 16
    ASSET = 32
    CONSOLE_CHAT = 64  # 通过 console.x.ai/v1/responses 路由


# Human-readable mode strings in API order.
MODE_STRINGS: dict[ModeId, str] = {
    ModeId.AUTO: "auto",
    ModeId.FAST: "fast",
    ModeId.EXPERT: "expert",
    ModeId.HEAVY: "heavy",
}

ALL_MODES: tuple[ModeId, ...] = (ModeId.AUTO, ModeId.FAST, ModeId.EXPERT)
ALL_MODES_WITH_HEAVY: tuple[ModeId, ...] = (
    ModeId.AUTO,
    ModeId.FAST,
    ModeId.EXPERT,
    ModeId.HEAVY,
)
ALL_MODES_FULL: tuple[ModeId, ...] = (
    ModeId.AUTO,
    ModeId.FAST,
    ModeId.EXPERT,
    ModeId.HEAVY,
    ModeId.GROK_4_3,
)

__all__ = [
    "ModeId",
    "Tier",
    "Capability",
    "MODE_STRINGS",
    "ALL_MODES",
    "ALL_MODES_WITH_HEAVY",
    "ALL_MODES_FULL",
]