aggregators: accumulate full responses and take interruptions into account
This commit is contained in:
@@ -12,6 +12,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- `LLMUserResponseAggregator` and `LLMAssistantResponseAggregator` internal
|
- `LLMUserResponseAggregator` and `LLMAssistantResponseAggregator` internal
|
||||||
messages are now exposed through the `messages` property.
|
messages are now exposed through the `messages` property.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed an issue where `LLMAssistantResponseAggregator` was not accumulating the
|
||||||
|
full response but short sentences instead. If there's an interruption we only
|
||||||
|
accumulate what the bot has spoken until now in a long response as well.
|
||||||
|
|
||||||
## [0.0.18] - 2024-05-20
|
## [0.0.18] - 2024-05-20
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -11,12 +11,11 @@ from pipecat.frames.frames import (
|
|||||||
Frame,
|
Frame,
|
||||||
InterimTranscriptionFrame,
|
InterimTranscriptionFrame,
|
||||||
LLMFullResponseEndFrame,
|
LLMFullResponseEndFrame,
|
||||||
|
LLMFullResponseStartFrame,
|
||||||
LLMMessagesFrame,
|
LLMMessagesFrame,
|
||||||
LLMResponseStartFrame,
|
|
||||||
StartInterruptionFrame,
|
StartInterruptionFrame,
|
||||||
TextFrame,
|
|
||||||
LLMResponseEndFrame,
|
|
||||||
TranscriptionFrame,
|
TranscriptionFrame,
|
||||||
|
TextFrame,
|
||||||
UserStartedSpeakingFrame,
|
UserStartedSpeakingFrame,
|
||||||
UserStoppedSpeakingFrame)
|
UserStoppedSpeakingFrame)
|
||||||
|
|
||||||
@@ -103,6 +102,8 @@ class LLMResponseAggregator(FrameProcessor):
|
|||||||
elif self._interim_accumulator_frame and isinstance(frame, self._interim_accumulator_frame):
|
elif self._interim_accumulator_frame and isinstance(frame, self._interim_accumulator_frame):
|
||||||
self._seen_interim_results = True
|
self._seen_interim_results = True
|
||||||
elif isinstance(frame, StartInterruptionFrame):
|
elif isinstance(frame, StartInterruptionFrame):
|
||||||
|
await self._push_aggregation()
|
||||||
|
# Reset anyways
|
||||||
self._reset()
|
self._reset()
|
||||||
await self.push_frame(frame, direction)
|
await self.push_frame(frame, direction)
|
||||||
else:
|
else:
|
||||||
@@ -133,8 +134,8 @@ class LLMAssistantResponseAggregator(LLMResponseAggregator):
|
|||||||
super().__init__(
|
super().__init__(
|
||||||
messages=messages,
|
messages=messages,
|
||||||
role="assistant",
|
role="assistant",
|
||||||
start_frame=LLMResponseStartFrame,
|
start_frame=LLMFullResponseStartFrame,
|
||||||
end_frame=LLMResponseEndFrame,
|
end_frame=LLMFullResponseEndFrame,
|
||||||
accumulator_frame=TextFrame
|
accumulator_frame=TextFrame
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user