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/frames",
|
||||
"src/pipecat/observers",
|
||||
"src/pipecat/extensions"
|
||||
"src/pipecat/extensions",
|
||||
"src/pipecat/turns"
|
||||
],
|
||||
"exclude": [
|
||||
"**/*_pb2.py",
|
||||
|
||||
@@ -101,7 +101,7 @@ class BaseUserTurnStartStrategy(BaseObject):
|
||||
"""Reset the strategy to its initial state."""
|
||||
pass
|
||||
|
||||
async def process_frame(self, frame: Frame) -> ProcessFrameResult:
|
||||
async def process_frame(self, frame: Frame) -> ProcessFrameResult | None:
|
||||
"""Process an incoming frame.
|
||||
|
||||
Subclasses should override this to implement logic that decides whether
|
||||
@@ -111,8 +111,8 @@ class BaseUserTurnStartStrategy(BaseObject):
|
||||
frame: The frame to be processed.
|
||||
|
||||
Returns:
|
||||
A ProcessFrameResult indicating the outcome. Subclasses that return
|
||||
None are treated as CONTINUE for backward compatibility.
|
||||
A ProcessFrameResult indicating the outcome, or None (treated as
|
||||
CONTINUE for backward compatibility).
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ class BaseUserTurnStopStrategy(BaseObject):
|
||||
"""Reset the strategy to its initial state."""
|
||||
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.
|
||||
|
||||
Subclasses should override this to implement logic that decides whether
|
||||
@@ -99,8 +99,8 @@ class BaseUserTurnStopStrategy(BaseObject):
|
||||
frame: The frame to be analyzed.
|
||||
|
||||
Returns:
|
||||
A ProcessFrameResult indicating the outcome. Subclasses that return
|
||||
None are treated as CONTINUE for backward compatibility.
|
||||
A ProcessFrameResult indicating the outcome, or None (treated as
|
||||
CONTINUE for backward compatibility).
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ from pipecat.frames.frames import (
|
||||
LLMRunFrame,
|
||||
LLMTextFrame,
|
||||
)
|
||||
from pipecat.processors.frame_processor import FrameDirection
|
||||
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
|
||||
|
||||
# Turn completion markers
|
||||
USER_TURN_COMPLETE_MARKER = "✓"
|
||||
@@ -178,7 +178,7 @@ class UserTurnCompletionConfig:
|
||||
return self.incomplete_long_prompt or DEFAULT_INCOMPLETE_LONG_PROMPT
|
||||
|
||||
|
||||
class UserTurnCompletionLLMServiceMixin:
|
||||
class UserTurnCompletionLLMServiceMixin(FrameProcessor):
|
||||
"""Mixin that adds turn completion detection to LLM services.
|
||||
|
||||
This mixin provides methods to push LLM text with turn completion detection.
|
||||
|
||||
Reference in New Issue
Block a user