Try to fix confirm and interrupt
This commit is contained in:
@@ -107,19 +107,19 @@ ON_DEMAND_KNOWLEDGE_SYSTEM_HINT = (
|
||||
)
|
||||
|
||||
|
||||
async def _wait_for_interrupted_output(
|
||||
worker: PipelineWorker,
|
||||
async def _wait_for_output_stop(
|
||||
wait_until_stopped: Callable[[], Awaitable[None]],
|
||||
*,
|
||||
wait_until_stopped: Callable[[], Awaitable[None]] | None = None,
|
||||
timeout_seconds: float = 3.0,
|
||||
) -> None:
|
||||
"""Wait until an in-band interruption crosses pipeline and playback."""
|
||||
if not await worker.flush_pipeline(timeout=2.0):
|
||||
raise RuntimeError("输出中断帧未能及时穿过媒体管线")
|
||||
if wait_until_stopped is not None:
|
||||
try:
|
||||
await asyncio.wait_for(wait_until_stopped(), timeout=2.0)
|
||||
except TimeoutError as exc:
|
||||
raise RuntimeError("等待客户端语音停止超时") from exc
|
||||
"""Wait for the transport's real stop event after an interruption."""
|
||||
try:
|
||||
await asyncio.wait_for(
|
||||
wait_until_stopped(),
|
||||
timeout=timeout_seconds,
|
||||
)
|
||||
except TimeoutError as exc:
|
||||
raise RuntimeError("等待客户端语音停止超时") from exc
|
||||
|
||||
|
||||
def _compact_knowledge_metadata(value: str, max_length: int) -> str:
|
||||
@@ -753,14 +753,8 @@ async def run_pipeline(
|
||||
|
||||
async def wait_for_output_stopped() -> None:
|
||||
"""Keep workflow continuation behind the interrupted output."""
|
||||
wait_until_stopped = (
|
||||
call_end.wait_until_silent if call_end.speaking else None
|
||||
)
|
||||
await _wait_for_interrupted_output(
|
||||
worker,
|
||||
wait_until_stopped=wait_until_stopped,
|
||||
)
|
||||
|
||||
if call_end.speaking:
|
||||
await _wait_for_output_stop(call_end.wait_until_silent)
|
||||
|
||||
def set_system_prompt(text: str) -> None:
|
||||
"""替换上下文里的系统提示(节点切换时整体替换,而非追加)。"""
|
||||
|
||||
Reference in New Issue
Block a user