From 3bf15476a43f5bbfd806786f3ecdf931a87dcd45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Tue, 10 Dec 2024 10:03:52 -0800 Subject: [PATCH] processors(filters): add IdentityFilter --- CHANGELOG.md | 3 ++ .../processors/filters/identity_filter.py | 30 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/pipecat/processors/filters/identity_filter.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f763624c..697197a9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Added `IdentityFilter`. This is the simplest frame filter that lets through + all incoming frames. + - New `STTMuteStrategy` called `FUNCTION_CALL` which mutes the STT service during LLM function calls. diff --git a/src/pipecat/processors/filters/identity_filter.py b/src/pipecat/processors/filters/identity_filter.py new file mode 100644 index 000000000..d6f896b73 --- /dev/null +++ b/src/pipecat/processors/filters/identity_filter.py @@ -0,0 +1,30 @@ +# +# Copyright (c) 2024, Daily +# +# SPDX-License-Identifier: BSD 2-Clause License +# + +from pipecat.frames.frames import Frame +from pipecat.processors.frame_processor import FrameDirection, FrameProcessor + + +class IdentityFilter(FrameProcessor): + """A pass-through filter that forwards all frames without modification. + + This filter acts as a transparent passthrough, allowing all frames to flow + through unchanged. It can be useful when testing `ParallelPipeline` to + create pipelines that pass through frames (no frames should be repeated). + + """ + + def __init__(self, **kwargs): + super().__init__(**kwargs) + + # + # Frame processor + # + + async def process_frame(self, frame: Frame, direction: FrameDirection): + """Process an incoming frame by passing it through unchanged.""" + await super().process_frame(frame, direction) + await self.push_frame(frame, direction)