Merge pull request #1394 from NousResearch/hermes/hermes-eca4a640

fix: honor stt.enabled false across gateway transcription
This commit is contained in:
Teknium 2026-03-14 22:11:47 -07:00 committed by GitHub
commit 84d99f7754
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 133 additions and 6 deletions

View file

@ -0,0 +1,53 @@
"""Gateway STT config tests — honor stt.enabled: false from config.yaml."""
from pathlib import Path
from unittest.mock import AsyncMock, patch
import pytest
import yaml
from gateway.config import GatewayConfig, load_gateway_config
def test_gateway_config_stt_disabled_from_dict_nested():
config = GatewayConfig.from_dict({"stt": {"enabled": False}})
assert config.stt_enabled is False
def test_load_gateway_config_bridges_stt_enabled_from_config_yaml(tmp_path, monkeypatch):
hermes_home = tmp_path / ".hermes"
hermes_home.mkdir()
(hermes_home / "config.yaml").write_text(
yaml.dump({"stt": {"enabled": False}}),
encoding="utf-8",
)
monkeypatch.setenv("HERMES_HOME", str(hermes_home))
monkeypatch.setattr(Path, "home", lambda: tmp_path)
config = load_gateway_config()
assert config.stt_enabled is False
@pytest.mark.asyncio
async def test_enrich_message_with_transcription_skips_when_stt_disabled():
from gateway.run import GatewayRunner
runner = GatewayRunner.__new__(GatewayRunner)
runner.config = GatewayConfig(stt_enabled=False)
with patch(
"tools.transcription_tools.transcribe_audio",
side_effect=AssertionError("transcribe_audio should not be called when STT is disabled"),
), patch(
"tools.transcription_tools.get_stt_model_from_config",
return_value=None,
):
result = await runner._enrich_message_with_transcription(
"caption",
["/tmp/voice.ogg"],
)
assert "transcription is disabled" in result.lower()
assert "caption" in result

View file

@ -59,6 +59,10 @@ class TestGetProvider:
from tools.transcription_tools import _get_provider
assert _get_provider({}) == "local"
def test_disabled_config_returns_none(self):
from tools.transcription_tools import _get_provider
assert _get_provider({"enabled": False, "provider": "openai"}) == "none"
# ---------------------------------------------------------------------------
# File validation
@ -217,6 +221,18 @@ class TestTranscribeAudio:
assert result["success"] is False
assert "No STT provider" in result["error"]
def test_disabled_config_returns_disabled_error(self, tmp_path):
audio_file = tmp_path / "test.ogg"
audio_file.write_bytes(b"fake audio")
with patch("tools.transcription_tools._load_stt_config", return_value={"enabled": False}), \
patch("tools.transcription_tools._get_provider", return_value="none"):
from tools.transcription_tools import transcribe_audio
result = transcribe_audio(str(audio_file))
assert result["success"] is False
assert "disabled" in result["error"].lower()
def test_invalid_file_returns_error(self):
from tools.transcription_tools import transcribe_audio
result = transcribe_audio("/nonexistent/file.ogg")