Move ServiceSwitcherFrame and ManuallySwitchServiceFrame to frames.py

This commit is contained in:
Paul Kompfner
2025-08-26 09:43:47 -04:00
parent 8b543e558d
commit dcb4949e20
2 changed files with 18 additions and 19 deletions

View File

@@ -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"

View File

@@ -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.