Skip to content

Commit

Permalink
Merge pull request #162 from pipecat-ai/reset-before-pushing
Browse files Browse the repository at this point in the history
processors: reset aggergator before pushing
  • Loading branch information
aconchillo authored May 22, 2024
2 parents 83ed687 + 979739c commit 34670ee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/pipecat/processors/aggregators/llm_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,15 @@ async def process_frame(self, frame: Frame, direction: FrameDirection):
async def _push_aggregation(self):
if len(self._aggregation) > 0:
self._messages.append({"role": self._role, "content": self._aggregation})
frame = LLMMessagesFrame(self._messages)
await self.push_frame(frame)

# Reset our accumulator state.
# 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)

def _reset(self):
self._aggregation = ""
self._aggregating = False
Expand Down
9 changes: 8 additions & 1 deletion src/pipecat/processors/aggregators/user_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,14 @@ async def process_frame(self, frame: Frame, direction: FrameDirection):

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()
Expand Down

0 comments on commit 34670ee

Please sign in to comment.