From a962459151e088f916e015bdcaed82d12d2d4ca4 Mon Sep 17 00:00:00 2001 From: Paul Kompfner Date: Mon, 18 Aug 2025 16:03:26 -0400 Subject: [PATCH] Change `LLMContextAggregatorPair.create(context)` to `LLMContextAggregatorPair(context)` --- .../14w-function-calling-universal-context.py | 2 +- ...nction-calling-google-universal-context.py | 2 +- .../aggregators/llm_response_universal.py | 29 +++++-------------- 3 files changed, 10 insertions(+), 23 deletions(-) diff --git a/examples/foundational/14w-function-calling-universal-context.py b/examples/foundational/14w-function-calling-universal-context.py index 7087a70d6..890c145ab 100644 --- a/examples/foundational/14w-function-calling-universal-context.py +++ b/examples/foundational/14w-function-calling-universal-context.py @@ -119,7 +119,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ] context = LLMContext(messages, tools) - context_aggregator = LLMContextAggregatorPair.create(context) + context_aggregator = LLMContextAggregatorPair(context) pipeline = Pipeline( [ diff --git a/examples/foundational/14x-function-calling-google-universal-context.py b/examples/foundational/14x-function-calling-google-universal-context.py index 0750d230e..b22f2596c 100644 --- a/examples/foundational/14x-function-calling-google-universal-context.py +++ b/examples/foundational/14x-function-calling-google-universal-context.py @@ -172,7 +172,7 @@ indicate you should use the get_image tool are: ] context = LLMContext(messages, tools) - context_aggregator = LLMContextAggregatorPair.create(context) + context_aggregator = LLMContextAggregatorPair(context) pipeline = Pipeline( [ diff --git a/src/pipecat/processors/aggregators/llm_response_universal.py b/src/pipecat/processors/aggregators/llm_response_universal.py index 55d758746..73a6909b4 100644 --- a/src/pipecat/processors/aggregators/llm_response_universal.py +++ b/src/pipecat/processors/aggregators/llm_response_universal.py @@ -795,38 +795,25 @@ class LLMAssistantAggregator(LLMContextAggregator): asyncio.run_coroutine_threadsafe(self.wait_for_task(task), self.get_event_loop()) -@dataclass class LLMContextAggregatorPair: - """Pair of LLM context aggregators for user and assistant messages. + """Pair of LLM context aggregators for updating context with user and assistant messages.""" - Parameters: - _user: User context aggregator for processing user messages. - _assistant: Assistant context aggregator for processing assistant messages. - """ - - _user: LLMUserAggregator - _assistant: LLMAssistantAggregator - - @staticmethod - def create( + def __init__( + self, context: LLMContext, *, user_params: LLMUserAggregatorParams = LLMUserAggregatorParams(), assistant_params: LLMAssistantAggregatorParams = LLMAssistantAggregatorParams(), - ) -> "LLMContextAggregatorPair": - """Factory method to create an LLMContextAggregatorPair. + ): + """Initialize the LLM context aggregator pair. Args: - context: The context managed by the aggregators. + context: The context to be managed by the aggregators. user_params: Parameters for the user context aggregator. assistant_params: Parameters for the assistant context aggregator. - - Returns: - LLMContextAggregatorPair: A new instance with configured aggregators. """ - user = LLMUserAggregator(context, params=user_params) - assistant = LLMAssistantAggregator(context, params=assistant_params) - return LLMContextAggregatorPair(_user=user, _assistant=assistant) + self._user = LLMUserAggregator(context, params=user_params) + self._assistant = LLMAssistantAggregator(context, params=assistant_params) def user(self) -> LLMUserAggregator: """Get the user context aggregator.