codepilot review fixes
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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.
|
||||
"""
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 <test>pattern")
|
||||
print(f"result: {result}")
|
||||
self.assertIsNone(result)
|
||||
self.assertEqual(self.aggregator.text.text, "Hello <test>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 <code>pattern")
|
||||
print(f"result: {result}")
|
||||
self.assertEqual(result.text, "Here is code ")
|
||||
self.assertEqual(self.aggregator.text.text, "<code>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, "<code>pattern content</code>")
|
||||
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.")
|
||||
|
||||
Reference in New Issue
Block a user