llm_text_processor

LLM text processor module for processing and aggregating raw LLM output text.

This processor will convert LLMTextFrames into AggregatedTextFrames based on the configured text aggregator. Using the customizable aggregator, it provides functionality to handle or manipulate LLM text frames before they are sent to other components such as TTS services or context aggregators. It can be used to pre-aggregate and categorize, modify, or filter direct output tokens from the LLM.

class pipecat.processors.aggregators.llm_text_processor.LLMTextProcessor(*, text_aggregator: BaseTextAggregator | None = None, **kwargs)[source]

Bases: FrameProcessor

A processor for handling or manipulating LLM text frames before they are processed further.

This processor will convert LLMTextFrames into AggregatedTextFrames based on the configured text aggregator. Using the customizable aggregator, it provides functionality to handle or manipulate LLM text frames before they are sent to other components such as TTS services or context aggregators. It can be used to pre-aggregate and categorize, modify, or filter direct output tokens from the LLM.

__init__(*, text_aggregator: BaseTextAggregator | None = None, **kwargs)[source]

Initialize the LLM text processor.

Parameters:
  • text_aggregator – An optional text aggregator to use for processing LLM text frames. By default, a SimpleTextAggregator aggregating by sentence will be used.

  • **kwargs – Additional arguments passed to parent class.

TODO: Allow transformations per aggregation type or all (and deprecate the TTS filters).

async process_frame(frame: Frame, direction: FrameDirection)[source]

Process an LLMTextFrames using the aggregator to generate AggregatedTextFrames.

Parameters:
  • frame – The frame to process.

  • direction – The direction of frame flow in the pipeline.

async reset()[source]

Reset the internal state of the text processor and its aggregator.