Change LLMContextAggregatorPair.create(context) to LLMContextAggregatorPair(context)

This commit is contained in:
Paul Kompfner
2025-08-18 16:03:26 -04:00
parent 8fc76a29bc
commit a962459151
3 changed files with 10 additions and 23 deletions

View File

@@ -119,7 +119,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments):
] ]
context = LLMContext(messages, tools) context = LLMContext(messages, tools)
context_aggregator = LLMContextAggregatorPair.create(context) context_aggregator = LLMContextAggregatorPair(context)
pipeline = Pipeline( pipeline = Pipeline(
[ [

View File

@@ -172,7 +172,7 @@ indicate you should use the get_image tool are:
] ]
context = LLMContext(messages, tools) context = LLMContext(messages, tools)
context_aggregator = LLMContextAggregatorPair.create(context) context_aggregator = LLMContextAggregatorPair(context)
pipeline = Pipeline( pipeline = Pipeline(
[ [

View File

@@ -795,38 +795,25 @@ class LLMAssistantAggregator(LLMContextAggregator):
asyncio.run_coroutine_threadsafe(self.wait_for_task(task), self.get_event_loop()) asyncio.run_coroutine_threadsafe(self.wait_for_task(task), self.get_event_loop())
@dataclass
class LLMContextAggregatorPair: 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: def __init__(
_user: User context aggregator for processing user messages. self,
_assistant: Assistant context aggregator for processing assistant messages.
"""
_user: LLMUserAggregator
_assistant: LLMAssistantAggregator
@staticmethod
def create(
context: LLMContext, context: LLMContext,
*, *,
user_params: LLMUserAggregatorParams = LLMUserAggregatorParams(), user_params: LLMUserAggregatorParams = LLMUserAggregatorParams(),
assistant_params: LLMAssistantAggregatorParams = LLMAssistantAggregatorParams(), assistant_params: LLMAssistantAggregatorParams = LLMAssistantAggregatorParams(),
) -> "LLMContextAggregatorPair": ):
"""Factory method to create an LLMContextAggregatorPair. """Initialize the LLM context aggregator pair.
Args: 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. user_params: Parameters for the user context aggregator.
assistant_params: Parameters for the assistant context aggregator. assistant_params: Parameters for the assistant context aggregator.
Returns:
LLMContextAggregatorPair: A new instance with configured aggregators.
""" """
user = LLMUserAggregator(context, params=user_params) self._user = LLMUserAggregator(context, params=user_params)
assistant = LLMAssistantAggregator(context, params=assistant_params) self._assistant = LLMAssistantAggregator(context, params=assistant_params)
return LLMContextAggregatorPair(_user=user, _assistant=assistant)
def user(self) -> LLMUserAggregator: def user(self) -> LLMUserAggregator:
"""Get the user context aggregator. """Get the user context aggregator.