-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #815 from pipecat-ai/aleix/identity-filter
processors(filters): add IdentityFilter
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |