From dcb4949e2095c7054c6c6e06be2fafdd74c28c4e Mon Sep 17 00:00:00 2001 From: Paul Kompfner Date: Tue, 26 Aug 2025 09:43:47 -0400 Subject: [PATCH] Move `ServiceSwitcherFrame` and `ManuallySwitchServiceFrame` to frames.py --- src/pipecat/frames/frames.py | 17 +++++++++++++++++ src/pipecat/pipeline/service_switcher.py | 20 +------------------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/pipecat/frames/frames.py b/src/pipecat/frames/frames.py index 800a22623..01c840a71 100644 --- a/src/pipecat/frames/frames.py +++ b/src/pipecat/frames/frames.py @@ -1465,3 +1465,20 @@ class MixerEnableFrame(MixerControlFrame): """ enable: bool + + +@dataclass +class ServiceSwitcherFrame(ControlFrame): + """A base class for frames that control ServiceSwitcher behavior.""" + + pass + + +@dataclass +class ManuallySwitchServiceFrame(ServiceSwitcherFrame): + """A frame to request a manual switch in the active service in a ServiceSwitcher. + + Handled by ServiceSwitcherStrategyManual to switch the active service. + """ + + service: "FrameProcessor" diff --git a/src/pipecat/pipeline/service_switcher.py b/src/pipecat/pipeline/service_switcher.py index e9cf5371b..7dd36c503 100644 --- a/src/pipecat/pipeline/service_switcher.py +++ b/src/pipecat/pipeline/service_switcher.py @@ -6,22 +6,14 @@ """Service switcher for switching between different services at runtime, with different switching strategies.""" -from dataclasses import dataclass from typing import Any, Generic, List, Optional, Type, TypeVar -from pipecat.frames.frames import ControlFrame, Frame +from pipecat.frames.frames import Frame, ManuallySwitchServiceFrame, ServiceSwitcherFrame from pipecat.pipeline.parallel_pipeline import ParallelPipeline from pipecat.processors.filters.function_filter import FunctionFilter from pipecat.processors.frame_processor import FrameDirection, FrameProcessor -@dataclass -class ServiceSwitcherFrame(ControlFrame): - """A base class for frames that control service switching.""" - - pass - - class ServiceSwitcherStrategy: """Base class for service switching strategies.""" @@ -56,16 +48,6 @@ class ServiceSwitcherStrategy: raise NotImplementedError("Subclasses must implement this method.") -@dataclass -class ManuallySwitchServiceFrame(ServiceSwitcherFrame): - """A frame to signal a manual switch in the active service in a ServiceSwitcher. - - Handled by ServiceSwitcherStrategyManual to switch the active service. - """ - - service: FrameProcessor - - class ServiceSwitcherStrategyManual(ServiceSwitcherStrategy): """A strategy for switching between services manually.