Change LLMContextAggregatorPair.create(context) to LLMContextAggregatorPair(context)
This commit is contained in:
@@ -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(
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -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(
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
Reference in New Issue
Block a user