LLMTextFrame: don't override skip_tts
This commit is contained in:
@@ -28,6 +28,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed an issue where `LLMTextFrame.skip_tts` was being overwritten by LLM
|
||||||
|
services.
|
||||||
|
|
||||||
- Fixed an issue in `SarvamTTSService` where the last sentence was not being
|
- Fixed an issue in `SarvamTTSService` where the last sentence was not being
|
||||||
spoken. Now, audio is flushed when the TTS services receives the
|
spoken. Now, audio is flushed when the TTS services receives the
|
||||||
`LLMFullResponseEndFrame` or `EndFrame`.
|
`LLMFullResponseEndFrame` or `EndFrame`.
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ class TextFrame(DataFrame):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
text: str
|
text: str
|
||||||
skip_tts: bool = field(init=False)
|
skip_tts: Optional[bool] = field(init=False)
|
||||||
# Whether any necessary inter-frame (leading/trailing) spaces are already
|
# Whether any necessary inter-frame (leading/trailing) spaces are already
|
||||||
# included in the text.
|
# included in the text.
|
||||||
# NOTE: Ideally this would be available at init time with a default value,
|
# NOTE: Ideally this would be available at init time with a default value,
|
||||||
@@ -343,7 +343,7 @@ class TextFrame(DataFrame):
|
|||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
super().__post_init__()
|
super().__post_init__()
|
||||||
self.skip_tts = False
|
self.skip_tts = None
|
||||||
self.includes_inter_frame_spaces = False
|
self.includes_inter_frame_spaces = False
|
||||||
self.append_to_context = True
|
self.append_to_context = True
|
||||||
|
|
||||||
@@ -1632,22 +1632,22 @@ class LLMFullResponseStartFrame(ControlFrame):
|
|||||||
more TextFrames and a final LLMFullResponseEndFrame.
|
more TextFrames and a final LLMFullResponseEndFrame.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
skip_tts: bool = field(init=False)
|
skip_tts: Optional[bool] = field(init=False)
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
super().__post_init__()
|
super().__post_init__()
|
||||||
self.skip_tts = False
|
self.skip_tts = None
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class LLMFullResponseEndFrame(ControlFrame):
|
class LLMFullResponseEndFrame(ControlFrame):
|
||||||
"""Frame indicating the end of an LLM response."""
|
"""Frame indicating the end of an LLM response."""
|
||||||
|
|
||||||
skip_tts: bool = field(init=False)
|
skip_tts: Optional[bool] = field(init=False)
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
super().__post_init__()
|
super().__post_init__()
|
||||||
self.skip_tts = False
|
self.skip_tts = None
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class LLMTextProcessor(FrameProcessor):
|
|||||||
out_frame.skip_tts = in_frame.skip_tts
|
out_frame.skip_tts = in_frame.skip_tts
|
||||||
await self.push_frame(out_frame)
|
await self.push_frame(out_frame)
|
||||||
|
|
||||||
async def _handle_llm_end(self, skip_tts: bool = False):
|
async def _handle_llm_end(self, skip_tts: Optional[bool] = None):
|
||||||
# Flush any remaining aggregated text at the end of the LLM response
|
# Flush any remaining aggregated text at the end of the LLM response
|
||||||
aggregation = self._text_aggregator.text
|
aggregation = self._text_aggregator.text
|
||||||
await self._text_aggregator.reset()
|
await self._text_aggregator.reset()
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ class LLMService(AIService):
|
|||||||
self._function_call_tasks: Dict[Optional[asyncio.Task], FunctionCallRunnerItem] = {}
|
self._function_call_tasks: Dict[Optional[asyncio.Task], FunctionCallRunnerItem] = {}
|
||||||
self._sequential_runner_task: Optional[asyncio.Task] = None
|
self._sequential_runner_task: Optional[asyncio.Task] = None
|
||||||
self._tracing_enabled: bool = False
|
self._tracing_enabled: bool = False
|
||||||
self._skip_tts: bool = False
|
self._skip_tts: Optional[bool] = None
|
||||||
|
|
||||||
self._register_event_handler("on_function_calls_started")
|
self._register_event_handler("on_function_calls_started")
|
||||||
self._register_event_handler("on_completion_timeout")
|
self._register_event_handler("on_completion_timeout")
|
||||||
@@ -297,7 +297,8 @@ class LLMService(AIService):
|
|||||||
direction: The direction of frame pushing.
|
direction: The direction of frame pushing.
|
||||||
"""
|
"""
|
||||||
if isinstance(frame, (LLMTextFrame, LLMFullResponseStartFrame, LLMFullResponseEndFrame)):
|
if isinstance(frame, (LLMTextFrame, LLMFullResponseStartFrame, LLMFullResponseEndFrame)):
|
||||||
frame.skip_tts = self._skip_tts
|
if self._skip_tts is not None:
|
||||||
|
frame.skip_tts = self._skip_tts
|
||||||
|
|
||||||
await super().push_frame(frame, direction)
|
await super().push_frame(frame, direction)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user