fix: await message confirmation interruption
This commit is contained in:
@@ -104,6 +104,17 @@ ON_DEMAND_KNOWLEDGE_SYSTEM_HINT = (
|
||||
"先调用 search_knowledge_base 检索;回答资料事实时只根据检索内容,"
|
||||
"资料不足要明确说明。"
|
||||
)
|
||||
|
||||
|
||||
async def _interrupt_pipeline_output(
|
||||
source: FrameProcessor,
|
||||
worker: PipelineWorker,
|
||||
) -> None:
|
||||
"""Broadcast an interruption and wait until it crosses the media pipeline."""
|
||||
await source.broadcast_interruption()
|
||||
await worker.flush_pipeline(timeout=1.0)
|
||||
|
||||
|
||||
def _compact_knowledge_metadata(value: str, max_length: int) -> str:
|
||||
"""Keep tool metadata useful without letting it dominate the model context."""
|
||||
compact = " ".join(value.split())
|
||||
@@ -733,6 +744,10 @@ async def run_pipeline(
|
||||
current_enable_interrupt = enable_interrupt
|
||||
current_turn_config = normalized
|
||||
|
||||
async def interrupt_output() -> None:
|
||||
"""Stop active output through the same boundary as text/voice input."""
|
||||
await _interrupt_pipeline_output(user_input, worker)
|
||||
|
||||
|
||||
def set_system_prompt(text: str) -> None:
|
||||
"""替换上下文里的系统提示(节点切换时整体替换,而非追加)。"""
|
||||
@@ -766,6 +781,7 @@ async def run_pipeline(
|
||||
set_vision_scope=lambda scope: workflow_vision_scope.update(scope),
|
||||
vision_function=workflow_vision_function,
|
||||
set_input_enabled=lambda enabled: input_state.__setitem__("enabled", enabled),
|
||||
interrupt_output=interrupt_output,
|
||||
apply_turn_config=apply_workflow_turn_config,
|
||||
flow_global_functions=flow_global_functions,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user