Skip to content

Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!

Python

perf: Lower latency for cutting voice

Clémence Lesnébcf0a529c5e2
diff --git a/app/helpers/call_llm.py b/app/helpers/call_llm.py
index 5cf08ea..40d3df3 100644
--- a/app/helpers/call_llm.py
+++ b/app/helpers/call_llm.py
@@ -184,9 +184,6 @@ async def load_llm_chat( # noqa: PLR0913, PLR0915
Start the chat task and wait for its response if needed. Job is stored in `last_response` shared variable.
"""
- # Stop any previous response
- await _stop_callback()
-
# Start chat task
nonlocal last_response
last_response = await scheduler.spawn(
@@ -228,6 +225,9 @@ async def load_llm_chat( # noqa: PLR0913, PLR0915
await asyncio.sleep(0.2)
return await _response_callback(_retry=True)
+ # Stop any previous response
+ await _stop_callback()
+
# Add it to the call history and update last interaction
logger.info("Voice stored: %s", stt_buffer)
async with _db.call_transac(
@@ -242,9 +242,6 @@ async def load_llm_chat( # noqa: PLR0913, PLR0915
)
)
- # Clear the recognition buffer
- stt_buffer.clear()
-
# Process the response
await _commit_answer(wait=True)