The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
"""Tests for the Speech-to-Text category in `hermes tools` (tools_config).
Covers the STT provider picker rows, config writes (stt.provider /
use_gateway), the model picker catalog, config-only checklist exclusion,
and the faster_whisper post-setup readiness hook.
"""
import sys
from pathlib import Path
from unittest.mock import MagicMock, patch
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
from hermes_cli.tools_config import (
STT_MODEL_CATALOG,
TOOL_CATEGORIES,
_checklist_toolset_keys,
_configure_stt_model,
_is_provider_active,
_write_provider_config,
apply_provider_selection,
)
def _stt_cat():
return TOOL_CATEGORIES["stt"]
def _stt_provider_named(name):
return next(p for p in _stt_cat()["providers"] if p["name"] == name)
class TestConfigWrites:
def test_write_provider_config_sets_stt_provider(self):
config = {"stt": {"use_gateway": True}}
prov = _stt_provider_named("Groq")
_write_provider_config(prov, config, managed_feature=None)
assert config["stt"]["provider"] == "groq"
# Legacy key is popped so the read-time shim can't override the pick.
assert "use_gateway" not in config["stt"]
def test_apply_provider_selection_stt(self):
config = {}
with patch(
"hermes_cli.tools_config.get_nous_subscription_features"
) as feats:
feats.return_value = MagicMock(
nous_auth_present=False, account_info=None
)
apply_provider_selection("stt", "OpenAI", config)
assert config["stt"]["provider"] == "openai"
class TestActiveDetection:
def test_active_matches_config(self):
config = {"stt": {"provider": "groq"}}
assert _is_provider_active(_stt_provider_named("Groq"), config)
assert not _is_provider_active(_stt_provider_named("OpenAI"), config)
def test_unset_provider_defaults_to_local(self):
assert _is_provider_active(_stt_provider_named("Local Whisper"), {})
class TestModelPicker:
def test_every_model_picker_lists_the_runtime_catalog(self):
"""Dashboard selects and Desktop suggestions offer exactly STT_MODEL_CATALOG per provider."""
import re
from hermes_cli.web_server_config import _SCHEMA_OVERRIDES
from tools.transcription_common import BUILTIN_STT_PROVIDERS, STT_MODEL_CONFIG_KEY
desktop = (Path(__file__).resolve().parents[2] / "apps/desktop/src/app/settings/constants.ts").read_text()
for provider, models in STT_MODEL_CATALOG.items():
key = f"stt.{provider}.{STT_MODEL_CONFIG_KEY.get(provider, 'model')}"
listed = re.search(rf"'{re.escape(key)}': \[([^\]]*)\]", desktop)
assert listed, key
desktop_models = re.findall(r"'([^']+)'", listed.group(1))
# Local sizes are listed smallest-first in the UIs; the catalog puts the default first.
same = set if provider == "local" else list
assert same(_SCHEMA_OVERRIDES[key]["options"]) == same(models), key
assert same(desktop_models) == same(models), key
assert set(_SCHEMA_OVERRIDES["stt.provider"]["options"]) == BUILTIN_STT_PROVIDERS - {"local_command"}
def test_configure_stt_model_defaults_to_current(self):
config = {"stt": {"openai": {"model": "gpt-transcribe"}}}
with patch(
"hermes_cli.tools_config._prompt_choice", return_value=0
) as pc:
_configure_stt_model("openai", config)
# default index should point at the currently configured model
args = pc.call_args[0]
assert args[2] == STT_MODEL_CATALOG["openai"].index("gpt-transcribe")
class TestConfigOnlyExclusion:
def test_stt_excluded_from_checklist_universe(self):
assert "stt" not in _checklist_toolset_keys("cli")
# sanity: tts (a real toolset) stays in
assert "tts" in _checklist_toolset_keys("cli")