From 8d629d6e908d03d2aa9cf2f7fc54fbc32634a70e Mon Sep 17 00:00:00 2001 From: vipyne Date: Thu, 23 Jan 2025 12:06:23 -0600 Subject: [PATCH] chore(ai_services): pr notes on api_key value exception --- src/pipecat/services/ai_services.py | 5 ++--- src/pipecat/services/moondream.py | 3 +-- src/pipecat/services/whisper.py | 3 +-- src/pipecat/services/xtts.py | 3 +-- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/pipecat/services/ai_services.py b/src/pipecat/services/ai_services.py index b6bb4180c..229699538 100644 --- a/src/pipecat/services/ai_services.py +++ b/src/pipecat/services/ai_services.py @@ -46,9 +46,8 @@ class AIService(FrameProcessor): - def __init__(self, **kwargs): + def __init__(self, *, require_api_key: bool = True, **kwargs): super().__init__(**kwargs) - self._require_api_key: bool = True self._api_key: str = "" self._model_name: str = "" self._settings: Dict[str, Any] = {} @@ -64,7 +63,7 @@ def set_model_name(self, model: str): async def start(self, frame: StartFrame): if self._require_api_key and not self._api_key: - raise Exception(f"{self}: Error: No api_key value found.") + raise Exception(f"{self}: Error: No api_key value provided.") else: pass diff --git a/src/pipecat/services/moondream.py b/src/pipecat/services/moondream.py index 19e9dfbf1..b9c6f15af 100644 --- a/src/pipecat/services/moondream.py +++ b/src/pipecat/services/moondream.py @@ -43,8 +43,7 @@ class MoondreamService(VisionService): def __init__( self, *, model="vikhyatk/moondream2", revision="2024-08-26", use_cpu=False, **kwargs ): - super().__init__(**kwargs) - self._require_api_key = False + super().__init__(require_api_key = False, **kwargs) self.set_model_name(model) diff --git a/src/pipecat/services/whisper.py b/src/pipecat/services/whisper.py index 9e37af1af..2f477894a 100644 --- a/src/pipecat/services/whisper.py +++ b/src/pipecat/services/whisper.py @@ -48,8 +48,7 @@ def __init__( no_speech_prob: float = 0.4, **kwargs, ): - super().__init__(**kwargs) - self._require_api_key = False + super().__init__(require_api_key = False, **kwargs) self._device: str = device self._compute_type = compute_type self.set_model_name(model if isinstance(model, str) else model.value) diff --git a/src/pipecat/services/xtts.py b/src/pipecat/services/xtts.py index 41e9dda04..55508d6ea 100644 --- a/src/pipecat/services/xtts.py +++ b/src/pipecat/services/xtts.py @@ -79,8 +79,7 @@ def __init__( sample_rate: int = 24000, **kwargs, ): - super().__init__(sample_rate=sample_rate, **kwargs) - self._require_api_key = False + super().__init__(require_api_key = False, sample_rate=sample_rate, **kwargs) self._settings = { "language": self.language_to_service_language(language),