diff --git a/src/pipecat/frames/frames.py b/src/pipecat/frames/frames.py index 858e1d973..13bf2eaa7 100644 --- a/src/pipecat/frames/frames.py +++ b/src/pipecat/frames/frames.py @@ -357,7 +357,14 @@ class LLMTextFrame(TextFrame): @dataclass class AggregatedLLMTextFrame(TextFrame): - """Text frame generated by Text-to-Speech services.""" + """Text frame representing an aggregation of LLMTextFrames. + + This frame contains multiple LLMTextFrames aggregated together for + processing or output along with a field to indicate how they are aggregated. + + Parameters: + aggregated_by: Method used to aggregate the text frames. + """ aggregated_by: Literal["sentence", "word"] | str diff --git a/src/pipecat/processors/frameworks/rtvi.py b/src/pipecat/processors/frameworks/rtvi.py index 8b126b5b6..dc2b63083 100644 --- a/src/pipecat/processors/frameworks/rtvi.py +++ b/src/pipecat/processors/frameworks/rtvi.py @@ -719,7 +719,7 @@ class RTVIBotOutputMessageData(RTVITextMessageData): class RTVIBotOutputMessage(BaseModel): """Message containing bot output text. - An event meant to wholistically represent what the bot is outputting, + An event meant to holistically represent what the bot is outputting, along with metadata about the output and if it has been spoken. """ diff --git a/src/pipecat/utils/text/base_text_aggregator.py b/src/pipecat/utils/text/base_text_aggregator.py index 5a5196920..7405a2d04 100644 --- a/src/pipecat/utils/text/base_text_aggregator.py +++ b/src/pipecat/utils/text/base_text_aggregator.py @@ -23,17 +23,14 @@ class Aggregation: An Aggregation object is created whenever a stream of text is aggregated by a text aggregator. It contains the aggregated text and a type indicating the nature of the aggregation. + + Parameters: + text: The aggregated text content. + type: The type of aggregation the text represents (e.g., 'sentence', 'word', 'token', 'my_custom_aggregation'). """ - def __init__(self, text: str, type: str): - """Initialize an aggregation instance. - - Args: - text: The aggregated text content. - type: The type of aggregation the text represents (e.g., 'sentence', 'word', 'token', 'my_custom_aggregation'). - """ - self.text = text - self.type = type + text: str + type: str def __str__(self) -> str: """Return a string representation of the aggregation. diff --git a/src/pipecat/utils/text/pattern_pair_aggregator.py b/src/pipecat/utils/text/pattern_pair_aggregator.py index f5e33f5b8..66cf4da9f 100644 --- a/src/pipecat/utils/text/pattern_pair_aggregator.py +++ b/src/pipecat/utils/text/pattern_pair_aggregator.py @@ -213,7 +213,6 @@ class PatternPairAggregator(BaseTextAggregator): # Remove the pattern from the text if configured if action == MatchAction.REMOVE: processed_text = processed_text.replace(full_match, "", 1) - # modified = True else: all_matches.append(pattern_match) @@ -273,7 +272,6 @@ class PatternPairAggregator(BaseTextAggregator): self._text = processed_text - # if len(patterns) > 0: if len(patterns) > 1: logger.warning( @@ -283,7 +281,6 @@ class PatternPairAggregator(BaseTextAggregator): action = self._patterns[patterns[0].pattern_id].get("action", MatchAction.REMOVE) if action == MatchAction.AGGREGATE: self._text = "" - print(f"Returning pattern: {patterns[0]}") return patterns[0] # Check if we have incomplete patterns diff --git a/tests/test_pattern_pair_aggregator.py b/tests/test_pattern_pair_aggregator.py index 804128eb4..5887a8197 100644 --- a/tests/test_pattern_pair_aggregator.py +++ b/tests/test_pattern_pair_aggregator.py @@ -43,7 +43,6 @@ class TestPatternPairAggregator(unittest.IsolatedAsyncioTestCase): async def test_pattern_match_and_removal(self): # First part doesn't complete the pattern result = await self.aggregator.aggregate("Hello pattern") - print(f"result: {result}") self.assertIsNone(result) self.assertEqual(self.aggregator.text.text, "Hello pattern") self.assertEqual(self.aggregator.text.type, "test") @@ -74,7 +73,6 @@ class TestPatternPairAggregator(unittest.IsolatedAsyncioTestCase): async def test_pattern_match_and_aggregate(self): # First part doesn't complete the pattern result = await self.aggregator.aggregate("Here is code pattern") - print(f"result: {result}") self.assertEqual(result.text, "Here is code ") self.assertEqual(self.aggregator.text.text, "pattern") self.assertEqual(self.aggregator.text.type, "code") @@ -89,6 +87,8 @@ class TestPatternPairAggregator(unittest.IsolatedAsyncioTestCase): self.assertEqual(call_args.pattern_id, "code_pattern") self.assertEqual(call_args.full_match, "pattern content") self.assertEqual(call_args.text, "pattern content") + self.assertEqual(result.text, "pattern content") + self.assertEqual(result.type, "code") # Next sentence should be processed separately result = await self.aggregator.aggregate(" This is another sentence.")