The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tools): address Copilot review on Groq STT language hint
Mate Remiasbe109982647e
diff --git a/cli-config.yaml.example b/cli-config.yaml.exampleindex 9ad8788a96f..c5097e9fbee 100644--- a/cli-config.yaml.example+++ b/cli-config.yaml.example@@ -1128,7 +1128,7 @@ stt:model: "base" # tiny | base | small | medium | large-v3 | turbo# language: "" # auto-detect; set to "en", "es", "fr", etc. to force# groq:- # language: "" # auto-detect; set to "en", "es", "fr", etc. to force+ # language: "" # blank = use HERMES_LOCAL_STT_LANGUAGE if set, else auto-detectopenai:model: "whisper-1" # whisper-1 | gpt-4o-mini-transcribe | gpt-4o-transcribelanguage: "" # auto-detect; set to "en", "es", "fr", etc. to forcediff --git a/tests/tools/test_transcription_tools.py b/tests/tools/test_transcription_tools.pyindex 0997872c69f..0dbebda66b8 100644--- a/tests/tools/test_transcription_tools.py+++ b/tests/tools/test_transcription_tools.py@@ -311,6 +311,95 @@ class TestTranscribeGroq:assert result["success"] is Falseassert "Permission denied" in result["error"]+ def test_language_hint_omitted_when_unset(self, monkeypatch, sample_wav):+ monkeypatch.setenv("GROQ_API_KEY", "gsk-test")+ monkeypatch.delenv("HERMES_LOCAL_STT_LANGUAGE", raising=False)++ mock_client = MagicMock()+ mock_client.audio.transcriptions.create.return_value = "hi"++ with patch("tools.transcription_tools._HAS_OPENAI", True), \+ patch("openai.OpenAI", return_value=mock_client), \+ patch("tools.transcription_tools._load_stt_config", return_value={}):+ from tools.transcription_tools import _transcribe_groq+ _transcribe_groq(sample_wav, "whisper-large-v3-turbo")++ kwargs = mock_client.audio.transcriptions.create.call_args.kwargs+ assert "language" not in kwargs++ def test_language_hint_from_config(self, monkeypatch, sample_wav):+ monkeypatch.setenv("GROQ_API_KEY", "gsk-test")+ monkeypatch.delenv("HERMES_LOCAL_STT_LANGUAGE", raising=False)++ mock_client = MagicMock()+ mock_client.audio.transcriptions.create.return_value = "hola"++ with patch("tools.transcription_tools._HAS_OPENAI", True), \+ patch("openai.OpenAI", return_value=mock_client), \+ patch(+ "tools.transcription_tools._load_stt_config",+ return_value={"groq": {"language": "es"}},+ ):+ from tools.transcription_tools import _transcribe_groq+ _transcribe_groq(sample_wav, "whisper-large-v3-turbo")++ kwargs = mock_client.audio.transcriptions.create.call_args.kwargs+ assert kwargs["language"] == "es"++ def test_language_hint_from_env_when_config_missing(self, monkeypatch, sample_wav):+ monkeypatch.setenv("GROQ_API_KEY", "gsk-test")+ monkeypatch.setenv("HERMES_LOCAL_STT_LANGUAGE", "hu")++ mock_client = MagicMock()+ mock_client.audio.transcriptions.create.return_value = "szia"++ with patch("tools.transcription_tools._HAS_OPENAI", True), \+ patch("openai.OpenAI", return_value=mock_client), \+ patch("tools.transcription_tools._load_stt_config", return_value={}):+ from tools.transcription_tools import _transcribe_groq+ _transcribe_groq(sample_wav, "whisper-large-v3-turbo")++ kwargs = mock_client.audio.transcriptions.create.call_args.kwargs+ assert kwargs["language"] == "hu"++ def test_language_config_overrides_env(self, monkeypatch, sample_wav):+ monkeypatch.setenv("GROQ_API_KEY", "gsk-test")+ monkeypatch.setenv("HERMES_LOCAL_STT_LANGUAGE", "hu")++ mock_client = MagicMock()+ mock_client.audio.transcriptions.create.return_value = "hello"++ with patch("tools.transcription_tools._HAS_OPENAI", True), \+ patch("openai.OpenAI", return_value=mock_client), \+ patch(+ "tools.transcription_tools._load_stt_config",+ return_value={"groq": {"language": "en"}},+ ):+ from tools.transcription_tools import _transcribe_groq+ _transcribe_groq(sample_wav, "whisper-large-v3-turbo")++ kwargs = mock_client.audio.transcriptions.create.call_args.kwargs+ assert kwargs["language"] == "en"++ def test_language_whitespace_treated_as_unset(self, monkeypatch, sample_wav):+ monkeypatch.setenv("GROQ_API_KEY", "gsk-test")+ monkeypatch.delenv("HERMES_LOCAL_STT_LANGUAGE", raising=False)++ mock_client = MagicMock()+ mock_client.audio.transcriptions.create.return_value = "hi"++ with patch("tools.transcription_tools._HAS_OPENAI", True), \+ patch("openai.OpenAI", return_value=mock_client), \+ patch(+ "tools.transcription_tools._load_stt_config",+ return_value={"groq": {"language": " "}},+ ):+ from tools.transcription_tools import _transcribe_groq+ _transcribe_groq(sample_wav, "whisper-large-v3-turbo")++ kwargs = mock_client.audio.transcriptions.create.call_args.kwargs+ assert "language" not in kwargs+# ============================================================================# _transcribe_openai — additional testsdiff --git a/tools/transcription_tools.py b/tools/transcription_tools.pyindex bef4b3b6302..1a724eda55c 100644--- a/tools/transcription_tools.py+++ b/tools/transcription_tools.py@@ -1321,7 +1321,9 @@ def _transcribe_groq(file_path: str, model_name: str) -> Dict[str, Any]:model_name = DEFAULT_GROQ_STT_MODELgroq_cfg = _load_stt_config().get("groq", {})- language = groq_cfg.get("language") or os.getenv(LOCAL_STT_LANGUAGE_ENV)+ language = str(+ groq_cfg.get("language") or os.getenv(LOCAL_STT_LANGUAGE_ENV) or ""+ ).strip() or Nonetry:from openai import OpenAI, APIError, APIConnectionError, APITimeoutErrordiff --git a/website/docs/reference/environment-variables.md b/website/docs/reference/environment-variables.mdindex ac73691ea46..ec99660fd78 100644--- a/website/docs/reference/environment-variables.md+++ b/website/docs/reference/environment-variables.md@@ -102,7 +102,7 @@ Hermes reads environment variables from the process environment and, for user-ma| `HERMES_MODEL` | Override model name at process level (used by cron scheduler; prefer `config.yaml` for normal use) || `VOICE_TOOLS_OPENAI_KEY` | Preferred OpenAI key for OpenAI speech-to-text and text-to-speech providers || `HERMES_LOCAL_STT_COMMAND` | Optional local speech-to-text command template. Supports `{input_path}`, `{output_dir}`, `{language}`, and `{model}` placeholders |-| `HERMES_LOCAL_STT_LANGUAGE` | Default language hint for STT. Used by `HERMES_LOCAL_STT_COMMAND`, the local `whisper` CLI fallback (default: `en`), Groq, and xAI when no per-provider `language` is set in `config.yaml` |+| `HERMES_LOCAL_STT_LANGUAGE` | Default language hint for STT. Used by the `local` (faster-whisper) provider, `HERMES_LOCAL_STT_COMMAND`, the local `whisper` CLI fallback (default: `en`), Groq, and xAI when no per-provider `language` is set in `config.yaml` || `HERMES_HOME` | Override Hermes config directory (default: `~/.hermes`). Also scopes the gateway PID file and systemd service name, so multiple installations can run concurrently || `HERMES_GIT_BASH_PATH` | **Windows only.** Override `bash.exe` discovery for the terminal tool. Points at any bash — full Git-for-Windows install, WSL bash via symlink, MSYS2, Cygwin. The installer sets this automatically to the PortableGit it provisioned. See the [Windows (Native) Guide](../user-guide/windows-native.md#how-hermes-runs-shell-commands-on-windows) || `HERMES_DISABLE_WINDOWS_UTF8` | **Windows only.** Set to `1` to disable the UTF-8 stdio shim (`configure_windows_stdio()`) and fall back to the console's locale code page. Useful for bisecting encoding bugs; rarely the right setting in normal operation |diff --git a/website/docs/user-guide/configuration.md b/website/docs/user-guide/configuration.mdindex f55bd139db4..8fa1ddc65ff 100644--- a/website/docs/user-guide/configuration.md+++ b/website/docs/user-guide/configuration.md@@ -1715,9 +1715,9 @@ stt:provider: "local" # "local" | "groq" | "openai" | "mistral"local:model: "base" # tiny, base, small, medium, large-v3- language: "" # optional ISO-639-1 hint (e.g. "en"); blank = auto-detect+ language: "" # optional ISO-639-1 hint; blank = use HERMES_LOCAL_STT_LANGUAGE if set, else auto-detectgroq:- language: "" # optional ISO-639-1 hint (e.g. "en"); blank = auto-detect+ language: "" # optional ISO-639-1 hint; blank = use HERMES_LOCAL_STT_LANGUAGE if set, else auto-detectopenai:model: "whisper-1" # whisper-1 | gpt-4o-mini-transcribe | gpt-4o-transcribelanguage: "" # auto-detect; set to "en", "es", "fr", etc. to forcediff --git a/website/docs/user-guide/features/tts.md b/website/docs/user-guide/features/tts.mdindex 2d8ceb228d7..920f360f7a3 100644--- a/website/docs/user-guide/features/tts.md+++ b/website/docs/user-guide/features/tts.md@@ -429,16 +429,16 @@ stt:provider: "local" # "local" | "groq" | "openai" | "mistral" | "xai"local:model: "base" # tiny, base, small, medium, large-v3- language: "" # optional ISO-639-1 hint (e.g. "en"); blank = auto-detect+ language: "" # optional ISO-639-1 hint; blank = use HERMES_LOCAL_STT_LANGUAGE if set, else auto-detectgroq:- language: "" # optional ISO-639-1 hint (e.g. "en"); blank = auto-detect+ language: "" # optional ISO-639-1 hint; blank = use HERMES_LOCAL_STT_LANGUAGE if set, else auto-detectopenai:model: "whisper-1" # whisper-1, gpt-4o-mini-transcribe, gpt-4o-transcribemistral:model: "voxtral-mini-latest" # voxtral-mini-latest, voxtral-mini-2602xai:model: "grok-stt" # xAI Grok STT- language: "" # optional ISO-639-1 hint+ language: "" # optional ISO-639-1 hint; blank = use HERMES_LOCAL_STT_LANGUAGE if set, else "en"```### Provider Detailsdiff --git a/website/docs/user-guide/features/voice-mode.md b/website/docs/user-guide/features/voice-mode.mdindex b10ef0dff7c..a4f64be3f3a 100644--- a/website/docs/user-guide/features/voice-mode.md+++ b/website/docs/user-guide/features/voice-mode.md@@ -414,9 +414,9 @@ stt:provider: "local" # "local" (free) | "groq" | "openai" | "mistral" | "xai"local:model: "base" # tiny, base, small, medium, large-v3- language: "" # optional ISO-639-1 hint (e.g. "en"); blank = auto-detect+ language: "" # optional ISO-639-1 hint; blank = use HERMES_LOCAL_STT_LANGUAGE if set, else auto-detectgroq:- language: "" # optional ISO-639-1 hint (e.g. "en"); blank = auto-detect+ language: "" # optional ISO-639-1 hint; blank = use HERMES_LOCAL_STT_LANGUAGE if set, else auto-detect# model: "whisper-1" # Legacy: used when provider is not set# Text-to-Speech