feat: checkpoint device agent runtime milestones
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from collections.abc import Mapping
|
||||
from dataclasses import dataclass
|
||||
|
||||
DEFAULT_MODEL = "claude-haiku-4-5"
|
||||
DEFAULT_TIMEOUT_SECONDS = 5.0
|
||||
|
||||
ENABLED_ENV = "SEMANTIC_ENRICHMENT_ENABLED"
|
||||
MODEL_ENV = "SEMANTIC_MODEL"
|
||||
TIMEOUT_ENV = "SEMANTIC_TIMEOUT_SECONDS"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class SemanticConfig:
|
||||
enabled: bool = False
|
||||
model: str = DEFAULT_MODEL
|
||||
timeout: float = DEFAULT_TIMEOUT_SECONDS
|
||||
|
||||
|
||||
def load_config(env: Mapping[str, str] | None = None) -> SemanticConfig:
|
||||
values = env or os.environ
|
||||
return SemanticConfig(
|
||||
enabled=_parse_bool(values.get(ENABLED_ENV), default=False),
|
||||
model=values.get(MODEL_ENV) or DEFAULT_MODEL,
|
||||
timeout=_parse_timeout(values.get(TIMEOUT_ENV)),
|
||||
)
|
||||
|
||||
|
||||
def _parse_bool(value: str | None, *, default: bool) -> bool:
|
||||
if value is None:
|
||||
return default
|
||||
return value.strip().lower() in {"1", "true", "yes", "on", "enabled"}
|
||||
|
||||
|
||||
def _parse_timeout(value: str | None) -> float:
|
||||
if value is None:
|
||||
return DEFAULT_TIMEOUT_SECONDS
|
||||
try:
|
||||
timeout = float(value)
|
||||
except ValueError:
|
||||
return DEFAULT_TIMEOUT_SECONDS
|
||||
return timeout if timeout > 0 else DEFAULT_TIMEOUT_SECONDS
|
||||
Reference in New Issue
Block a user