Introduce append_to_context to TextFrames

Adding support for setting whether or not the text in the TextFrame
should be added to the LLM context (by the LLM assistant aggregator).
Defaults to `True`.
This commit is contained in:
mattie ruth backman
2025-11-17 12:12:48 -05:00
committed by Mattie Ruth
parent 24266c238f
commit 0e820a01b9
4 changed files with 9 additions and 2 deletions

View File

@@ -135,6 +135,10 @@ Croatian, Hungarian, Malay, Norwegian, Nynorsk, Slovak, Slovenian, Swedish, and
text = match.text # instead of match.content
```
- `TextFrame` now includes the field `append_to_context` to support setting whether or not the
encompassing text should be added to the LLM context (by the LLM assistant aggregator). It
defaults to `True`.
### Deprecated
- The `api_key` parameter in `GeminiTTSService` is deprecated. Use

View File

@@ -337,11 +337,14 @@ class TextFrame(DataFrame):
# mandatory fields of theirs to have defaults to preserve
# non-default-before-default argument order)
includes_inter_frame_spaces: bool = field(init=False)
# Whether this text frame should be appended to the LLM context.
append_to_context: bool = field(init=False)
def __post_init__(self):
super().__post_init__()
self.skip_tts = False
self.includes_inter_frame_spaces = False
self.append_to_context = True
def __str__(self):
pts = format_pts(self.pts)

View File

@@ -1001,7 +1001,7 @@ class LLMAssistantContextAggregator(LLMContextResponseAggregator):
await self.push_aggregation()
async def _handle_text(self, frame: TextFrame):
if not self._started:
if not self._started or not frame.append_to_context:
return
if self._params.expect_stripped_words:

View File

@@ -811,7 +811,7 @@ class LLMAssistantAggregator(LLMContextAggregator):
await self.push_aggregation()
async def _handle_text(self, frame: TextFrame):
if not self._started:
if not self._started or not frame.append_to_context:
return
# Make sure we really have text (spaces count, too!)