feat(workflow): add edge-tool routing and realtime runtime
This commit is contained in:
@@ -19,6 +19,7 @@ from pipecat.frames.frames import (
|
||||
FunctionCallCancelFrame,
|
||||
FunctionCallResultFrame,
|
||||
FunctionCallsStartedFrame,
|
||||
InputAudioRawFrame,
|
||||
InputTransportMessageFrame,
|
||||
InterruptionFrame,
|
||||
LLMContextFrame,
|
||||
@@ -520,11 +521,26 @@ class RealtimeDynamicVariableProcessor(FrameProcessor):
|
||||
await self.push_frame(frame, direction)
|
||||
|
||||
|
||||
class RealtimeInputAudioGateProcessor(FrameProcessor):
|
||||
"""Drop live microphone frames while a deterministic node owns the turn."""
|
||||
|
||||
def __init__(self, is_enabled: Callable[[], bool]):
|
||||
super().__init__()
|
||||
self._is_enabled = is_enabled
|
||||
|
||||
async def process_frame(self, frame, direction: FrameDirection):
|
||||
await super().process_frame(frame, direction)
|
||||
if isinstance(frame, InputAudioRawFrame) and not self._is_enabled():
|
||||
return
|
||||
await self.push_frame(frame, direction)
|
||||
|
||||
|
||||
class RealtimeUserInputProcessor(FrameProcessor):
|
||||
"""Route text-only user-input messages to a realtime service."""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, should_ignore_input: Callable[[], bool] | None = None):
|
||||
super().__init__()
|
||||
self._should_ignore_input = should_ignore_input or (lambda: False)
|
||||
self._register_event_handler("on_user_input")
|
||||
|
||||
async def process_frame(self, frame, direction: FrameDirection):
|
||||
@@ -542,6 +558,12 @@ class RealtimeUserInputProcessor(FrameProcessor):
|
||||
if user_input is None:
|
||||
await self.push_frame(frame, direction)
|
||||
return
|
||||
if self._should_ignore_input():
|
||||
await self._emit_error(
|
||||
user_input.input_id,
|
||||
"当前工作流节点暂不接收用户输入",
|
||||
)
|
||||
return
|
||||
if user_input.has_camera_frame:
|
||||
await self._emit_error(
|
||||
user_input.input_id,
|
||||
|
||||
Reference in New Issue
Block a user