add skip_tts to LLMFullResponseStartFrame/LLMFullResponseEndFrame
This commit is contained in:
@@ -1351,14 +1351,22 @@ class LLMFullResponseStartFrame(ControlFrame):
|
|||||||
more TextFrames and a final LLMFullResponseEndFrame.
|
more TextFrames and a final LLMFullResponseEndFrame.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
pass
|
skip_tts: bool = field(init=False)
|
||||||
|
|
||||||
|
def __post_init__(self):
|
||||||
|
super().__post_init__()
|
||||||
|
self.skip_tts = False
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class LLMFullResponseEndFrame(ControlFrame):
|
class LLMFullResponseEndFrame(ControlFrame):
|
||||||
"""Frame indicating the end of an LLM response."""
|
"""Frame indicating the end of an LLM response."""
|
||||||
|
|
||||||
pass
|
skip_tts: bool = field(init=False)
|
||||||
|
|
||||||
|
def __post_init__(self):
|
||||||
|
super().__post_init__()
|
||||||
|
self.skip_tts = False
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ from typing import (
|
|||||||
Awaitable,
|
Awaitable,
|
||||||
Callable,
|
Callable,
|
||||||
Dict,
|
Dict,
|
||||||
List,
|
|
||||||
Mapping,
|
Mapping,
|
||||||
Optional,
|
Optional,
|
||||||
Protocol,
|
Protocol,
|
||||||
@@ -38,6 +37,8 @@ from pipecat.frames.frames import (
|
|||||||
FunctionCallResultProperties,
|
FunctionCallResultProperties,
|
||||||
FunctionCallsStartedFrame,
|
FunctionCallsStartedFrame,
|
||||||
LLMConfigureOutputFrame,
|
LLMConfigureOutputFrame,
|
||||||
|
LLMFullResponseEndFrame,
|
||||||
|
LLMFullResponseStartFrame,
|
||||||
LLMTextFrame,
|
LLMTextFrame,
|
||||||
StartFrame,
|
StartFrame,
|
||||||
StartInterruptionFrame,
|
StartInterruptionFrame,
|
||||||
@@ -285,7 +286,7 @@ class LLMService(AIService):
|
|||||||
frame: The frame to push.
|
frame: The frame to push.
|
||||||
direction: The direction of frame pushing.
|
direction: The direction of frame pushing.
|
||||||
"""
|
"""
|
||||||
if isinstance(frame, LLMTextFrame):
|
if isinstance(frame, (LLMTextFrame, LLMFullResponseStartFrame, LLMFullResponseEndFrame)):
|
||||||
frame.skip_tts = self._skip_tts
|
frame.skip_tts = self._skip_tts
|
||||||
|
|
||||||
await super().push_frame(frame, direction)
|
await super().push_frame(frame, direction)
|
||||||
|
|||||||
@@ -296,7 +296,10 @@ class TTSService(AIService):
|
|||||||
"""
|
"""
|
||||||
await super().process_frame(frame, direction)
|
await super().process_frame(frame, direction)
|
||||||
|
|
||||||
if isinstance(frame, TextFrame) and frame.skip_tts:
|
if (
|
||||||
|
isinstance(frame, (TextFrame, LLMFullResponseStartFrame, LLMFullResponseEndFrame))
|
||||||
|
and frame.skip_tts
|
||||||
|
):
|
||||||
await self.push_frame(frame, direction)
|
await self.push_frame(frame, direction)
|
||||||
elif (
|
elif (
|
||||||
isinstance(frame, TextFrame)
|
isinstance(frame, TextFrame)
|
||||||
|
|||||||
Reference in New Issue
Block a user