diff --git a/CHANGELOG.md b/CHANGELOG.md index 52606239d..70f13e865 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Deprecated +- Package `pipecat.sync` is deprecated, use `pipecat.utils.sync` instead. + - The `noise_gate_enable` parameter in `AICFilter` is deprecated and no longer has any effect. Noise gating is now handled automatically by the AIC VAD system. Use `AICFilter.create_vad_analyzer()` for VAD functionality instead. diff --git a/docs/api/conf.py b/docs/api/conf.py index 8946a34d3..c92eaa97d 100644 --- a/docs/api/conf.py +++ b/docs/api/conf.py @@ -119,7 +119,6 @@ def import_core_modules(): "pipecat.observers", "pipecat.runner", "pipecat.serializers", - "pipecat.sync", "pipecat.transcriptions", "pipecat.utils", ] diff --git a/docs/api/index.rst b/docs/api/index.rst index df84d9580..85f373db7 100644 --- a/docs/api/index.rst +++ b/docs/api/index.rst @@ -30,7 +30,6 @@ Quick Links Runner Serializers Services - Sync Transcriptions Transports - Utils \ No newline at end of file + Utils diff --git a/examples/foundational/22-natural-conversation.py b/examples/foundational/22-natural-conversation.py index f95a473df..c4326ac4d 100644 --- a/examples/foundational/22-natural-conversation.py +++ b/examples/foundational/22-natural-conversation.py @@ -28,10 +28,10 @@ from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import LLMService from pipecat.services.openai.llm import OpenAIContextAggregatorPair, OpenAILLMService -from pipecat.sync.event_notifier import EventNotifier from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams +from pipecat.utils.sync.event_notifier import EventNotifier load_dotenv(override=True) diff --git a/examples/foundational/22b-natural-conversation-proposal.py b/examples/foundational/22b-natural-conversation-proposal.py index 935676f9b..ca3737ebd 100644 --- a/examples/foundational/22b-natural-conversation-proposal.py +++ b/examples/foundational/22b-natural-conversation-proposal.py @@ -45,11 +45,11 @@ from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams, LLMService from pipecat.services.openai.llm import OpenAILLMService -from pipecat.sync.base_notifier import BaseNotifier -from pipecat.sync.event_notifier import EventNotifier from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams +from pipecat.utils.sync.base_notifier import BaseNotifier +from pipecat.utils.sync.event_notifier import EventNotifier from pipecat.utils.time import time_now_iso8601 load_dotenv(override=True) diff --git a/examples/foundational/22c-natural-conversation-mixed-llms.py b/examples/foundational/22c-natural-conversation-mixed-llms.py index cdcd21289..48fa7dfe0 100644 --- a/examples/foundational/22c-natural-conversation-mixed-llms.py +++ b/examples/foundational/22c-natural-conversation-mixed-llms.py @@ -46,11 +46,11 @@ from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams, LLMService from pipecat.services.openai.llm import OpenAILLMService -from pipecat.sync.base_notifier import BaseNotifier -from pipecat.sync.event_notifier import EventNotifier from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams +from pipecat.utils.sync.base_notifier import BaseNotifier +from pipecat.utils.sync.event_notifier import EventNotifier from pipecat.utils.time import time_now_iso8601 load_dotenv(override=True) diff --git a/examples/foundational/22d-natural-conversation-gemini-audio.py b/examples/foundational/22d-natural-conversation-gemini-audio.py index a7837ce60..9654dd154 100644 --- a/examples/foundational/22d-natural-conversation-gemini-audio.py +++ b/examples/foundational/22d-natural-conversation-gemini-audio.py @@ -47,11 +47,11 @@ from pipecat.runner.utils import create_transport from pipecat.services.cartesia.tts import CartesiaTTSService from pipecat.services.google.llm import GoogleLLMService from pipecat.services.llm_service import LLMService -from pipecat.sync.base_notifier import BaseNotifier -from pipecat.sync.event_notifier import EventNotifier from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams +from pipecat.utils.sync.base_notifier import BaseNotifier +from pipecat.utils.sync.event_notifier import EventNotifier from pipecat.utils.time import time_now_iso8601 load_dotenv(override=True) diff --git a/src/pipecat/extensions/voicemail/voicemail_detector.py b/src/pipecat/extensions/voicemail/voicemail_detector.py index 149103319..e79520cb5 100644 --- a/src/pipecat/extensions/voicemail/voicemail_detector.py +++ b/src/pipecat/extensions/voicemail/voicemail_detector.py @@ -40,8 +40,8 @@ from pipecat.processors.aggregators.llm_context import LLMContext from pipecat.processors.aggregators.llm_response_universal import LLMContextAggregatorPair from pipecat.processors.frame_processor import FrameDirection, FrameProcessor, FrameProcessorSetup from pipecat.services.llm_service import LLMService -from pipecat.sync.base_notifier import BaseNotifier -from pipecat.sync.event_notifier import EventNotifier +from pipecat.utils.sync.base_notifier import BaseNotifier +from pipecat.utils.sync.event_notifier import EventNotifier class NotifierGate(FrameProcessor): diff --git a/src/pipecat/processors/aggregators/gated_llm_context.py b/src/pipecat/processors/aggregators/gated_llm_context.py index 6535bffbb..9c3d90948 100644 --- a/src/pipecat/processors/aggregators/gated_llm_context.py +++ b/src/pipecat/processors/aggregators/gated_llm_context.py @@ -9,7 +9,7 @@ from pipecat.frames.frames import CancelFrame, EndFrame, Frame, LLMContextFrame, StartFrame from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContextFrame from pipecat.processors.frame_processor import FrameDirection, FrameProcessor -from pipecat.sync.base_notifier import BaseNotifier +from pipecat.utils.sync.base_notifier import BaseNotifier class GatedLLMContextAggregator(FrameProcessor): diff --git a/src/pipecat/processors/filters/wake_notifier_filter.py b/src/pipecat/processors/filters/wake_notifier_filter.py index c30f3b5d3..8ed3bc8c4 100644 --- a/src/pipecat/processors/filters/wake_notifier_filter.py +++ b/src/pipecat/processors/filters/wake_notifier_filter.py @@ -10,7 +10,7 @@ from typing import Awaitable, Callable, Tuple, Type from pipecat.frames.frames import Frame from pipecat.processors.frame_processor import FrameDirection, FrameProcessor -from pipecat.sync.base_notifier import BaseNotifier +from pipecat.utils.sync.base_notifier import BaseNotifier class WakeNotifierFilter(FrameProcessor): diff --git a/src/pipecat/sync/base_notifier.py b/src/pipecat/sync/base_notifier.py index 60321e282..1e3b16969 100644 --- a/src/pipecat/sync/base_notifier.py +++ b/src/pipecat/sync/base_notifier.py @@ -6,31 +6,14 @@ """Base notifier interface for Pipecat.""" -from abc import ABC, abstractmethod +import warnings +from pipecat.utils.sync.base_notifier import BaseNotifier -class BaseNotifier(ABC): - """Abstract base class for notification mechanisms. - - Provides a standard interface for implementing notification and waiting - patterns used for event coordination and signaling between components - in the Pipecat framework. - """ - - @abstractmethod - async def notify(self): - """Send a notification signal. - - Implementations should trigger any waiting coroutines or processes - that are blocked on this notifier. - """ - pass - - @abstractmethod - async def wait(self): - """Wait for a notification signal. - - Implementations should block until a notification is received - from the corresponding notify() call. - """ - pass +with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "Package pipecat.sync is deprecated, use pipecat.utils.sync instead.", + DeprecationWarning, + stacklevel=2, + ) diff --git a/src/pipecat/sync/event_notifier.py b/src/pipecat/sync/event_notifier.py index 6708c2404..35fee6cb3 100644 --- a/src/pipecat/sync/event_notifier.py +++ b/src/pipecat/sync/event_notifier.py @@ -6,40 +6,14 @@ """Event-based notifier implementation using asyncio Event primitives.""" -import asyncio +import warnings -from pipecat.sync.base_notifier import BaseNotifier +from pipecat.utils.sync.event_notifier import EventNotifier - -class EventNotifier(BaseNotifier): - """Event-based notifier using asyncio.Event for task synchronization. - - Provides a simple notification mechanism where one task can signal - an event and other tasks can wait for that event to occur. The event - is automatically cleared after each wait operation. - """ - - def __init__(self): - """Initialize the event notifier. - - Creates an internal asyncio.Event for managing notifications. - """ - self._event = asyncio.Event() - - async def notify(self): - """Signal the event to notify waiting tasks. - - Sets the internal event, causing any tasks waiting on this - notifier to be awakened. - """ - self._event.set() - - async def wait(self): - """Wait for the event to be signaled. - - Blocks until another task calls notify(). Automatically clears - the event after being awakened so subsequent calls will wait - for the next notification. - """ - await self._event.wait() - self._event.clear() +with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "Package pipecat.sync is deprecated, use pipecat.utils.sync instead.", + DeprecationWarning, + stacklevel=2, + ) diff --git a/src/pipecat/utils/sync/__init__.py b/src/pipecat/utils/sync/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/pipecat/utils/sync/base_notifier.py b/src/pipecat/utils/sync/base_notifier.py new file mode 100644 index 000000000..60321e282 --- /dev/null +++ b/src/pipecat/utils/sync/base_notifier.py @@ -0,0 +1,36 @@ +# +# Copyright (c) 2024–2025, Daily +# +# SPDX-License-Identifier: BSD 2-Clause License +# + +"""Base notifier interface for Pipecat.""" + +from abc import ABC, abstractmethod + + +class BaseNotifier(ABC): + """Abstract base class for notification mechanisms. + + Provides a standard interface for implementing notification and waiting + patterns used for event coordination and signaling between components + in the Pipecat framework. + """ + + @abstractmethod + async def notify(self): + """Send a notification signal. + + Implementations should trigger any waiting coroutines or processes + that are blocked on this notifier. + """ + pass + + @abstractmethod + async def wait(self): + """Wait for a notification signal. + + Implementations should block until a notification is received + from the corresponding notify() call. + """ + pass diff --git a/src/pipecat/utils/sync/event_notifier.py b/src/pipecat/utils/sync/event_notifier.py new file mode 100644 index 000000000..0a553fb1e --- /dev/null +++ b/src/pipecat/utils/sync/event_notifier.py @@ -0,0 +1,45 @@ +# +# Copyright (c) 2024–2025, Daily +# +# SPDX-License-Identifier: BSD 2-Clause License +# + +"""Event-based notifier implementation using asyncio Event primitives.""" + +import asyncio + +from pipecat.utils.sync.base_notifier import BaseNotifier + + +class EventNotifier(BaseNotifier): + """Event-based notifier using asyncio.Event for task synchronization. + + Provides a simple notification mechanism where one task can signal + an event and other tasks can wait for that event to occur. The event + is automatically cleared after each wait operation. + """ + + def __init__(self): + """Initialize the event notifier. + + Creates an internal asyncio.Event for managing notifications. + """ + self._event = asyncio.Event() + + async def notify(self): + """Signal the event to notify waiting tasks. + + Sets the internal event, causing any tasks waiting on this + notifier to be awakened. + """ + self._event.set() + + async def wait(self): + """Wait for the event to be signaled. + + Blocks until another task calls notify(). Automatically clears + the event after being awakened so subsequent calls will wait + for the next notification. + """ + await self._event.wait() + self._event.clear()