LLM Response Aggregators
Frame processors for managing and aggregating LLM conversations and contexts
Overview
The LLM Response Aggregators are a family of frame processors that manage conversation context and aggregate responses for Large Language Model interactions. They handle both user and assistant messages, maintaining conversation history and context.
Base Class: LLMResponseAggregator
Base class for LLM response aggregation.
Constructor Parameters
Initial list of conversation messages
Role for the messages (“user” or “assistant”)
Frame type that initiates aggregation
Frame type that completes aggregation
Frame type to aggregate
Frame type for interim results
Whether to handle interruption frames
Whether to add spaces between aggregated words
Specialized Aggregators
LLMAssistantResponseAggregator
Aggregates assistant responses in the conversation.
LLMUserResponseAggregator
Aggregates user responses in the conversation.
LLMFullResponseAggregator
Aggregates text frames into complete responses.
Combines multiple text frames until receiving an end frame, then emits a single combined text frame.
Context-Aware Aggregators
LLMContextAggregator
Base class for context-aware aggregation.
LLM context object for managing conversation state
LLMAssistantContextAggregator
Context-aware assistant response aggregator.
LLMUserContextAggregator
Context-aware user response aggregator.
Input Frames
The aggregators handle various frame types:
Control Frames
LLMFullResponseStartFrame
LLMFullResponseEndFrame
UserStartedSpeakingFrame
UserStoppedSpeakingFrame
StartInterruptionFrame
Content Frames
TextFrame
TranscriptionFrame
InterimTranscriptionFrame
Context Management Frames
LLMMessagesAppendFrame
LLMMessagesUpdateFrame
LLMSetToolsFrame
Output Frames
LLMMessagesFrame
: Contains complete conversation messagesOpenAILLMContextFrame
: Contains context-aware conversation stateTextFrame
: Contains aggregated responses
The aggregators follow specific patterns for frame processing. Using the notation:
- S: Start Frame
- E: End Frame
- T: Transcription/Text Frame
- I: Interim Frame
- X: Output Frame
Processing Patterns
The aggregators follow specific patterns for frame processing. Using the notation:
- S: Start Frame
- E: End Frame
- T: Transcription/Text Frame
- I: Interim Frame
- X: Output Frame
Supported Patterns
Unsupported Patterns
In this case, T2 will be dropped as the aggregation has completed.
Pattern Examples
Usage Examples
Basic Response Aggregation
Context-Aware Conversation
Frame Flow
Notes
- Maintains conversation history and roles
- Handles interruptions when configured
- Supports both streaming and complete responses
- Manages proper text spacing
- Provides context management
- Supports tool configuration for function calling
- Thread-safe for pipeline processing