From 6f4458f21dd7aaabad195d3e5a7479be5765eba8 Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Thu, 30 Apr 2026 14:16:41 -0400 Subject: [PATCH] fix(turns): defer LocalSmartTurnAnalyzerV3 import to avoid loading transformers at module load MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Importing pipecat.turns.user_turn_strategies pulled in LocalSmartTurnAnalyzerV3 → transformers → onnxruntime at module load time. Since this module is imported by llm_response_universal (and therefore most LLM services), any LLM service import paid the cost of loading transformers and triggered its missing-backend warning in environments without PyTorch/TF/Flax. Move the LocalSmartTurnAnalyzerV3 import into default_user_turn_stop_strategies() so it only loads when the default smart-turn strategy is actually constructed. Fixes #4392 --- src/pipecat/turns/user_turn_strategies.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pipecat/turns/user_turn_strategies.py b/src/pipecat/turns/user_turn_strategies.py index 8a663d3da..8bbe87a7a 100644 --- a/src/pipecat/turns/user_turn_strategies.py +++ b/src/pipecat/turns/user_turn_strategies.py @@ -8,7 +8,6 @@ from dataclasses import dataclass -from pipecat.audio.turn.smart_turn.local_smart_turn_v3 import LocalSmartTurnAnalyzerV3 from pipecat.turns.user_start import ( BaseUserTurnStartStrategy, ExternalUserTurnStartStrategy, @@ -44,6 +43,8 @@ def default_user_turn_stop_strategies() -> list[BaseUserTurnStopStrategy]: Returns ``[TurnAnalyzerUserTurnStopStrategy(LocalSmartTurnAnalyzerV3)]``. Useful when building a custom strategy list that extends the defaults. """ + from pipecat.audio.turn.smart_turn.local_smart_turn_v3 import LocalSmartTurnAnalyzerV3 + return [TurnAnalyzerUserTurnStopStrategy(turn_analyzer=LocalSmartTurnAnalyzerV3())]