turns: add external user and bot turn start strategies

External strategies are strategies where the logic for user turn start and turn
end come from a different processors (e.g. an STT).
This commit is contained in:
Aleix Conchillo Flaqué
2025-12-28 12:45:58 -08:00
parent 0e8e3afc85
commit ef73e498cb
15 changed files with 274 additions and 51 deletions

View File

@@ -29,6 +29,7 @@ from pipecat.transcriptions.language import Language
from pipecat.transports.base_transport import BaseTransport, TransportParams
from pipecat.transports.daily.transport import DailyParams
from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams
from pipecat.turns.turn_start_strategies import ExternalTurnStartStrategies
load_dotenv(override=True)
@@ -132,7 +133,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
context = LLMContext(messages)
context_aggregator = LLMContextAggregatorPair(
context,
user_params=LLMUserAggregatorParams(enable_user_speaking_frames=False),
user_params=LLMUserAggregatorParams(
turn_start_strategies=ExternalTurnStartStrategies()
),
)
pipeline = Pipeline(

View File

@@ -27,6 +27,7 @@ from pipecat.services.openai.llm import OpenAILLMService
from pipecat.transports.base_transport import BaseTransport, TransportParams
from pipecat.transports.daily.transport import DailyParams
from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams
from pipecat.turns.turn_start_strategies import ExternalTurnStartStrategies
load_dotenv(override=True)
@@ -71,7 +72,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
context = LLMContext(messages)
context_aggregator = LLMContextAggregatorPair(
context, user_params=LLMUserAggregatorParams(enable_user_speaking_frames=False)
context,
user_params=LLMUserAggregatorParams(turn_start_strategies=ExternalTurnStartStrategies()),
)
pipeline = Pipeline(

View File

@@ -33,6 +33,7 @@ from pipecat.services.openai.llm import OpenAILLMService
from pipecat.transports.base_transport import BaseTransport, TransportParams
from pipecat.transports.daily.transport import DailyParams
from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams
from pipecat.turns.turn_start_strategies import ExternalTurnStartStrategies
load_dotenv(override=True)
@@ -78,7 +79,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
context = LLMContext(messages)
context_aggregator = LLMContextAggregatorPair(
context,
user_params=LLMUserAggregatorParams(enable_user_speaking_frames=False),
user_params=LLMUserAggregatorParams(turn_start_strategies=ExternalTurnStartStrategies()),
)
pipeline = Pipeline(