dd1baee0e4
hermes_cli/runtime_provider._getenv was a 4-line copy of get_secret(name, default) or default; it becomes agent.secret_scope.get_secret_str (returns default only when the secret is genuinely unset, still raises UnscopedSecretError — a child's unscoped read is a spawn-site bug). The runtime_provider_backends/_custom siblings call it directly instead of via the origin module. tools/tts_tool, tools/transcription_tools and tools/xai_http each carried an identical get_env_value re-export kept "so tests can patch" it; the seam is hermes_cli.config.get_env_value, read lazily at call time. Callers (tts_streaming, tts_tool_providers, transcription_cloud, voice_client_config, tools_config) go there directly; resolve_provider_secret already defaults to it so the env_getter kwarg is gone. Tests repointed at the canonical; the two tests that only proved the shim forwarded are deleted. Behavior change: none.
69 lines
2.1 KiB
Python
69 lines
2.1 KiB
Python
"""Class-level base_url parity: every cloud TTS provider honors config base_url.
|
|
|
|
xAI, MiniMax, Gemini, OpenAI and DeepInfra already read
|
|
``tts.<provider>.base_url`` from config.yaml. This locks in the same
|
|
contract for the ElevenLabs and Mistral sections (the two that used to
|
|
hardcode the SDK default endpoint).
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import types
|
|
from unittest.mock import patch
|
|
|
|
import tools.tts_tool as tts
|
|
|
|
|
|
# ── ElevenLabs: base_url/wss_url → ElevenLabsEnvironment ──────────────────
|
|
|
|
|
|
def _fake_elevenlabs_environment_module(captured: dict):
|
|
mod = types.ModuleType("elevenlabs.environment")
|
|
|
|
class ElevenLabsEnvironment:
|
|
def __init__(self, base, wss):
|
|
captured["base"] = base
|
|
captured["wss"] = wss
|
|
|
|
mod.ElevenLabsEnvironment = ElevenLabsEnvironment
|
|
pkg = types.ModuleType("elevenlabs")
|
|
pkg.environment = mod
|
|
return pkg, mod
|
|
|
|
|
|
def test_elevenlabs_no_base_url_uses_sdk_default_environment():
|
|
from tools.tts_tool_providers import _elevenlabs_environment_kwargs
|
|
|
|
assert _elevenlabs_environment_kwargs({}) == {}
|
|
assert _elevenlabs_environment_kwargs({"base_url": ""}) == {}
|
|
|
|
|
|
# ── Mistral: tts.mistral.base_url → SDK server_url ────────────────────────
|
|
|
|
|
|
def test_mistral_no_base_url_omits_server_url(tmp_path):
|
|
captured: dict = {}
|
|
|
|
class _FakeMistral:
|
|
def __init__(self, **kwargs):
|
|
captured.update(kwargs)
|
|
|
|
def __enter__(self):
|
|
return self
|
|
|
|
def __exit__(self, *args):
|
|
return False
|
|
|
|
class audio: # noqa: N801
|
|
class speech: # noqa: N801
|
|
@staticmethod
|
|
def complete(**kwargs):
|
|
return types.SimpleNamespace(audio_data="aGVsbG8=")
|
|
|
|
out = tmp_path / "out.mp3"
|
|
with patch.object(tts, "_import_mistral_client", return_value=_FakeMistral), \
|
|
patch("hermes_cli.config.get_env_value", lambda k, *a: "key" if k == "MISTRAL_API_KEY" else None):
|
|
tts._generate_mistral_tts("hi", str(out), {"mistral": {}})
|
|
|
|
assert "server_url" not in captured
|