Merge pull request #162 from pipecat-ai/reset-before-pushing
processors: reset aggergator before pushing
This commit is contained in:
@@ -117,12 +117,15 @@ class LLMResponseAggregator(FrameProcessor):
|
||||
async def _push_aggregation(self):
|
||||
if len(self._aggregation) > 0:
|
||||
self._messages.append({"role": self._role, "content": self._aggregation})
|
||||
|
||||
# Reset our accumulator state. Reset it before pushing it down,
|
||||
# otherwise if the tasks gets cancelled we won't be able to clear
|
||||
# things up.
|
||||
self._reset()
|
||||
|
||||
frame = LLMMessagesFrame(self._messages)
|
||||
await self.push_frame(frame)
|
||||
|
||||
# Reset our accumulator state.
|
||||
self._reset()
|
||||
|
||||
def _reset(self):
|
||||
self._aggregation = ""
|
||||
self._aggregating = False
|
||||
|
||||
@@ -118,7 +118,14 @@ class ResponseAggregator(FrameProcessor):
|
||||
|
||||
async def _push_aggregation(self):
|
||||
if len(self._aggregation) > 0:
|
||||
await self.push_frame(TextFrame(self._aggregation.strip()))
|
||||
frame = TextFrame(self._aggregation.strip())
|
||||
|
||||
# Reset our accumulator state. Reset it before pushing it down,
|
||||
# otherwise if the tasks gets cancelled we won't be able to clear
|
||||
# things up.
|
||||
self._reset()
|
||||
|
||||
await self.push_frame(frame)
|
||||
|
||||
# Reset our accumulator state.
|
||||
self._reset()
|
||||
|
||||
Reference in New Issue
Block a user