Update idle prompt

This commit is contained in:
Xin Wang
2026-05-29 11:01:24 +08:00
parent b4804c3884
commit 69c5941139
4 changed files with 38 additions and 2 deletions

View File

@@ -146,6 +146,7 @@ async def run_pipeline_with_serializer(
user_params=LLMUserAggregatorParams(
vad_analyzer=SileroVADAnalyzer(params=vad_params),
user_turn_strategies=user_turn_strategies,
user_idle_timeout=config.turn.idle_prompt_timeout_sec,
),
)
@@ -188,6 +189,7 @@ async def run_pipeline_with_serializer(
),
idle_timeout_secs=config.session.inactivity_timeout_sec,
)
idle_prompt_count = 0
@transport.event_handler("on_client_connected")
async def on_client_connected(_transport, _client):
@@ -216,6 +218,8 @@ async def run_pipeline_with_serializer(
@user_aggregator.event_handler("on_user_turn_stopped")
async def on_user_turn_stopped(_aggregator, _strategy, message: UserTurnStoppedMessage):
nonlocal idle_prompt_count
idle_prompt_count = 0
logger.info(f"User: {message.content}")
text = (message.content or "").strip()
if not text:
@@ -231,6 +235,17 @@ async def run_pipeline_with_serializer(
)
)
@user_aggregator.event_handler("on_user_turn_idle")
async def on_user_turn_idle(_aggregator):
nonlocal idle_prompt_count
text = config.turn.idle_prompt_text.strip()
if not text or idle_prompt_count >= config.turn.idle_prompt_max_count:
return
idle_prompt_count += 1
logger.info("User idle prompt triggered")
await task.queue_frames([TTSSpeakFrame(text)])
# NOTE: assistant turn started/final events are emitted by
# ProductTextStreamProcessor, upstream of TTS, so text streams to the
# client ahead of audio. This logger is kept for server-side visibility.