codepilot review fixes

This commit is contained in:
mattie ruth backman
2025-10-29 11:37:13 -04:00
parent ccca6e8d81
commit 8a90decbc0
5 changed files with 17 additions and 16 deletions

View File

@@ -357,7 +357,14 @@ class LLMTextFrame(TextFrame):
@dataclass @dataclass
class AggregatedLLMTextFrame(TextFrame): 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 aggregated_by: Literal["sentence", "word"] | str

View File

@@ -719,7 +719,7 @@ class RTVIBotOutputMessageData(RTVITextMessageData):
class RTVIBotOutputMessage(BaseModel): class RTVIBotOutputMessage(BaseModel):
"""Message containing bot output text. """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. along with metadata about the output and if it has been spoken.
""" """

View File

@@ -23,17 +23,14 @@ class Aggregation:
An Aggregation object is created whenever a stream of text is aggregated by 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 a text aggregator. It contains the aggregated text and a type indicating
the nature of the aggregation. 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): text: str
"""Initialize an aggregation instance. type: str
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
def __str__(self) -> str: def __str__(self) -> str:
"""Return a string representation of the aggregation. """Return a string representation of the aggregation.

View File

@@ -213,7 +213,6 @@ class PatternPairAggregator(BaseTextAggregator):
# Remove the pattern from the text if configured # Remove the pattern from the text if configured
if action == MatchAction.REMOVE: if action == MatchAction.REMOVE:
processed_text = processed_text.replace(full_match, "", 1) processed_text = processed_text.replace(full_match, "", 1)
# modified = True
else: else:
all_matches.append(pattern_match) all_matches.append(pattern_match)
@@ -273,7 +272,6 @@ class PatternPairAggregator(BaseTextAggregator):
self._text = processed_text self._text = processed_text
#
if len(patterns) > 0: if len(patterns) > 0:
if len(patterns) > 1: if len(patterns) > 1:
logger.warning( logger.warning(
@@ -283,7 +281,6 @@ class PatternPairAggregator(BaseTextAggregator):
action = self._patterns[patterns[0].pattern_id].get("action", MatchAction.REMOVE) action = self._patterns[patterns[0].pattern_id].get("action", MatchAction.REMOVE)
if action == MatchAction.AGGREGATE: if action == MatchAction.AGGREGATE:
self._text = "" self._text = ""
print(f"Returning pattern: {patterns[0]}")
return patterns[0] return patterns[0]
# Check if we have incomplete patterns # Check if we have incomplete patterns

View File

@@ -43,7 +43,6 @@ class TestPatternPairAggregator(unittest.IsolatedAsyncioTestCase):
async def test_pattern_match_and_removal(self): async def test_pattern_match_and_removal(self):
# First part doesn't complete the pattern # First part doesn't complete the pattern
result = await self.aggregator.aggregate("Hello <test>pattern") result = await self.aggregator.aggregate("Hello <test>pattern")
print(f"result: {result}")
self.assertIsNone(result) self.assertIsNone(result)
self.assertEqual(self.aggregator.text.text, "Hello <test>pattern") self.assertEqual(self.aggregator.text.text, "Hello <test>pattern")
self.assertEqual(self.aggregator.text.type, "test") self.assertEqual(self.aggregator.text.type, "test")
@@ -74,7 +73,6 @@ class TestPatternPairAggregator(unittest.IsolatedAsyncioTestCase):
async def test_pattern_match_and_aggregate(self): async def test_pattern_match_and_aggregate(self):
# First part doesn't complete the pattern # First part doesn't complete the pattern
result = await self.aggregator.aggregate("Here is code <code>pattern") result = await self.aggregator.aggregate("Here is code <code>pattern")
print(f"result: {result}")
self.assertEqual(result.text, "Here is code ") self.assertEqual(result.text, "Here is code ")
self.assertEqual(self.aggregator.text.text, "<code>pattern") self.assertEqual(self.aggregator.text.text, "<code>pattern")
self.assertEqual(self.aggregator.text.type, "code") 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.pattern_id, "code_pattern")
self.assertEqual(call_args.full_match, "<code>pattern content</code>") self.assertEqual(call_args.full_match, "<code>pattern content</code>")
self.assertEqual(call_args.text, "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 # Next sentence should be processed separately
result = await self.aggregator.aggregate(" This is another sentence.") result = await self.aggregator.aggregate(" This is another sentence.")