simplify(compat): tools/wake_word — drop 5 re-exports, repoint 1 test
This commit is contained in:
+1
-1
@@ -104,7 +104,7 @@ if not _loaded_env_paths:
|
||||
|
||||
|
||||
from model_tools import get_tool_definitions, get_toolset_for_tool, handle_function_call, check_toolset_requirements # noqa: F401
|
||||
from tools.terminal_tool import cleanup_vm, get_active_env
|
||||
from tools.terminal_tool_lifecycle import cleanup_vm, get_active_env
|
||||
from tools.interrupt import set_interrupt as _set_interrupt
|
||||
from tools.browser_tool import cleanup_browser
|
||||
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
"""Regression coverage for machine-readable MoA quiet output."""
|
||||
from __future__ import annotations
|
||||
|
||||
from types import SimpleNamespace
|
||||
import unittest
|
||||
|
||||
from agent.agent_init import _relay_moa_reference_event
|
||||
|
||||
|
||||
class MoAQuietReferenceOutputTests(unittest.TestCase):
|
||||
@staticmethod
|
||||
def _agent(*, platform: str, tool_progress_mode: str, quiet_mode: bool = True):
|
||||
calls = []
|
||||
|
||||
def callback(*args, **kwargs):
|
||||
calls.append((args, kwargs))
|
||||
|
||||
return SimpleNamespace(
|
||||
platform=platform,
|
||||
tool_progress_mode=tool_progress_mode,
|
||||
quiet_mode=quiet_mode,
|
||||
tool_progress_callback=callback,
|
||||
), calls
|
||||
|
||||
def test_machine_readable_cli_suppresses_reference_relay(self) -> None:
|
||||
agent, calls = self._agent(platform="cli", tool_progress_mode="off")
|
||||
_relay_moa_reference_event(
|
||||
agent,
|
||||
"moa.reference",
|
||||
label="local:advisor",
|
||||
text="hidden",
|
||||
index=1,
|
||||
count=1,
|
||||
)
|
||||
self.assertEqual(calls, [])
|
||||
|
||||
def test_interactive_cli_delivers_reference_relay(self) -> None:
|
||||
agent, calls = self._agent(
|
||||
platform="cli",
|
||||
tool_progress_mode="all",
|
||||
quiet_mode=True,
|
||||
)
|
||||
_relay_moa_reference_event(
|
||||
agent,
|
||||
"moa.reference",
|
||||
label="local:advisor",
|
||||
text="visible",
|
||||
index=1,
|
||||
count=2,
|
||||
)
|
||||
self.assertEqual(
|
||||
calls,
|
||||
[
|
||||
(
|
||||
("moa.reference", "local:advisor", "visible", None),
|
||||
{"moa_index": 1, "moa_count": 2},
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
def test_gateway_delivers_even_when_progress_mode_is_off(self) -> None:
|
||||
agent, calls = self._agent(platform="discord", tool_progress_mode="off")
|
||||
_relay_moa_reference_event(
|
||||
agent,
|
||||
"moa.aggregating",
|
||||
aggregator="local:aggregator",
|
||||
ref_count=2,
|
||||
)
|
||||
self.assertEqual(
|
||||
calls,
|
||||
[
|
||||
(
|
||||
("moa.aggregating", "local:aggregator", None, None),
|
||||
{"moa_ref_count": 2},
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -55,9 +55,10 @@ def test_wake_surface_enabled_gate():
|
||||
|
||||
|
||||
def test_looks_like_path():
|
||||
assert ww._looks_like_path("models/hey_hermes.onnx")
|
||||
assert ww._looks_like_path("custom.ppn")
|
||||
assert not ww._looks_like_path("hey_jarvis")
|
||||
from tools.wake_word_engines import _looks_like_path
|
||||
assert _looks_like_path("models/hey_hermes.onnx")
|
||||
assert _looks_like_path("custom.ppn")
|
||||
assert not _looks_like_path("hey_jarvis")
|
||||
|
||||
|
||||
def test_load_wake_word_config_is_a_dict_with_defaults():
|
||||
|
||||
+1
-4
@@ -21,10 +21,7 @@ from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, Dict, Optional
|
||||
|
||||
from tools.wake_word_engines import ( # noqa: F401 (re-exported for callers/tests)
|
||||
_SHERPA_KWS_MODEL_DIR, _SHERPA_KWS_MODEL_URL, _Engine, _OpenWakeWordEngine, _PorcupineEngine,
|
||||
_SherpaKwsEngine, _ensure_sherpa_model, _looks_like_path, _sherpa_model_root, _sub,
|
||||
)
|
||||
from tools.wake_word_engines import _Engine, _OpenWakeWordEngine, _PorcupineEngine, _SherpaKwsEngine, _sub
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
"""Wake-word hotword engines (openWakeWord / sherpa-onnx KWS / Porcupine).
|
||||
|
||||
All three run fully on-device. Config, platform probes and sensitivity accessors
|
||||
live in :mod:`tools.wake_word`; engines read them lazily through that module so
|
||||
test seams (``patch("tools.wake_word.<name>")``) keep working.
|
||||
live in :mod:`tools.wake_word`; engines read them lazily through that module (import cycle).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
Reference in New Issue
Block a user