fix(telegram): separate voice transcription client (#166)
This commit is contained in:
@@ -135,6 +135,23 @@ def test_doctor_voice_checks(monkeypatch) -> None:
|
||||
monkeypatch.delenv("OPENAI_API_KEY", raising=False)
|
||||
checks = cli._doctor_voice_checks(settings)
|
||||
assert checks[0].status == "error"
|
||||
assert checks[0].detail == "API key not set"
|
||||
|
||||
settings_with_key = _settings(
|
||||
{
|
||||
"transports": {
|
||||
"telegram": {
|
||||
"bot_token": "token",
|
||||
"chat_id": 1,
|
||||
"voice_transcription": True,
|
||||
"voice_transcription_api_key": "local",
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
checks = cli._doctor_voice_checks(settings_with_key)
|
||||
assert checks[0].status == "ok"
|
||||
assert checks[0].detail == "voice_transcription_api_key set"
|
||||
|
||||
monkeypatch.setenv("OPENAI_API_KEY", "key")
|
||||
checks = cli._doctor_voice_checks(settings)
|
||||
|
||||
@@ -143,6 +143,8 @@ def test_telegram_backend_build_and_run_wires_config(
|
||||
voice_transcription=True,
|
||||
voice_max_bytes=1234,
|
||||
voice_transcription_model="whisper-1",
|
||||
voice_transcription_base_url="http://localhost:8000/v1",
|
||||
voice_transcription_api_key="local",
|
||||
files=TelegramFilesSettings(enabled=True, allowed_user_ids=[1, 2]),
|
||||
topics=TelegramTopicsSettings(enabled=True, scope="main"),
|
||||
)
|
||||
@@ -161,6 +163,8 @@ def test_telegram_backend_build_and_run_wires_config(
|
||||
assert cfg.voice_transcription is True
|
||||
assert cfg.voice_max_bytes == 1234
|
||||
assert cfg.voice_transcription_model == "whisper-1"
|
||||
assert cfg.voice_transcription_base_url == "http://localhost:8000/v1"
|
||||
assert cfg.voice_transcription_api_key == "local"
|
||||
assert cfg.files.enabled is True
|
||||
assert cfg.files.allowed_user_ids == [1, 2]
|
||||
assert cfg.topics.enabled is True
|
||||
|
||||
@@ -1954,8 +1954,10 @@ async def test_run_main_loop_voice_transcript_preserves_directive(
|
||||
model: str,
|
||||
max_bytes: int | None = None,
|
||||
reply,
|
||||
base_url: str | None = None,
|
||||
api_key: str | None = None,
|
||||
) -> str:
|
||||
_ = bot, msg, enabled, model, max_bytes, reply
|
||||
_ = bot, msg, enabled, model, max_bytes, reply, base_url, api_key
|
||||
return "/codex do thing"
|
||||
|
||||
monkeypatch.setattr(telegram_loop, "transcribe_voice", _fake_transcribe)
|
||||
|
||||
Reference in New Issue
Block a user