Inline STT and tray

This commit is contained in:
Thales Maciel 2026-02-24 11:27:22 -03:00
parent 8c68719041
commit 4e8edc3e40
No known key found for this signature in database
GPG key ID: 33112E6833C34679
8 changed files with 109 additions and 171 deletions

View file

@ -12,7 +12,6 @@ class Config:
ai_cleanup: dict = field(
default_factory=lambda: {
"model": "llama3.2:3b",
"temperature": 0.0,
"base_url": "http://localhost:11434",
"api_key": "",
}
@ -30,7 +29,7 @@ def load(path: str | None) -> Config:
p = Path(path) if path else default_path()
if p.exists():
data = json.loads(p.read_text(encoding="utf-8"))
if any(k in data for k in ("daemon", "recording", "stt", "injection", "ai_cleanup", "ai")):
if any(k in data for k in ("daemon", "recording", "stt", "injection", "ai_cleanup")):
for k, v in data.items():
if hasattr(cfg, k):
setattr(cfg, k, v)
@ -41,7 +40,6 @@ def load(path: str | None) -> Config:
cfg.stt["device"] = data.get("whisper_device", cfg.stt["device"])
cfg.injection["backend"] = data.get("injection_backend", cfg.injection["backend"])
cfg.ai_cleanup["model"] = data.get("ai_model", cfg.ai_cleanup["model"])
cfg.ai_cleanup["temperature"] = data.get("ai_temperature", cfg.ai_cleanup["temperature"])
cfg.ai_cleanup["base_url"] = data.get("ai_base_url", cfg.ai_cleanup["base_url"])
cfg.ai_cleanup["api_key"] = data.get("ai_api_key", cfg.ai_cleanup["api_key"])
@ -56,20 +54,9 @@ def load(path: str | None) -> Config:
if not isinstance(cfg.ai_cleanup, dict):
cfg.ai_cleanup = {
"model": "llama3.2:3b",
"temperature": 0.0,
"base_url": "http://localhost:11434",
"api_key": "",
}
legacy_ai = getattr(cfg, "ai", None)
if isinstance(legacy_ai, dict) and not cfg.ai_cleanup:
cfg.ai_cleanup = legacy_ai
try:
delattr(cfg, "ai")
except AttributeError:
pass
except Exception:
pass
validate(cfg)
return cfg