mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-01 08:21:50 +08:00
fix(tts): tolerate missing hermes_cli.config in tts_tool import
Wrap the new top-level `from hermes_cli.config import get_env_value` in try/except ImportError and fall back to a thin os.getenv shim, so importing tools.tts_tool keeps working in environments where hermes_cli.config is unavailable. This matches the existing tolerance in `_load_tts_config()` (tools/tts_tool.py) and the same import-fallback pattern in tools/tool_backend_helpers.py::fal_key_is_configured. Also update the TestDotenvFallbackPerProvider docstring to accurately describe the mocking strategy: per-provider tests patch `tools.tts_tool.get_env_value` directly, while the regression-guard tests cover the lower-level `hermes_cli.config.load_env` integration. Addresses Copilot review on #17163. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -34,9 +34,12 @@ def isolate_env(monkeypatch):
|
||||
|
||||
class TestDotenvFallbackPerProvider:
|
||||
"""For each affected provider, when only ``~/.hermes/.env`` carries the
|
||||
key (mocked via ``hermes_cli.config.load_env``), the provider must find
|
||||
it. Before the fix, ``os.getenv`` returned ``None`` and the provider
|
||||
raised ``ValueError("X_API_KEY not set")``.
|
||||
key, the provider must find it. These per-provider tests model that
|
||||
dotenv-backed lookup by mocking ``tools.tts_tool.get_env_value`` directly;
|
||||
the separate regression-guard tests cover the lower-level
|
||||
``hermes_cli.config.load_env`` integration. Before the fix, ``os.getenv``
|
||||
returned ``None`` and the provider raised
|
||||
``ValueError("X_API_KEY not set")``.
|
||||
"""
|
||||
|
||||
def test_elevenlabs_reads_dotenv_key(self, tmp_path):
|
||||
|
||||
Reference in New Issue
Block a user