Skip to content

Commit

Permalink
chore(ai_services): pr notes on api_key value exception
Browse files Browse the repository at this point in the history
  • Loading branch information
vipyne committed Jan 23, 2025
1 parent f28536b commit 8d629d6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/pipecat/services/ai_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {}
Expand All @@ -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

Expand Down
3 changes: 1 addition & 2 deletions src/pipecat/services/moondream.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 1 addition & 2 deletions src/pipecat/services/whisper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions src/pipecat/services/xtts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 8d629d6

Please sign in to comment.