Fix IVRNavigator to push AggregatedTextFrame when switching to conversation mode

This commit is contained in:
Mark Backman
2026-01-30 21:01:35 -05:00
parent 342ae7af41
commit e779233918
3 changed files with 12 additions and 3 deletions

1
changelog/3604.fixed.md Normal file
View File

@@ -0,0 +1 @@
- Fixed an issue in the `IVRNavigator` where the `TextFrame`s pushed had incorrect spacing. Now, the internal `IVRProcessor` pushes `AggregatedTextFrame`s when in conversation mode. This allows for controlling spacing of the outputted, aggregated text.

View File

@@ -18,6 +18,7 @@ from loguru import logger
from pipecat.audio.dtmf.types import KeypadEntry
from pipecat.audio.vad.vad_analyzer import VADParams
from pipecat.frames.frames import (
AggregatedTextFrame,
EndFrame,
Frame,
LLMContextFrame,
@@ -153,13 +154,19 @@ class IVRProcessor(FrameProcessor):
# Process text through the pattern aggregator
async for result in self._aggregator.aggregate(frame.text):
# Push aggregated text that doesn't contain XML patterns
await self.push_frame(LLMTextFrame(result.text), direction)
await self.push_frame(
AggregatedTextFrame(text=result.text, aggregated_by=result.type),
direction,
)
elif isinstance(frame, (LLMFullResponseEndFrame, EndFrame)):
# Flush any remaining text from the aggregator
remaining = await self._aggregator.flush()
if remaining:
await self.push_frame(LLMTextFrame(remaining.text), direction)
await self.push_frame(
AggregatedTextFrame(text=remaining.text, aggregated_by=remaining.type),
direction,
)
# Push the end frame
await self.push_frame(frame, direction)

View File

@@ -10,6 +10,7 @@ from unittest.mock import AsyncMock
from pipecat.audio.vad.vad_analyzer import VADParams
from pipecat.extensions.ivr.ivr_navigator import IVRProcessor
from pipecat.frames.frames import (
AggregatedTextFrame,
LLMFullResponseEndFrame,
LLMMessagesUpdateFrame,
LLMTextFrame,
@@ -339,7 +340,7 @@ class TestIVRNavigation(unittest.IsolatedAsyncioTestCase):
]
expected_down_frames = [
LLMTextFrame, # Should pass through unchanged
AggregatedTextFrame, # LLMTextFrames aggregrated and converted to AggregatedTextFrame
LLMFullResponseEndFrame,
]