Remove ai.enabled configuration support
This commit is contained in:
parent
ccf968a410
commit
2c570c7a87
5 changed files with 22 additions and 26 deletions
|
|
@ -94,7 +94,6 @@ Create `~/.config/lel/config.json`:
|
||||||
"backend": "clipboard",
|
"backend": "clipboard",
|
||||||
"remove_transcription_from_clipboard": false
|
"remove_transcription_from_clipboard": false
|
||||||
},
|
},
|
||||||
"ai": { "enabled": true },
|
|
||||||
"vocabulary": {
|
"vocabulary": {
|
||||||
"replacements": [
|
"replacements": [
|
||||||
{ "from": "Martha", "to": "Marta" },
|
{ "from": "Martha", "to": "Marta" },
|
||||||
|
|
@ -111,7 +110,6 @@ Create `~/.config/lel/config.json`:
|
||||||
Recording input can be a device index (preferred) or a substring of the device
|
Recording input can be a device index (preferred) or a substring of the device
|
||||||
name.
|
name.
|
||||||
|
|
||||||
`ai.enabled` is accepted for compatibility but currently has no runtime effect.
|
|
||||||
AI cleanup is always enabled and uses the locked local Llama-3.2-3B GGUF model
|
AI cleanup is always enabled and uses the locked local Llama-3.2-3B GGUF model
|
||||||
downloaded to `~/.cache/lel/models/` on first use.
|
downloaded to `~/.cache/lel/models/` on first use.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,6 @@
|
||||||
"backend": "clipboard",
|
"backend": "clipboard",
|
||||||
"remove_transcription_from_clipboard": false
|
"remove_transcription_from_clipboard": false
|
||||||
},
|
},
|
||||||
"ai": {
|
|
||||||
"enabled": true
|
|
||||||
},
|
|
||||||
"vocabulary": {
|
"vocabulary": {
|
||||||
"replacements": [
|
"replacements": [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -41,11 +41,6 @@ class InjectionConfig:
|
||||||
remove_transcription_from_clipboard: bool = False
|
remove_transcription_from_clipboard: bool = False
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class AiConfig:
|
|
||||||
enabled: bool = True
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class VocabularyReplacement:
|
class VocabularyReplacement:
|
||||||
source: str
|
source: str
|
||||||
|
|
@ -72,7 +67,6 @@ class Config:
|
||||||
recording: RecordingConfig = field(default_factory=RecordingConfig)
|
recording: RecordingConfig = field(default_factory=RecordingConfig)
|
||||||
stt: SttConfig = field(default_factory=SttConfig)
|
stt: SttConfig = field(default_factory=SttConfig)
|
||||||
injection: InjectionConfig = field(default_factory=InjectionConfig)
|
injection: InjectionConfig = field(default_factory=InjectionConfig)
|
||||||
ai: AiConfig = field(default_factory=AiConfig)
|
|
||||||
vocabulary: VocabularyConfig = field(default_factory=VocabularyConfig)
|
vocabulary: VocabularyConfig = field(default_factory=VocabularyConfig)
|
||||||
domain_inference: DomainInferenceConfig = field(default_factory=DomainInferenceConfig)
|
domain_inference: DomainInferenceConfig = field(default_factory=DomainInferenceConfig)
|
||||||
|
|
||||||
|
|
@ -119,9 +113,6 @@ def validate(cfg: Config) -> None:
|
||||||
if not isinstance(cfg.injection.remove_transcription_from_clipboard, bool):
|
if not isinstance(cfg.injection.remove_transcription_from_clipboard, bool):
|
||||||
raise ValueError("injection.remove_transcription_from_clipboard must be boolean")
|
raise ValueError("injection.remove_transcription_from_clipboard must be boolean")
|
||||||
|
|
||||||
if not isinstance(cfg.ai.enabled, bool):
|
|
||||||
raise ValueError("ai.enabled must be boolean")
|
|
||||||
|
|
||||||
cfg.vocabulary.max_rules = _validated_limit(cfg.vocabulary.max_rules, "vocabulary.max_rules")
|
cfg.vocabulary.max_rules = _validated_limit(cfg.vocabulary.max_rules, "vocabulary.max_rules")
|
||||||
cfg.vocabulary.max_terms = _validated_limit(cfg.vocabulary.max_terms, "vocabulary.max_terms")
|
cfg.vocabulary.max_terms = _validated_limit(cfg.vocabulary.max_terms, "vocabulary.max_terms")
|
||||||
|
|
||||||
|
|
@ -151,6 +142,10 @@ def _from_dict(data: dict[str, Any], cfg: Config) -> Config:
|
||||||
raise ValueError("logging section is no longer supported; use -v/--verbose")
|
raise ValueError("logging section is no longer supported; use -v/--verbose")
|
||||||
if "log_transcript" in data:
|
if "log_transcript" in data:
|
||||||
raise ValueError("log_transcript is no longer supported; use -v/--verbose")
|
raise ValueError("log_transcript is no longer supported; use -v/--verbose")
|
||||||
|
if "ai" in data:
|
||||||
|
raise ValueError("ai section is no longer supported")
|
||||||
|
if "ai_enabled" in data:
|
||||||
|
raise ValueError("ai_enabled is no longer supported")
|
||||||
|
|
||||||
has_sections = any(
|
has_sections = any(
|
||||||
key in data
|
key in data
|
||||||
|
|
@ -159,7 +154,6 @@ def _from_dict(data: dict[str, Any], cfg: Config) -> Config:
|
||||||
"recording",
|
"recording",
|
||||||
"stt",
|
"stt",
|
||||||
"injection",
|
"injection",
|
||||||
"ai",
|
|
||||||
"vocabulary",
|
"vocabulary",
|
||||||
"domain_inference",
|
"domain_inference",
|
||||||
)
|
)
|
||||||
|
|
@ -169,7 +163,6 @@ def _from_dict(data: dict[str, Any], cfg: Config) -> Config:
|
||||||
recording = _ensure_dict(data.get("recording"), "recording")
|
recording = _ensure_dict(data.get("recording"), "recording")
|
||||||
stt = _ensure_dict(data.get("stt"), "stt")
|
stt = _ensure_dict(data.get("stt"), "stt")
|
||||||
injection = _ensure_dict(data.get("injection"), "injection")
|
injection = _ensure_dict(data.get("injection"), "injection")
|
||||||
ai = _ensure_dict(data.get("ai"), "ai")
|
|
||||||
vocabulary = _ensure_dict(data.get("vocabulary"), "vocabulary")
|
vocabulary = _ensure_dict(data.get("vocabulary"), "vocabulary")
|
||||||
domain_inference = _ensure_dict(data.get("domain_inference"), "domain_inference")
|
domain_inference = _ensure_dict(data.get("domain_inference"), "domain_inference")
|
||||||
|
|
||||||
|
|
@ -188,8 +181,6 @@ def _from_dict(data: dict[str, Any], cfg: Config) -> Config:
|
||||||
injection["remove_transcription_from_clipboard"],
|
injection["remove_transcription_from_clipboard"],
|
||||||
"injection.remove_transcription_from_clipboard",
|
"injection.remove_transcription_from_clipboard",
|
||||||
)
|
)
|
||||||
if "enabled" in ai:
|
|
||||||
cfg.ai.enabled = _as_bool(ai["enabled"], "ai.enabled")
|
|
||||||
if "replacements" in vocabulary:
|
if "replacements" in vocabulary:
|
||||||
cfg.vocabulary.replacements = _as_replacements(vocabulary["replacements"])
|
cfg.vocabulary.replacements = _as_replacements(vocabulary["replacements"])
|
||||||
if "terms" in vocabulary:
|
if "terms" in vocabulary:
|
||||||
|
|
@ -218,8 +209,6 @@ def _from_dict(data: dict[str, Any], cfg: Config) -> Config:
|
||||||
cfg.stt.device = _as_nonempty_str(data["whisper_device"], "whisper_device")
|
cfg.stt.device = _as_nonempty_str(data["whisper_device"], "whisper_device")
|
||||||
if "injection_backend" in data:
|
if "injection_backend" in data:
|
||||||
cfg.injection.backend = _as_nonempty_str(data["injection_backend"], "injection_backend")
|
cfg.injection.backend = _as_nonempty_str(data["injection_backend"], "injection_backend")
|
||||||
if "ai_enabled" in data:
|
|
||||||
cfg.ai.enabled = _as_bool(data["ai_enabled"], "ai_enabled")
|
|
||||||
return cfg
|
return cfg
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ class ConfigTests(unittest.TestCase):
|
||||||
self.assertEqual(cfg.stt.device, "cpu")
|
self.assertEqual(cfg.stt.device, "cpu")
|
||||||
self.assertEqual(cfg.injection.backend, "clipboard")
|
self.assertEqual(cfg.injection.backend, "clipboard")
|
||||||
self.assertFalse(cfg.injection.remove_transcription_from_clipboard)
|
self.assertFalse(cfg.injection.remove_transcription_from_clipboard)
|
||||||
self.assertTrue(cfg.ai.enabled)
|
|
||||||
self.assertEqual(cfg.vocabulary.replacements, [])
|
self.assertEqual(cfg.vocabulary.replacements, [])
|
||||||
self.assertEqual(cfg.vocabulary.terms, [])
|
self.assertEqual(cfg.vocabulary.terms, [])
|
||||||
self.assertEqual(cfg.vocabulary.max_rules, 500)
|
self.assertEqual(cfg.vocabulary.max_rules, 500)
|
||||||
|
|
@ -43,7 +42,6 @@ class ConfigTests(unittest.TestCase):
|
||||||
"backend": "injection",
|
"backend": "injection",
|
||||||
"remove_transcription_from_clipboard": True,
|
"remove_transcription_from_clipboard": True,
|
||||||
},
|
},
|
||||||
"ai": {"enabled": False},
|
|
||||||
"vocabulary": {
|
"vocabulary": {
|
||||||
"replacements": [
|
"replacements": [
|
||||||
{"from": "Martha", "to": "Marta"},
|
{"from": "Martha", "to": "Marta"},
|
||||||
|
|
@ -67,7 +65,6 @@ class ConfigTests(unittest.TestCase):
|
||||||
self.assertEqual(cfg.stt.device, "cuda")
|
self.assertEqual(cfg.stt.device, "cuda")
|
||||||
self.assertEqual(cfg.injection.backend, "injection")
|
self.assertEqual(cfg.injection.backend, "injection")
|
||||||
self.assertTrue(cfg.injection.remove_transcription_from_clipboard)
|
self.assertTrue(cfg.injection.remove_transcription_from_clipboard)
|
||||||
self.assertFalse(cfg.ai.enabled)
|
|
||||||
self.assertEqual(cfg.vocabulary.max_rules, 100)
|
self.assertEqual(cfg.vocabulary.max_rules, 100)
|
||||||
self.assertEqual(cfg.vocabulary.max_terms, 200)
|
self.assertEqual(cfg.vocabulary.max_terms, 200)
|
||||||
self.assertEqual(len(cfg.vocabulary.replacements), 2)
|
self.assertEqual(len(cfg.vocabulary.replacements), 2)
|
||||||
|
|
@ -84,7 +81,6 @@ class ConfigTests(unittest.TestCase):
|
||||||
"whisper_model": "tiny",
|
"whisper_model": "tiny",
|
||||||
"whisper_device": "cpu",
|
"whisper_device": "cpu",
|
||||||
"injection_backend": "clipboard",
|
"injection_backend": "clipboard",
|
||||||
"ai_enabled": False,
|
|
||||||
}
|
}
|
||||||
with tempfile.TemporaryDirectory() as td:
|
with tempfile.TemporaryDirectory() as td:
|
||||||
path = Path(td) / "config.json"
|
path = Path(td) / "config.json"
|
||||||
|
|
@ -98,7 +94,6 @@ class ConfigTests(unittest.TestCase):
|
||||||
self.assertEqual(cfg.stt.device, "cpu")
|
self.assertEqual(cfg.stt.device, "cpu")
|
||||||
self.assertEqual(cfg.injection.backend, "clipboard")
|
self.assertEqual(cfg.injection.backend, "clipboard")
|
||||||
self.assertFalse(cfg.injection.remove_transcription_from_clipboard)
|
self.assertFalse(cfg.injection.remove_transcription_from_clipboard)
|
||||||
self.assertFalse(cfg.ai.enabled)
|
|
||||||
self.assertEqual(cfg.vocabulary.replacements, [])
|
self.assertEqual(cfg.vocabulary.replacements, [])
|
||||||
|
|
||||||
def test_invalid_injection_backend_raises(self):
|
def test_invalid_injection_backend_raises(self):
|
||||||
|
|
@ -119,6 +114,24 @@ class ConfigTests(unittest.TestCase):
|
||||||
with self.assertRaisesRegex(ValueError, "injection.remove_transcription_from_clipboard"):
|
with self.assertRaisesRegex(ValueError, "injection.remove_transcription_from_clipboard"):
|
||||||
load(str(path))
|
load(str(path))
|
||||||
|
|
||||||
|
def test_removed_ai_section_raises(self):
|
||||||
|
payload = {"ai": {"enabled": True}}
|
||||||
|
with tempfile.TemporaryDirectory() as td:
|
||||||
|
path = Path(td) / "config.json"
|
||||||
|
path.write_text(json.dumps(payload), encoding="utf-8")
|
||||||
|
|
||||||
|
with self.assertRaisesRegex(ValueError, "ai section is no longer supported"):
|
||||||
|
load(str(path))
|
||||||
|
|
||||||
|
def test_removed_legacy_ai_enabled_raises(self):
|
||||||
|
payload = {"ai_enabled": True}
|
||||||
|
with tempfile.TemporaryDirectory() as td:
|
||||||
|
path = Path(td) / "config.json"
|
||||||
|
path.write_text(json.dumps(payload), encoding="utf-8")
|
||||||
|
|
||||||
|
with self.assertRaisesRegex(ValueError, "ai_enabled is no longer supported"):
|
||||||
|
load(str(path))
|
||||||
|
|
||||||
def test_removed_logging_section_raises(self):
|
def test_removed_logging_section_raises(self):
|
||||||
payload = {"logging": {"log_transcript": True}}
|
payload = {"logging": {"log_transcript": True}}
|
||||||
with tempfile.TemporaryDirectory() as td:
|
with tempfile.TemporaryDirectory() as td:
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,6 @@ class FakeAudio:
|
||||||
class DaemonTests(unittest.TestCase):
|
class DaemonTests(unittest.TestCase):
|
||||||
def _config(self) -> Config:
|
def _config(self) -> Config:
|
||||||
cfg = Config()
|
cfg = Config()
|
||||||
cfg.ai.enabled = False
|
|
||||||
return cfg
|
return cfg
|
||||||
|
|
||||||
@patch("leld.stop_audio_recording", return_value=FakeAudio(8))
|
@patch("leld.stop_audio_recording", return_value=FakeAudio(8))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue