fix: address PR review round 4 — remove web UI, fix audio/import/interface issues

Remove web UI gateway (web.py, tests, docs, toolset, env vars, Platform.WEB
enum) per maintainer request — Nous is building their own official chat UI.

Fix 1: Replace sd.wait() with polling pattern in play_audio_file() to prevent
indefinite hang when audio device stalls (consistent with play_beep()).

Fix 2: Use importlib.util.find_spec() for faster_whisper/openai availability
checks instead of module-level imports that trigger heavy native library
loading (CUDA/cuDNN) at import time.

Fix 3: Remove inspect.signature() hack in _send_voice_reply() — add **kwargs
to Telegram send_voice() so all adapters accept metadata uniformly.

Fix 4: Make session loading resilient to removed platform enum values — skip
entries with unknown platforms instead of crashing the entire gateway.
This commit is contained in:
0xbyt4 2026-03-14 09:06:52 +03:00
parent 1ad5e0ed15
commit 35748a2fb0
17 changed files with 55 additions and 2930 deletions

View file

@ -390,33 +390,6 @@ class TestDiscordPlayTtsSkip:
# Web play_tts sends play_audio (not voice bubble)
# =====================================================================
class TestWebPlayTts:
"""Web adapter play_tts sends invisible play_audio, not a voice bubble."""
@pytest.mark.asyncio
async def test_play_tts_sends_play_audio(self, tmp_path):
from gateway.platforms.web import WebAdapter
from gateway.config import PlatformConfig
config = PlatformConfig(enabled=True, extra={
"port": 0, "host": "127.0.0.1", "token": "tok",
})
adapter = WebAdapter(config)
adapter._broadcast = AsyncMock()
adapter._media_dir = tmp_path / "media"
adapter._media_dir.mkdir()
audio_file = tmp_path / "test.ogg"
audio_file.write_bytes(b"fake audio")
result = await adapter.play_tts(chat_id="web", audio_path=str(audio_file))
assert result.success is True
payload = adapter._broadcast.call_args[0][0]
assert payload["type"] == "play_audio"
assert "/media/" in payload["url"]
# =====================================================================
# Help text + known commands
# =====================================================================