Update idle count will reset when user active again

This commit is contained in:
Xin Wang
2026-05-29 16:44:01 +08:00
parent 050ecc7a2d
commit 991c8a02e7

View File

@@ -10,6 +10,7 @@ from pipecat.frames.frames import (
LLMRunFrame,
OutputTransportMessageUrgentFrame,
TTSSpeakFrame,
UserStartedSpeakingFrame,
)
from pipecat.pipeline.pipeline import Pipeline
from pipecat.pipeline.runner import PipelineRunner
@@ -189,6 +190,7 @@ async def run_pipeline_with_serializer(
),
idle_timeout_secs=config.session.inactivity_timeout_sec,
)
task.set_reached_upstream_filter((UserStartedSpeakingFrame,))
idle_prompt_count = 0
@transport.event_handler("on_client_connected")
@@ -218,6 +220,11 @@ async def run_pipeline_with_serializer(
logger.info(f"{client_label} websocket session timed out")
await task.cancel()
@task.event_handler("on_frame_reached_upstream")
async def on_frame_reached_upstream(_task, _frame: UserStartedSpeakingFrame):
nonlocal idle_prompt_count
idle_prompt_count = 0
@user_aggregator.event_handler("on_user_turn_started")
async def on_user_turn_started(_aggregator, _strategy):
nonlocal idle_prompt_count