Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!
Python
ux: Not prompt a timeout if a message was sent in the meantime
Clémence Lesné2cc560b2a4f1
diff --git a/app/helpers/call_llm.py b/app/helpers/call_llm.pyindex 3cc8f2b..6b8647e 100644--- a/app/helpers/call_llm.py+++ b/app/helpers/call_llm.py@@ -1,5 +1,6 @@import asynciofrom collections.abc import Awaitable, Callable+from datetime import UTC, datetime, timedeltafrom functools import wrapsimport aiojobs@@ -598,7 +599,16 @@ async def _in_audio( # noqa: PLR0913# Wait for silence and trigger timeouttimeout_sec = await phone_silence_timeout_sec()while call.in_progress:+ timeout_start = datetime.now(UTC)await asyncio.sleep(timeout_sec)+ if (+ call.messages[-1].created_at + timedelta(seconds=timeout_sec)+ > timeout_start+ ):+ logger.debug(+ "Message sent in the meantime, canceling this silence timeout"+ )+ continuelogger.info("Silence triggered after %i sec", timeout_sec)await timeout_callback()