feat: add optional bot backchannels to prompt pipelines
This commit is contained in:
@@ -14,6 +14,7 @@ from models import AssistantConfig
|
||||
from services.brains import Brain, BrainRuntime, build_brain
|
||||
from services.brains.base import RealtimeBrainRuntime
|
||||
from services.conversation_history import ConversationRecorder
|
||||
from services.pipecat.backchannel import BotBackchannelProcessor
|
||||
from services.pipecat.call_lifecycle import (
|
||||
CallEndCoordinator,
|
||||
EndCallAfterSpeechProcessor,
|
||||
@@ -722,6 +723,14 @@ async def run_pipeline(
|
||||
protocol_adapter.inference_processors() if protocol_adapter else []
|
||||
)
|
||||
protocol_outputs = protocol_adapter.output_processors() if protocol_adapter else []
|
||||
backchannel_config = cfg.turnConfig.get("bot_backchannel", cfg.turnConfig.get("botBackchannel", {}))
|
||||
backchannel_processors = []
|
||||
if cfg.type == "prompt" and backchannel_config.get("enabled", False):
|
||||
backchannel_processors.append(BotBackchannelProcessor(
|
||||
delay_secs=float(backchannel_config.get("delay_secs", backchannel_config.get("delaySecs", 4))),
|
||||
can_speak=lambda: (call_end.accepts_input and not call_end.ending
|
||||
and input_state["enabled"] and not tool_interruption_strategy.is_muted),
|
||||
))
|
||||
pipeline = Pipeline(
|
||||
[
|
||||
transport.input(),
|
||||
@@ -740,6 +749,7 @@ async def run_pipeline(
|
||||
# Pipecat commits the generated prefix immediately instead of
|
||||
# waiting for a TTS provider to emit spoken-text/timestamp frames.
|
||||
assistant_aggregator,
|
||||
*backchannel_processors,
|
||||
tts_processor,
|
||||
EndCallAfterSpeechProcessor(call_end),
|
||||
ConversationHistoryProcessor(recorder),
|
||||
|
||||
Reference in New Issue
Block a user