From 9f6a1c093a5114967f702a235ae6ed9c03d6fa91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Wed, 12 Feb 2025 23:54:59 -0800 Subject: [PATCH] LLMUserContextAggregator: reset user speaking time after bot interruption --- src/pipecat/processors/aggregators/llm_response.py | 2 ++ tests/test_llm_response.py | 1 + 2 files changed, 3 insertions(+) diff --git a/src/pipecat/processors/aggregators/llm_response.py b/src/pipecat/processors/aggregators/llm_response.py index 850c0ca27..1f50119fd 100644 --- a/src/pipecat/processors/aggregators/llm_response.py +++ b/src/pipecat/processors/aggregators/llm_response.py @@ -326,6 +326,8 @@ class LLMUserContextAggregator(LLMContextResponseAggregator): diff_time = time.time() - self._last_user_speaking_time if diff_time > self._bot_interruption_timeout: await self.push_frame(BotInterruptionFrame(), FrameDirection.UPSTREAM) + # Reset time so we don't interrupt again right away. + self._last_user_speaking_time = time.time() class LLMAssistantContextAggregator(LLMContextResponseAggregator): diff --git a/tests/test_llm_response.py b/tests/test_llm_response.py index 1d71217a2..e0026f5b5 100644 --- a/tests/test_llm_response.py +++ b/tests/test_llm_response.py @@ -343,6 +343,7 @@ class BaseTestUserContextAggregator: aggregator = self.AGGREGATOR_CLASS(context, aggregation_timeout=AGGREGATION_TIMEOUT) frames_to_send = [ InterimTranscriptionFrame(text="Hello ", user_id="cat", timestamp=""), + SleepFrame(), TranscriptionFrame(text="Hello Pipecat!", user_id="cat", timestamp=""), SleepFrame(sleep=AGGREGATION_SLEEP), ]