Coverage for src/lilbee/core/config/enums.py: 100%
38 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-09-08 09:20 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-09-08 09:20 +0000
1"""StrEnum types used by :mod:`lilbee.config`."""
3from enum import StrEnum
6class ReasoningMode(StrEnum):
7 """How a chat API surface presents a reasoning model's thinking.
9 ``separate`` reports thinking in the wire format's own reasoning channel:
10 ``reasoning_content`` on ``/v1/chat/completions``, a ``thinking`` block on
11 ``/v1/messages``. ``inline`` presents thinking as ordinary answer text with
12 the ``<think>`` markers stripped, for clients that never render the
13 reasoning channel. ``off`` asks the model not to think, which only reaches
14 the template on a locally served model; ``/v1/messages`` also drops
15 thinking a model produces anyway, ``/v1/chat/completions`` still reports it
16 in ``reasoning_content``.
17 """
19 SEPARATE = "separate"
20 INLINE = "inline"
21 OFF = "off"
24class ChatMode(StrEnum):
25 """How chat turns route through retrieval. ``search`` uses retrieval; ``chat`` skips it."""
27 SEARCH = "search"
28 CHAT = "chat"
31class LlmProvider(StrEnum):
32 """Inference backend that ``create_provider`` builds.
34 ``auto`` prefix-routes: native GGUF refs to the local llama-server engine,
35 remote-prefixed refs (``ollama/``, ``openai/``, ...) to the SDK backend.
36 ``remote`` forces the SDK backend.
37 """
39 AUTO = "auto"
40 REMOTE = "remote"
43class RerankerType(StrEnum):
44 """How the reranker GGUF is served. ``auto`` detects by architecture."""
46 AUTO = "auto"
47 CROSS_ENCODER = "cross_encoder"
48 LLM = "llm"
51class CrawlRenderMode(StrEnum):
52 """How a crawl fetches pages. ``http`` uses no browser; ``browser`` runs Chromium with JS."""
54 HTTP = "http"
55 BROWSER = "browser"
58class ClustererBackend(StrEnum):
59 """Known wiki clusterer backends."""
61 EMBEDDING = "embedding"
62 CONCEPTS = "concepts"
65class WikiEntityMode(StrEnum):
66 """Strategy used to extract entities for the wiki.
68 The extractor emits typed NER entities only. Concept pages are
69 proposed by the LLM inside the per-source batched call in
70 :mod:`lilbee.wiki.generation`. The enum values reflect that
71 extractor responsibility.
72 """
74 NER_ENTITIES = "ner_entities"
75 NER_CONCEPTS_PLUS_LLM_TYPES = "ner_concepts_plus_llm_types"
76 LLM_TAGGED = "llm_tagged"
79class TableModel(StrEnum):
80 """xberg's table structure recognition model, used when layout detection is on.
82 The ``slanet_*`` variants are the docling-parity lineage; ``tatr`` is xberg's
83 older default. ``disabled`` skips structure recognition.
84 """
86 DISABLED = "disabled"
87 TATR = "tatr"
88 SLANET_AUTO = "slanet_auto"
89 SLANET_PLUS = "slanet_plus"
90 SLANET_WIRED = "slanet_wired"
91 SLANET_WIRELESS = "slanet_wireless"
94class KvCacheType(StrEnum):
95 """KV cache element type. ``q8_0`` / ``q4_0`` require flash attention."""
97 F16 = "f16"
98 F32 = "f32"
99 Q8_0 = "q8_0"
100 Q4_0 = "q4_0"
103# Bytes per KV element for memory budgeting, from llama.cpp's block layouts:
104# q8_0 stores 32 elements in 34 bytes (2-byte scale + 32 data bytes) and q4_0
105# stores 32 elements in 18 bytes (2-byte scale + 16 bytes of packed nibbles).
106# Rounding q4_0 up to a whole byte charged its cache at almost twice the real
107# size and nearly halved the context window the dynamic picker granted.
108KV_CACHE_TYPE_BYTES: dict[KvCacheType, float] = {
109 KvCacheType.F16: 2.0,
110 KvCacheType.F32: 4.0,
111 KvCacheType.Q8_0: 34 / 32,
112 KvCacheType.Q4_0: 18 / 32,
113}