GatedOpenAILLMContextAggregator: use keyword argument and add start_open
This commit is contained in:
@@ -47,6 +47,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
- `GatedOpenAILLMContextAggregator` now require keyword arguments. Also, a new
|
||||||
|
`start_open` argument has been added to set the initial state of the gate.
|
||||||
|
|
||||||
- Added `organization` and `project` level authentication to
|
- Added `organization` and `project` level authentication to
|
||||||
`OpenAILLMService`.
|
`OpenAILLMService`.
|
||||||
|
|
||||||
|
|||||||
@@ -16,9 +16,10 @@ class GatedOpenAILLMContextAggregator(FrameProcessor):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, notifier: BaseNotifier, **kwargs):
|
def __init__(self, *, notifier: BaseNotifier, start_open: bool = False, **kwargs):
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self._notifier = notifier
|
self._notifier = notifier
|
||||||
|
self._start_open = start_open
|
||||||
self._last_context_frame = None
|
self._last_context_frame = None
|
||||||
|
|
||||||
async def process_frame(self, frame: Frame, direction: FrameDirection):
|
async def process_frame(self, frame: Frame, direction: FrameDirection):
|
||||||
@@ -31,7 +32,11 @@ class GatedOpenAILLMContextAggregator(FrameProcessor):
|
|||||||
await self._stop()
|
await self._stop()
|
||||||
await self.push_frame(frame)
|
await self.push_frame(frame)
|
||||||
elif isinstance(frame, OpenAILLMContextFrame):
|
elif isinstance(frame, OpenAILLMContextFrame):
|
||||||
self._last_context_frame = frame
|
if self._start_open:
|
||||||
|
self._start_open = False
|
||||||
|
await self.push_frame(frame, direction)
|
||||||
|
else:
|
||||||
|
self._last_context_frame = frame
|
||||||
else:
|
else:
|
||||||
await self.push_frame(frame, direction)
|
await self.push_frame(frame, direction)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user