Merge pull request #2147 from pipecat-ai/mb/user-idle-long-function-call
UserIdleProcessor: Account for function calls in progress
This commit is contained in:
@@ -13,6 +13,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
the case where the user has hung up before the `TwilioFrameSerializer` hangs
|
the case where the user has hung up before the `TwilioFrameSerializer` hangs
|
||||||
up the call.
|
up the call.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- The `UserIdleProcessor` now handles the scenario where function calls take
|
||||||
|
longer than the idle timeout duration. This allows you to use the
|
||||||
|
`UserIdleProcessor` in conjunction with function calls that take a while to
|
||||||
|
return a result.
|
||||||
|
|
||||||
### Performance
|
### Performance
|
||||||
|
|
||||||
- Remove unncessary push task in each `FrameProcessor`.
|
- Remove unncessary push task in each `FrameProcessor`.
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ from pipecat.frames.frames import (
|
|||||||
CancelFrame,
|
CancelFrame,
|
||||||
EndFrame,
|
EndFrame,
|
||||||
Frame,
|
Frame,
|
||||||
|
FunctionCallInProgressFrame,
|
||||||
|
FunctionCallResultFrame,
|
||||||
StartFrame,
|
StartFrame,
|
||||||
UserStartedSpeakingFrame,
|
UserStartedSpeakingFrame,
|
||||||
UserStoppedSpeakingFrame,
|
UserStoppedSpeakingFrame,
|
||||||
@@ -168,6 +170,13 @@ class UserIdleProcessor(FrameProcessor):
|
|||||||
self._idle_event.set()
|
self._idle_event.set()
|
||||||
elif isinstance(frame, BotSpeakingFrame):
|
elif isinstance(frame, BotSpeakingFrame):
|
||||||
self._idle_event.set()
|
self._idle_event.set()
|
||||||
|
elif isinstance(frame, FunctionCallInProgressFrame):
|
||||||
|
# Function calls can take longer than the timeout, so we want to prevent idle callbacks
|
||||||
|
self._interrupted = True
|
||||||
|
self._idle_event.set()
|
||||||
|
elif isinstance(frame, FunctionCallResultFrame):
|
||||||
|
self._interrupted = False
|
||||||
|
self._idle_event.set()
|
||||||
|
|
||||||
async def cleanup(self) -> None:
|
async def cleanup(self) -> None:
|
||||||
"""Cleans up resources when processor is shutting down."""
|
"""Cleans up resources when processor is shutting down."""
|
||||||
|
|||||||
Reference in New Issue
Block a user