diff --git a/CHANGELOG.md b/CHANGELOG.md index c882fa7c5..da1f08eaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Added new base `TaskFrame` (which is a system frame). This is the base class + for all task frames (`EndTaskFrame`, `CancelTaskFrame`, etc.) that are meant + to be pushed upstream to reach the pipeline task. + - Expanded support for universal `LLMContext` to the AWS Bedrock LLM service. Using the universal `LLMContext` and associated `LLMContextAggregatorPair` is a pre-requisite for using `LLMSwitcher` to switch between LLMs at runtime. diff --git a/src/pipecat/frames/frames.py b/src/pipecat/frames/frames.py index 83488f2a4..288048de0 100644 --- a/src/pipecat/frames/frames.py +++ b/src/pipecat/frames/frames.py @@ -788,43 +788,6 @@ class FatalErrorFrame(ErrorFrame): fatal: bool = field(default=True, init=False) -@dataclass -class EndTaskFrame(SystemFrame): - """Frame to request graceful pipeline task closure. - - This is used to notify the pipeline task that the pipeline should be - closed nicely (flushing all the queued frames) by pushing an EndFrame - downstream. This frame should be pushed upstream. - """ - - pass - - -@dataclass -class CancelTaskFrame(SystemFrame): - """Frame to request immediate pipeline task cancellation. - - This is used to notify the pipeline task that the pipeline should be - stopped immediately by pushing a CancelFrame downstream. This frame - should be pushed upstream. - """ - - pass - - -@dataclass -class StopTaskFrame(SystemFrame): - """Frame to request pipeline task stop while keeping processors running. - - This is used to notify the pipeline task that it should be stopped as - soon as possible (flushing all the queued frames) but that the pipeline - processors should be kept in a running state. This frame should be pushed - upstream. - """ - - pass - - @dataclass class FrameProcessorPauseUrgentFrame(SystemFrame): """Frame to pause frame processing immediately. @@ -1289,6 +1252,62 @@ class SpeechControlParamsFrame(SystemFrame): turn_params: Optional[SmartTurnParams] = None +# +# Task frames +# + + +@dataclass +class TaskFrame(SystemFrame): + """Base frame for task frames. + + This is a base class for frames that are meant to be sent and handled + upstream by the pipeline task. This might result in a corresponding frame + sent downstream (e.g. `InterruptionTaskFrame` / `InterruptionFrame` or + `EndTaskFrame` / `EndFrame`). + + """ + + pass + + +@dataclass +class EndTaskFrame(TaskFrame): + """Frame to request graceful pipeline task closure. + + This is used to notify the pipeline task that the pipeline should be + closed nicely (flushing all the queued frames) by pushing an EndFrame + downstream. This frame should be pushed upstream. + """ + + pass + + +@dataclass +class CancelTaskFrame(TaskFrame): + """Frame to request immediate pipeline task cancellation. + + This is used to notify the pipeline task that the pipeline should be + stopped immediately by pushing a CancelFrame downstream. This frame + should be pushed upstream. + """ + + pass + + +@dataclass +class StopTaskFrame(TaskFrame): + """Frame to request pipeline task stop while keeping processors running. + + This is used to notify the pipeline task that it should be stopped as + soon as possible (flushing all the queued frames) but that the pipeline + processors should be kept in a running state. This frame should be pushed + upstream. + """ + + pass + + # # Control frames #