Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "celeste-ai"
version = "0.2.4"
version = "0.2.5"
description = "Open source, type-safe primitives for multi-modal AI. All capabilities, all providers, one interface"
authors = [{name = "Kamilbenkirane", email = "kamil@withceleste.ai"}]
readme = "README.md"
Expand Down
2 changes: 2 additions & 0 deletions src/celeste/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
StreamNotExhaustedError,
UnsupportedCapabilityError,
UnsupportedParameterError,
UnsupportedProviderError,
ValidationError,
)
from celeste.http import HTTPClient, close_all_http_clients
Expand Down Expand Up @@ -120,6 +121,7 @@ def create_client(
"StreamingNotSupportedError",
"UnsupportedCapabilityError",
"UnsupportedParameterError",
"UnsupportedProviderError",
"Usage",
"ValidationError",
"close_all_http_clients",
Expand Down
4 changes: 4 additions & 0 deletions src/celeste/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Provider(StrEnum):
TOPAZLABS = "topazlabs"
PERPLEXITY = "perplexity"
BYTEDANCE = "bytedance"
ELEVENLABS = "elevenlabs"


class Capability(StrEnum):
Expand All @@ -39,6 +40,9 @@ class Capability(StrEnum):
# Audio
AUDIO_INTELLIGENCE = "audio-intelligence"

# Speech
SPEECH_GENERATION = "speech-generation"

# Search
SEARCH = "search"

Expand Down
9 changes: 5 additions & 4 deletions src/celeste/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pydantic_settings import BaseSettings

from celeste.core import Provider
from celeste.exceptions import MissingCredentialsError
from celeste.exceptions import MissingCredentialsError, UnsupportedProviderError

# Provider to credential field mapping
PROVIDER_CREDENTIAL_MAP = {
Expand All @@ -22,6 +22,7 @@
Provider.TOPAZLABS: "topazlabs_api_key",
Provider.PERPLEXITY: "perplexity_api_key",
Provider.BYTEDANCE: "bytedance_api_key",
Provider.ELEVENLABS: "elevenlabs_api_key",
}


Expand All @@ -41,6 +42,7 @@ class Credentials(BaseSettings):
topazlabs_api_key: SecretStr | None = Field(None, alias="TOPAZLABS_API_KEY")
perplexity_api_key: SecretStr | None = Field(None, alias="PERPLEXITY_API_KEY")
bytedance_api_key: SecretStr | None = Field(None, alias="BYTEDANCE_API_KEY")
elevenlabs_api_key: SecretStr | None = Field(None, alias="ELEVENLABS_API_KEY")

model_config = {
"env_file": find_dotenv(),
Expand Down Expand Up @@ -95,12 +97,11 @@ def has_credential(self, provider: Provider) -> bool:
True if provider has credentials configured, False if credentials not set.

Raises:
ValueError: If provider has no credential mapping.
UnsupportedProviderError: If provider has no credential mapping.
"""
credential_field = PROVIDER_CREDENTIAL_MAP.get(provider)
if not credential_field:
msg = f"Provider {provider} has no credential mapping"
raise ValueError(msg)
raise UnsupportedProviderError(provider=provider)
return getattr(self, credential_field, None) is not None


Expand Down
13 changes: 13 additions & 0 deletions src/celeste/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,18 @@ def __init__(self, provider: str) -> None:
)


class UnsupportedProviderError(CredentialsError):
"""Raised when a provider is not configured in the credential system."""

def __init__(self, provider: str) -> None:
"""Initialize with provider details."""
self.provider = provider
super().__init__(
f"Provider {provider} has no credential mapping. "
f"This provider is not configured in the credential system."
)


class UnsupportedParameterError(ValidationError):
"""Raised when a parameter is not supported by a model."""

Expand All @@ -170,4 +182,5 @@ def __init__(self, parameter: str, model_id: str) -> None:
"StreamingNotSupportedError",
"UnsupportedCapabilityError",
"UnsupportedParameterError",
"UnsupportedProviderError",
]
Loading