Add InterruptionConfig
This commit is contained in:
@@ -438,6 +438,20 @@ class OutputDTMFFrame(DTMFFrame, DataFrame):
|
||||
#
|
||||
|
||||
|
||||
@dataclass
|
||||
class InterruptionConfig:
|
||||
"""Configuration for interruption behavior.
|
||||
|
||||
When specified, the bot will not be interrupted immediately when the user speaks.
|
||||
Instead, interruption will only occur when the configured conditions are met.
|
||||
|
||||
Args:
|
||||
min_words: If set, user must speak at least this many words to interrupt
|
||||
"""
|
||||
|
||||
min_words: Optional[int] = None
|
||||
|
||||
|
||||
@dataclass
|
||||
class StartFrame(SystemFrame):
|
||||
"""This is the first frame that should be pushed down a pipeline."""
|
||||
@@ -448,6 +462,7 @@ class StartFrame(SystemFrame):
|
||||
enable_metrics: bool = False
|
||||
enable_usage_metrics: bool = False
|
||||
report_only_initial_ttfb: bool = False
|
||||
interruption_config: Optional[InterruptionConfig] = None
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@@ -22,6 +22,7 @@ from pipecat.frames.frames import (
|
||||
ErrorFrame,
|
||||
Frame,
|
||||
HeartbeatFrame,
|
||||
InterruptionConfig,
|
||||
LLMFullResponseEndFrame,
|
||||
MetricsFrame,
|
||||
StartFrame,
|
||||
@@ -58,6 +59,7 @@ class PipelineParams(BaseModel):
|
||||
report_only_initial_ttfb: Whether to report only initial time to first byte.
|
||||
send_initial_empty_metrics: Whether to send initial empty metrics.
|
||||
start_metadata: Additional metadata for pipeline start.
|
||||
interruption_config: Configuration for bot interruption behavior.
|
||||
"""
|
||||
|
||||
model_config = ConfigDict(arbitrary_types_allowed=True)
|
||||
@@ -73,6 +75,7 @@ class PipelineParams(BaseModel):
|
||||
report_only_initial_ttfb: bool = False
|
||||
send_initial_empty_metrics: bool = True
|
||||
start_metadata: Dict[str, Any] = Field(default_factory=dict)
|
||||
interruption_config: Optional[InterruptionConfig] = None
|
||||
|
||||
|
||||
class PipelineTaskSource(FrameProcessor):
|
||||
@@ -518,6 +521,7 @@ class PipelineTask(BaseTask):
|
||||
enable_metrics=self._params.enable_metrics,
|
||||
enable_usage_metrics=self._params.enable_usage_metrics,
|
||||
report_only_initial_ttfb=self._params.report_only_initial_ttfb,
|
||||
interruption_config=self._params.interruption_config,
|
||||
)
|
||||
start_frame.metadata = self._params.start_metadata
|
||||
await self._source.queue_frame(start_frame, FrameDirection.DOWNSTREAM)
|
||||
|
||||
Reference in New Issue
Block a user