introduce Ruff formatting
This commit is contained in:
@@ -43,6 +43,7 @@ class DataFrame(Frame):
|
||||
@dataclass
|
||||
class AudioRawFrame(DataFrame):
|
||||
"""A chunk of audio."""
|
||||
|
||||
audio: bytes
|
||||
sample_rate: int
|
||||
num_channels: int
|
||||
@@ -58,9 +59,8 @@ class AudioRawFrame(DataFrame):
|
||||
|
||||
@dataclass
|
||||
class InputAudioRawFrame(AudioRawFrame):
|
||||
"""A chunk of audio usually coming from an input transport.
|
||||
"""A chunk of audio usually coming from an input transport."""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@@ -70,14 +70,14 @@ class OutputAudioRawFrame(AudioRawFrame):
|
||||
transport's microphone has been enabled.
|
||||
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
@dataclass
|
||||
class TTSAudioRawFrame(OutputAudioRawFrame):
|
||||
"""A chunk of output audio generated by a TTS service.
|
||||
"""A chunk of output audio generated by a TTS service."""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ class ImageRawFrame(DataFrame):
|
||||
enabled.
|
||||
|
||||
"""
|
||||
|
||||
image: bytes
|
||||
size: Tuple[int, int]
|
||||
format: str | None
|
||||
@@ -112,6 +113,7 @@ class UserImageRawFrame(InputImageRawFrame):
|
||||
transport's camera is enabled.
|
||||
|
||||
"""
|
||||
|
||||
user_id: str
|
||||
|
||||
def __str__(self):
|
||||
@@ -125,11 +127,14 @@ class VisionImageRawFrame(InputImageRawFrame):
|
||||
shown by the transport if the transport's camera is enabled.
|
||||
|
||||
"""
|
||||
|
||||
text: str | None
|
||||
|
||||
def __str__(self):
|
||||
pts = format_pts(self.pts)
|
||||
return f"{self.name}(pts: {pts}, text: {self.text}, size: {self.size}, format: {self.format})"
|
||||
return (
|
||||
f"{self.name}(pts: {pts}, text: {self.text}, size: {self.size}, format: {self.format})"
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -138,6 +143,7 @@ class URLImageRawFrame(OutputImageRawFrame):
|
||||
transport's camera is enabled.
|
||||
|
||||
"""
|
||||
|
||||
url: str | None
|
||||
|
||||
def __str__(self):
|
||||
@@ -152,6 +158,7 @@ class SpriteFrame(Frame):
|
||||
`camera_out_framerate` constructor parameter.
|
||||
|
||||
"""
|
||||
|
||||
images: List[ImageRawFrame]
|
||||
|
||||
def __str__(self):
|
||||
@@ -165,6 +172,7 @@ class TextFrame(DataFrame):
|
||||
be used to send text through pipelines.
|
||||
|
||||
"""
|
||||
|
||||
text: str
|
||||
|
||||
def __str__(self):
|
||||
@@ -178,6 +186,7 @@ class TranscriptionFrame(TextFrame):
|
||||
transport's receive queue when a participant speaks.
|
||||
|
||||
"""
|
||||
|
||||
user_id: str
|
||||
timestamp: str
|
||||
language: Language | None = None
|
||||
@@ -190,6 +199,7 @@ class TranscriptionFrame(TextFrame):
|
||||
class InterimTranscriptionFrame(TextFrame):
|
||||
"""A text frame with interim transcription-specific data. Will be placed in
|
||||
the transport's receive queue when a participant speaks."""
|
||||
|
||||
user_id: str
|
||||
timestamp: str
|
||||
language: Language | None = None
|
||||
@@ -207,6 +217,7 @@ class LLMMessagesFrame(DataFrame):
|
||||
processors.
|
||||
|
||||
"""
|
||||
|
||||
messages: List[dict]
|
||||
|
||||
|
||||
@@ -216,6 +227,7 @@ class LLMMessagesAppendFrame(DataFrame):
|
||||
current context.
|
||||
|
||||
"""
|
||||
|
||||
messages: List[dict]
|
||||
|
||||
|
||||
@@ -226,6 +238,7 @@ class LLMMessagesUpdateFrame(DataFrame):
|
||||
LLMMessagesFrame.
|
||||
|
||||
"""
|
||||
|
||||
messages: List[dict]
|
||||
|
||||
|
||||
@@ -235,13 +248,14 @@ class LLMSetToolsFrame(DataFrame):
|
||||
The specific format depends on the LLM being used, but it should typically
|
||||
contain JSON Schema objects.
|
||||
"""
|
||||
|
||||
tools: List[dict]
|
||||
|
||||
|
||||
@dataclass
|
||||
class LLMEnablePromptCachingFrame(DataFrame):
|
||||
"""A frame to enable/disable prompt caching in certain LLMs.
|
||||
"""
|
||||
"""A frame to enable/disable prompt caching in certain LLMs."""
|
||||
|
||||
enable: bool
|
||||
|
||||
|
||||
@@ -251,6 +265,7 @@ class TTSSpeakFrame(DataFrame):
|
||||
pipeline (if any).
|
||||
|
||||
"""
|
||||
|
||||
text: str
|
||||
|
||||
|
||||
@@ -262,6 +277,7 @@ class TransportMessageFrame(DataFrame):
|
||||
def __str__(self):
|
||||
return f"{self.name}(message: {self.message})"
|
||||
|
||||
|
||||
#
|
||||
# App frames. Application user-defined frames.
|
||||
#
|
||||
@@ -271,6 +287,7 @@ class TransportMessageFrame(DataFrame):
|
||||
class AppFrame(Frame):
|
||||
pass
|
||||
|
||||
|
||||
#
|
||||
# System frames
|
||||
#
|
||||
@@ -284,6 +301,7 @@ class SystemFrame(Frame):
|
||||
@dataclass
|
||||
class StartFrame(SystemFrame):
|
||||
"""This is the first frame that should be pushed down a pipeline."""
|
||||
|
||||
clock: BaseClock
|
||||
allow_interruptions: bool = False
|
||||
enable_metrics: bool = False
|
||||
@@ -294,6 +312,7 @@ class StartFrame(SystemFrame):
|
||||
@dataclass
|
||||
class CancelFrame(SystemFrame):
|
||||
"""Indicates that a pipeline needs to stop right away."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
@@ -304,6 +323,7 @@ class ErrorFrame(SystemFrame):
|
||||
bot should exit.
|
||||
|
||||
"""
|
||||
|
||||
error: str
|
||||
fatal: bool = False
|
||||
|
||||
@@ -317,6 +337,7 @@ class FatalErrorFrame(ErrorFrame):
|
||||
that the bot should exit.
|
||||
|
||||
"""
|
||||
|
||||
fatal: bool = field(default=True, init=False)
|
||||
|
||||
|
||||
@@ -327,6 +348,7 @@ class StopTaskFrame(SystemFrame):
|
||||
the pipeline task.
|
||||
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
@@ -338,6 +360,7 @@ class StartInterruptionFrame(SystemFrame):
|
||||
guaranteed).
|
||||
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
@@ -349,6 +372,7 @@ class StopInterruptionFrame(SystemFrame):
|
||||
guaranteed).
|
||||
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
@@ -359,13 +383,14 @@ class BotInterruptionFrame(SystemFrame):
|
||||
UserStartedSpeakingFrame and UserStoppedSpeakingFrame won't be generated.
|
||||
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
@dataclass
|
||||
class MetricsFrame(SystemFrame):
|
||||
"""Emitted by processor that can compute metrics like latencies.
|
||||
"""
|
||||
"""Emitted by processor that can compute metrics like latencies."""
|
||||
|
||||
data: List[MetricsData]
|
||||
|
||||
|
||||
@@ -388,6 +413,7 @@ class EndFrame(ControlFrame):
|
||||
was sent (unline system frames).
|
||||
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
@@ -395,12 +421,14 @@ class EndFrame(ControlFrame):
|
||||
class LLMFullResponseStartFrame(ControlFrame):
|
||||
"""Used to indicate the beginning of an LLM response. Following by one or
|
||||
more TextFrame and a final LLMFullResponseEndFrame."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
@dataclass
|
||||
class LLMFullResponseEndFrame(ControlFrame):
|
||||
"""Indicates the end of an LLM response."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
@@ -412,28 +440,28 @@ class UserStartedSpeakingFrame(ControlFrame):
|
||||
with a TranscriptionFrame)
|
||||
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
@dataclass
|
||||
class UserStoppedSpeakingFrame(ControlFrame):
|
||||
"""Emitted by the VAD to indicate that a user stopped speaking."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
@dataclass
|
||||
class BotStartedSpeakingFrame(ControlFrame):
|
||||
"""Emitted upstream by transport outputs to indicate the bot started speaking.
|
||||
"""Emitted upstream by transport outputs to indicate the bot started speaking."""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@dataclass
|
||||
class BotStoppedSpeakingFrame(ControlFrame):
|
||||
"""Emitted upstream by transport outputs to indicate the bot stopped speaking.
|
||||
"""Emitted upstream by transport outputs to indicate the bot stopped speaking."""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@@ -445,6 +473,7 @@ class BotSpeakingFrame(ControlFrame):
|
||||
since the user might be listening.
|
||||
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
@@ -457,18 +486,21 @@ class TTSStartedFrame(ControlFrame):
|
||||
needing to control this in the TTS service.
|
||||
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
@dataclass
|
||||
class TTSStoppedFrame(ControlFrame):
|
||||
"""Indicates the end of a TTS response."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
@dataclass
|
||||
class UserImageRequestFrame(ControlFrame):
|
||||
"""A frame user to request an image from the given user."""
|
||||
|
||||
user_id: str
|
||||
context: Optional[Any] = None
|
||||
|
||||
@@ -478,29 +510,29 @@ class UserImageRequestFrame(ControlFrame):
|
||||
|
||||
@dataclass
|
||||
class LLMModelUpdateFrame(ControlFrame):
|
||||
"""A control frame containing a request to update to a new LLM model.
|
||||
"""
|
||||
"""A control frame containing a request to update to a new LLM model."""
|
||||
|
||||
model: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class LLMTemperatureUpdateFrame(ControlFrame):
|
||||
"""A control frame containing a request to update to a new LLM temperature.
|
||||
"""
|
||||
"""A control frame containing a request to update to a new LLM temperature."""
|
||||
|
||||
temperature: float
|
||||
|
||||
|
||||
@dataclass
|
||||
class LLMTopKUpdateFrame(ControlFrame):
|
||||
"""A control frame containing a request to update to a new LLM top_k.
|
||||
"""
|
||||
"""A control frame containing a request to update to a new LLM top_k."""
|
||||
|
||||
top_k: int
|
||||
|
||||
|
||||
@dataclass
|
||||
class LLMTopPUpdateFrame(ControlFrame):
|
||||
"""A control frame containing a request to update to a new LLM top_p.
|
||||
"""
|
||||
"""A control frame containing a request to update to a new LLM top_p."""
|
||||
|
||||
top_p: float
|
||||
|
||||
|
||||
@@ -510,6 +542,7 @@ class LLMFrequencyPenaltyUpdateFrame(ControlFrame):
|
||||
penalty.
|
||||
|
||||
"""
|
||||
|
||||
frequency_penalty: float
|
||||
|
||||
|
||||
@@ -519,41 +552,42 @@ class LLMPresencePenaltyUpdateFrame(ControlFrame):
|
||||
penalty.
|
||||
|
||||
"""
|
||||
|
||||
presence_penalty: float
|
||||
|
||||
|
||||
@dataclass
|
||||
class LLMMaxTokensUpdateFrame(ControlFrame):
|
||||
"""A control frame containing a request to update to a new LLM max tokens.
|
||||
"""
|
||||
"""A control frame containing a request to update to a new LLM max tokens."""
|
||||
|
||||
max_tokens: int
|
||||
|
||||
|
||||
@dataclass
|
||||
class LLMSeedUpdateFrame(ControlFrame):
|
||||
"""A control frame containing a request to update to a new LLM seed.
|
||||
"""
|
||||
"""A control frame containing a request to update to a new LLM seed."""
|
||||
|
||||
seed: int
|
||||
|
||||
|
||||
@dataclass
|
||||
class LLMExtraUpdateFrame(ControlFrame):
|
||||
"""A control frame containing a request to update to a new LLM extra params.
|
||||
"""
|
||||
"""A control frame containing a request to update to a new LLM extra params."""
|
||||
|
||||
extra: dict
|
||||
|
||||
|
||||
@dataclass
|
||||
class TTSModelUpdateFrame(ControlFrame):
|
||||
"""A control frame containing a request to update the TTS model.
|
||||
"""
|
||||
"""A control frame containing a request to update the TTS model."""
|
||||
|
||||
model: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class TTSVoiceUpdateFrame(ControlFrame):
|
||||
"""A control frame containing a request to update to a new TTS voice.
|
||||
"""
|
||||
"""A control frame containing a request to update to a new TTS voice."""
|
||||
|
||||
voice: str
|
||||
|
||||
|
||||
@@ -563,6 +597,7 @@ class TTSLanguageUpdateFrame(ControlFrame):
|
||||
optional voice.
|
||||
|
||||
"""
|
||||
|
||||
language: Language
|
||||
|
||||
|
||||
@@ -572,20 +607,21 @@ class STTModelUpdateFrame(ControlFrame):
|
||||
language.
|
||||
|
||||
"""
|
||||
|
||||
model: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class STTLanguageUpdateFrame(ControlFrame):
|
||||
"""A control frame containing a request to update to STT language.
|
||||
"""
|
||||
"""A control frame containing a request to update to STT language."""
|
||||
|
||||
language: Language
|
||||
|
||||
|
||||
@dataclass
|
||||
class FunctionCallInProgressFrame(SystemFrame):
|
||||
"""A frame signaling that a function call is in progress.
|
||||
"""
|
||||
"""A frame signaling that a function call is in progress."""
|
||||
|
||||
function_name: str
|
||||
tool_call_id: str
|
||||
arguments: str
|
||||
@@ -593,8 +629,8 @@ class FunctionCallInProgressFrame(SystemFrame):
|
||||
|
||||
@dataclass
|
||||
class FunctionCallResultFrame(DataFrame):
|
||||
"""A frame containing the result of an LLM function (tool) call.
|
||||
"""
|
||||
"""A frame containing the result of an LLM function (tool) call."""
|
||||
|
||||
function_name: str
|
||||
tool_call_id: str
|
||||
arguments: str
|
||||
@@ -606,4 +642,5 @@ class VADParamsUpdateFrame(ControlFrame):
|
||||
"""A control frame containing a request to update VAD params. Intended
|
||||
to be pushed upstream from RTVI processor.
|
||||
"""
|
||||
|
||||
params: VADParams
|
||||
|
||||
Reference in New Issue
Block a user