Fix type errors in turns and add to pyright checked set
Widen base strategy process_frame return types to ProcessFrameResult | None to match actual behavior (None treated as CONTINUE). Give UserTurnCompletionLLMServiceMixin a FrameProcessor base class so pyright can see create_task, cancel_task, process_frame, and push_frame.
This commit is contained in:
@@ -8,7 +8,8 @@
|
|||||||
"src/pipecat/transcriptions",
|
"src/pipecat/transcriptions",
|
||||||
"src/pipecat/frames",
|
"src/pipecat/frames",
|
||||||
"src/pipecat/observers",
|
"src/pipecat/observers",
|
||||||
"src/pipecat/extensions"
|
"src/pipecat/extensions",
|
||||||
|
"src/pipecat/turns"
|
||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"**/*_pb2.py",
|
"**/*_pb2.py",
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ class BaseUserTurnStartStrategy(BaseObject):
|
|||||||
"""Reset the strategy to its initial state."""
|
"""Reset the strategy to its initial state."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
async def process_frame(self, frame: Frame) -> ProcessFrameResult:
|
async def process_frame(self, frame: Frame) -> ProcessFrameResult | None:
|
||||||
"""Process an incoming frame.
|
"""Process an incoming frame.
|
||||||
|
|
||||||
Subclasses should override this to implement logic that decides whether
|
Subclasses should override this to implement logic that decides whether
|
||||||
@@ -111,8 +111,8 @@ class BaseUserTurnStartStrategy(BaseObject):
|
|||||||
frame: The frame to be processed.
|
frame: The frame to be processed.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
A ProcessFrameResult indicating the outcome. Subclasses that return
|
A ProcessFrameResult indicating the outcome, or None (treated as
|
||||||
None are treated as CONTINUE for backward compatibility.
|
CONTINUE for backward compatibility).
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class BaseUserTurnStopStrategy(BaseObject):
|
|||||||
"""Reset the strategy to its initial state."""
|
"""Reset the strategy to its initial state."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
async def process_frame(self, frame: Frame) -> ProcessFrameResult:
|
async def process_frame(self, frame: Frame) -> ProcessFrameResult | None:
|
||||||
"""Process an incoming frame to decide whether the user stopped speaking.
|
"""Process an incoming frame to decide whether the user stopped speaking.
|
||||||
|
|
||||||
Subclasses should override this to implement logic that decides whether
|
Subclasses should override this to implement logic that decides whether
|
||||||
@@ -99,8 +99,8 @@ class BaseUserTurnStopStrategy(BaseObject):
|
|||||||
frame: The frame to be analyzed.
|
frame: The frame to be analyzed.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
A ProcessFrameResult indicating the outcome. Subclasses that return
|
A ProcessFrameResult indicating the outcome, or None (treated as
|
||||||
None are treated as CONTINUE for backward compatibility.
|
CONTINUE for backward compatibility).
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ from pipecat.frames.frames import (
|
|||||||
LLMRunFrame,
|
LLMRunFrame,
|
||||||
LLMTextFrame,
|
LLMTextFrame,
|
||||||
)
|
)
|
||||||
from pipecat.processors.frame_processor import FrameDirection
|
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
|
||||||
|
|
||||||
# Turn completion markers
|
# Turn completion markers
|
||||||
USER_TURN_COMPLETE_MARKER = "✓"
|
USER_TURN_COMPLETE_MARKER = "✓"
|
||||||
@@ -178,7 +178,7 @@ class UserTurnCompletionConfig:
|
|||||||
return self.incomplete_long_prompt or DEFAULT_INCOMPLETE_LONG_PROMPT
|
return self.incomplete_long_prompt or DEFAULT_INCOMPLETE_LONG_PROMPT
|
||||||
|
|
||||||
|
|
||||||
class UserTurnCompletionLLMServiceMixin:
|
class UserTurnCompletionLLMServiceMixin(FrameProcessor):
|
||||||
"""Mixin that adds turn completion detection to LLM services.
|
"""Mixin that adds turn completion detection to LLM services.
|
||||||
|
|
||||||
This mixin provides methods to push LLM text with turn completion detection.
|
This mixin provides methods to push LLM text with turn completion detection.
|
||||||
|
|||||||
Reference in New Issue
Block a user