diff --git a/changelog/3385.deprecated.md b/changelog/3385.deprecated.md new file mode 100644 index 000000000..e810af08a --- /dev/null +++ b/changelog/3385.deprecated.md @@ -0,0 +1 @@ +- `TranscriptProcessor` and related data classes and frames (`TranscriptionMessage`, `ThoughtTranscriptionMessage`, `TranscriptionUpdateFrame`) are deprecated. Use `LLMUserAggregator`'s and `LLMAssistantAggregator`'s new events (`on_user_turn_stopped` and `on_assistant_turn_stopped`) instead. diff --git a/src/pipecat/frames/frames.py b/src/pipecat/frames/frames.py index f2993ea74..fb0f8243b 100644 --- a/src/pipecat/frames/frames.py +++ b/src/pipecat/frames/frames.py @@ -536,6 +536,10 @@ class TranscriptionMessage: content: The message content/text. user_id: Optional identifier for the user. timestamp: Optional timestamp when the message was created. + + .. deprecated:: 0.0.99 + `TranscriptionMessage` is deprecated and will be removed in a future version. + Use `LLMUserAggregator`'s and `LLMAssistantAggregator`'s new events instead. """ role: Literal["user", "assistant"] @@ -543,15 +547,44 @@ class TranscriptionMessage: user_id: Optional[str] = None timestamp: Optional[str] = None + def __post_init__(self): + import warnings + + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "TranscriptionMessage is deprecated and will be removed in a future version. " + "Use `LLMUserAggregator`'s and `LLMAssistantAggregator`'s new events instead.", + DeprecationWarning, + stacklevel=2, + ) + @dataclass class ThoughtTranscriptionMessage: - """An LLM thought message in a conversation transcript.""" + """An LLM thought message in a conversation transcript. + + .. deprecated:: 0.0.99 + `ThoughtTranscriptionMessage` is deprecated and will be removed in a future version. + Use `LLMAssistantAggregator`'s new events instead. + """ role: Literal["assistant"] = field(default="assistant", init=False) content: str timestamp: Optional[str] = None + def __post_init__(self): + import warnings + + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "ThoughtTranscriptionMessage is deprecated and will be removed in a future version. " + "Use `LLMAssistantAggregator`'s new events instead.", + DeprecationWarning, + stacklevel=2, + ) + @dataclass class TranscriptionUpdateFrame(DataFrame): @@ -595,10 +628,28 @@ class TranscriptionUpdateFrame(DataFrame): Parameters: messages: List of new transcript messages that were added. + + .. deprecated:: 0.0.99 + `TranscriptionUpdateFrame` is deprecated and will be removed in a future version. + Use `LLMUserAggregator`'s and `LLMAssistantAggregator`'s new events instead. """ messages: List[TranscriptionMessage | ThoughtTranscriptionMessage] + def __post_init__(self): + super().__post_init__() + + import warnings + + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "TranscriptionUpdateFrame is deprecated and will be removed in a future version. " + "Use `LLMUserAggregator`'s and `LLMAssistantAggregator`'s new events instead.", + DeprecationWarning, + stacklevel=2, + ) + def __str__(self): pts = format_pts(self.pts) return f"{self.name}(pts: {pts}, messages: {len(self.messages)})" @@ -1160,7 +1211,18 @@ class EmulateUserStartedSpeakingFrame(SystemFrame): This frame is deprecated and will be removed in a future version. """ - pass + def __post_init__(self): + super().__post_init__() + + import warnings + + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "EmulateUserStartedSpeakingFrame is deprecated and will be removed in a future version.", + DeprecationWarning, + stacklevel=2, + ) @dataclass @@ -1174,7 +1236,18 @@ class EmulateUserStoppedSpeakingFrame(SystemFrame): This frame is deprecated and will be removed in a future version. """ - pass + def __post_init__(self): + super().__post_init__() + + import warnings + + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "EmulateUserStoppedSpeakingFrame is deprecated and will be removed in a future version.", + DeprecationWarning, + stacklevel=2, + ) @dataclass diff --git a/src/pipecat/processors/transcript_processor.py b/src/pipecat/processors/transcript_processor.py index be59bd9ef..2c9fe2917 100644 --- a/src/pipecat/processors/transcript_processor.py +++ b/src/pipecat/processors/transcript_processor.py @@ -269,6 +269,10 @@ class TranscriptProcessor: @transcript.event_handler("on_transcript_update") async def handle_update(processor, frame): print(f"New messages: {frame.messages}") + + .. deprecated:: 0.0.99 + `TranscriptProcessor` is deprecated and will be removed in a future version. + Use `LLMUserAggregator`'s and `LLMAssistantAggregator`'s new events instead. """ def __init__(self, *, process_thoughts: bool = False): @@ -283,6 +287,16 @@ class TranscriptProcessor: self._assistant_processor = None self._event_handlers = {} + import warnings + + with warnings.catch_warnings(): + warnings.simplefilter("always") + warnings.warn( + "`TranscriptProcessor` is deprecated and will be removed in a future version. " + "Use `LLMUserAggregator`'s and `LLMAssistantAggregator`'s new events instead.", + DeprecationWarning, + ) + def user(self, **kwargs) -> UserTranscriptProcessor: """Get the user transcript processor.