Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ai_services): raise exception if api_key None or empty #1056

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

vipyne
Copy link
Member

@vipyne vipyne commented Jan 21, 2025

Please describe the changes in your PR. If it is addressing an issue, please reference that as well.

closes #941

Raises exception if the value of an API key is None or empty.

@@ -44,6 +44,7 @@ def __init__(
self, *, model="vikhyatk/moondream2", revision="2024-08-26", use_cpu=False, **kwargs
):
super().__init__(**kwargs)
self._require_api_key = False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super().__init__(require_api_key = False, **kwargs)

@@ -61,7 +63,10 @@ def set_model_name(self, model: str):
self.set_core_metrics_data(MetricsData(processor=self.name, model=self._model_name))

async def start(self, frame: StartFrame):
pass
if self._require_api_key and not self._api_key:
raise Exception(f"{self}: Error: No api_key value found.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we create a custom expection for this, like APIKeyMissing / APIKeyError, this is save us from cases where we would need to catch it but can only do it via expect Exception

src/pipecat/services/ai_services.py Outdated Show resolved Hide resolved
@vipyne vipyne force-pushed the vp-941-raise-no-api-key-exception branch 2 times, most recently from 8d629d6 to 1674c85 Compare January 23, 2025 18:09
@vipyne vipyne force-pushed the vp-941-raise-no-api-key-exception branch from 1674c85 to 4a7d5bf Compare January 24, 2025 03:48
@vipyne vipyne requested a review from aconchillo January 24, 2025 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Raising Exception when API Key in any service is None or Blank
3 participants