Overview
LLMTextProcessor is a processor designed to aggregate LLMTextFrames into coherent text units before passing them to downstream services, such as TTS. By utilizing text aggregators, it ensures that text is properly segmented and structured, enhancing the quality of subsequent processing. This processor expects LLMTextFrames as input and outputs AggregatedTextFrames containing the aggregated text.
If an
LLMTextProcessor is in use, the text_aggregator parameter of TTS services will be ignored, as text aggregation is handled upstream.bot-output messages, supporting custom client-side handling and rendering (e.g. collapsible code blocks, clickable links, etc.).
LLMTextProcessor API Reference
Pipecat’s API methods for LLMTextProcessor
Example Implementation
Complete example with LLMTextProcessor and custom TTS and RTVI handling
Constructor Parameters
An instance of a text aggregator (e.g.,
PatternPairAggregator or a custom aggregator type) used to aggregate incoming text from LLMTextFrames.
If None, a SimpleTextAggregator will be used by default, aggregating text based on sentence boundaries.Usage
TheLLMTextProcessor should be integrated into your pipeline after the LLM service and before any services that consume text, such as TTS. It processes incoming LLMTextFrames, aggregates their text content, and outputs AggregatedTextFrames.