Add multilingual STT support and config UI/runtime updates
This commit is contained in:
parent
ed950cb7c4
commit
4a69c3d333
26 changed files with 2207 additions and 465 deletions
60
tests/test_config_ui.py
Normal file
60
tests/test_config_ui.py
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SRC = ROOT / "src"
|
||||
if str(SRC) not in sys.path:
|
||||
sys.path.insert(0, str(SRC))
|
||||
|
||||
from config import Config
|
||||
from config_ui import (
|
||||
RUNTIME_MODE_EXPERT,
|
||||
RUNTIME_MODE_MANAGED,
|
||||
apply_canonical_runtime_defaults,
|
||||
infer_runtime_mode,
|
||||
)
|
||||
|
||||
|
||||
class ConfigUiRuntimeModeTests(unittest.TestCase):
|
||||
def test_infer_runtime_mode_defaults_to_managed(self):
|
||||
cfg = Config()
|
||||
self.assertEqual(infer_runtime_mode(cfg), RUNTIME_MODE_MANAGED)
|
||||
|
||||
def test_infer_runtime_mode_detects_expert_overrides(self):
|
||||
cfg = Config()
|
||||
cfg.llm.provider = "external_api"
|
||||
cfg.external_api.enabled = True
|
||||
self.assertEqual(infer_runtime_mode(cfg), RUNTIME_MODE_EXPERT)
|
||||
|
||||
def test_apply_canonical_runtime_defaults_resets_expert_fields(self):
|
||||
cfg = Config()
|
||||
cfg.stt.provider = "local_whisper"
|
||||
cfg.llm.provider = "external_api"
|
||||
cfg.external_api.enabled = True
|
||||
cfg.external_api.base_url = "https://example.local/v1"
|
||||
cfg.external_api.model = "custom-model"
|
||||
cfg.external_api.api_key_env_var = "CUSTOM_KEY"
|
||||
cfg.external_api.timeout_ms = 321
|
||||
cfg.external_api.max_retries = 8
|
||||
cfg.models.allow_custom_models = True
|
||||
cfg.models.whisper_model_path = "/tmp/custom-whisper.bin"
|
||||
cfg.models.llm_model_path = "/tmp/custom-model.gguf"
|
||||
|
||||
apply_canonical_runtime_defaults(cfg)
|
||||
|
||||
self.assertEqual(cfg.stt.provider, "local_whisper")
|
||||
self.assertEqual(cfg.llm.provider, "local_llama")
|
||||
self.assertFalse(cfg.external_api.enabled)
|
||||
self.assertEqual(cfg.external_api.base_url, "https://api.openai.com/v1")
|
||||
self.assertEqual(cfg.external_api.model, "gpt-4o-mini")
|
||||
self.assertEqual(cfg.external_api.api_key_env_var, "AMAN_EXTERNAL_API_KEY")
|
||||
self.assertEqual(cfg.external_api.timeout_ms, 15000)
|
||||
self.assertEqual(cfg.external_api.max_retries, 2)
|
||||
self.assertFalse(cfg.models.allow_custom_models)
|
||||
self.assertEqual(cfg.models.whisper_model_path, "")
|
||||
self.assertEqual(cfg.models.llm_model_path, "")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue