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 src/celeste/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def _stream(

@classmethod
@abstractmethod
def parameter_mappers(cls) -> list[ParameterMapper]:
def parameter_mappers(cls) -> list[ParameterMapper[Content]]:
"""Provider-specific parameter mappers."""
...

Expand Down
3 changes: 2 additions & 1 deletion src/celeste/modalities/audio/providers/elevenlabs/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from celeste.providers.elevenlabs.text_to_speech.streaming import (
ElevenLabsTextToSpeechStream as _ElevenLabsTextToSpeechStream,
)
from celeste.types import AudioContent

from ...client import AudioClient
from ...io import (
Expand Down Expand Up @@ -40,7 +41,7 @@ class ElevenLabsAudioClient(ElevenLabsTextToSpeechMixin, AudioClient):
"""ElevenLabs audio client (TTS)."""

@classmethod
def parameter_mappers(cls) -> list[ParameterMapper]:
def parameter_mappers(cls) -> list[ParameterMapper[AudioContent]]:
return ELEVENLABS_PARAMETER_MAPPERS

async def speak(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from celeste.providers.elevenlabs.text_to_speech.parameters import (
VoiceMapper as _VoiceMapper,
)
from celeste.types import AudioContent

from ...parameters import AudioParameter

Expand Down Expand Up @@ -41,7 +42,7 @@ class LanguageCodeMapper(_LanguageCodeMapper):
name = AudioParameter.LANGUAGE


ELEVENLABS_PARAMETER_MAPPERS: list[ParameterMapper] = [
ELEVENLABS_PARAMETER_MAPPERS: list[ParameterMapper[AudioContent]] = [
VoiceMapper(),
SpeedMapper(),
OutputFormatMapper(),
Expand Down
3 changes: 2 additions & 1 deletion src/celeste/modalities/audio/providers/google/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from celeste.providers.google.cloud_tts.client import (
GoogleCloudTTSClient as GoogleCloudTTSMixin,
)
from celeste.types import AudioContent

from ...client import AudioClient
from ...io import (
Expand All @@ -23,7 +24,7 @@ class GoogleAudioClient(GoogleCloudTTSMixin, AudioClient):
"""Google audio client (Cloud TTS)."""

@classmethod
def parameter_mappers(cls) -> list[ParameterMapper]:
def parameter_mappers(cls) -> list[ParameterMapper[AudioContent]]:
return GOOGLE_PARAMETER_MAPPERS

async def speak(
Expand Down
3 changes: 2 additions & 1 deletion src/celeste/modalities/audio/providers/google/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from celeste.providers.google.cloud_tts.parameters import (
VoiceMapper as _VoiceMapper,
)
from celeste.types import AudioContent

from ...parameters import AudioParameter

Expand Down Expand Up @@ -63,7 +64,7 @@ class OutputFormatMapper(_AudioEncodingMapper):
}


GOOGLE_PARAMETER_MAPPERS: list[ParameterMapper] = [
GOOGLE_PARAMETER_MAPPERS: list[ParameterMapper[AudioContent]] = [
VoiceMapper(),
LanguageMapper(),
OutputFormatMapper(),
Expand Down
3 changes: 2 additions & 1 deletion src/celeste/modalities/audio/providers/gradium/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from celeste.providers.gradium.text_to_speech.streaming import (
GradiumTextToSpeechStream as _GradiumTextToSpeechStream,
)
from celeste.types import AudioContent

from ...client import AudioClient
from ...io import (
Expand Down Expand Up @@ -40,7 +41,7 @@ class GradiumAudioClient(GradiumTextToSpeechMixin, AudioClient):
"""Gradium audio client (TTS)."""

@classmethod
def parameter_mappers(cls) -> list[ParameterMapper]:
def parameter_mappers(cls) -> list[ParameterMapper[AudioContent]]:
return GRADIUM_PARAMETER_MAPPERS

async def speak(
Expand Down
3 changes: 2 additions & 1 deletion src/celeste/modalities/audio/providers/gradium/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from celeste.providers.gradium.text_to_speech.parameters import (
VoiceMapper as _VoiceMapper,
)
from celeste.types import AudioContent

from ...parameters import AudioParameter

Expand All @@ -23,7 +24,7 @@ class OutputFormatMapper(_OutputFormatMapper):
name = AudioParameter.OUTPUT_FORMAT


GRADIUM_PARAMETER_MAPPERS: list[ParameterMapper] = [
GRADIUM_PARAMETER_MAPPERS: list[ParameterMapper[AudioContent]] = [
VoiceMapper(),
OutputFormatMapper(),
]
Expand Down
3 changes: 2 additions & 1 deletion src/celeste/modalities/audio/providers/openai/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from celeste.parameters import ParameterMapper
from celeste.providers.openai.audio import config
from celeste.providers.openai.audio.client import OpenAIAudioClient as OpenAIAudioMixin
from celeste.types import AudioContent

from ...client import AudioClient
from ...io import AudioFinishReason, AudioInput, AudioOutput
Expand All @@ -17,7 +18,7 @@ class OpenAIAudioClient(OpenAIAudioMixin, AudioClient):
"""OpenAI audio client (TTS)."""

@classmethod
def parameter_mappers(cls) -> list[ParameterMapper]:
def parameter_mappers(cls) -> list[ParameterMapper[AudioContent]]:
return OPENAI_PARAMETER_MAPPERS

async def speak(
Expand Down
3 changes: 2 additions & 1 deletion src/celeste/modalities/audio/providers/openai/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from celeste.providers.openai.audio.parameters import (
VoiceMapper as _VoiceMapper,
)
from celeste.types import AudioContent

from ...parameters import AudioParameter

Expand All @@ -32,7 +33,7 @@ class OutputFormatMapper(_ResponseFormatMapper):
name = AudioParameter.OUTPUT_FORMAT


OPENAI_PARAMETER_MAPPERS: list[ParameterMapper] = [
OPENAI_PARAMETER_MAPPERS: list[ParameterMapper[AudioContent]] = [
VoiceMapper(),
SpeedMapper(),
OutputFormatMapper(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class GoogleEmbeddingsClient(GoogleEmbeddingsMixin, EmbeddingsClient):
"""Google embeddings client."""

@classmethod
def parameter_mappers(cls) -> list[ParameterMapper]:
def parameter_mappers(cls) -> list[ParameterMapper[EmbeddingsContent]]:
"""Return parameter mappers for Google embeddings."""
return GOOGLE_PARAMETER_MAPPERS

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from celeste.providers.google.embeddings.parameters import (
OutputDimensionalityMapper as _OutputDimensionalityMapper,
)
from celeste.types import EmbeddingsContent

from ...parameters import EmbeddingsParameter

Expand All @@ -14,7 +15,7 @@ class DimensionsMapper(_OutputDimensionalityMapper):
name = EmbeddingsParameter.DIMENSIONS


GOOGLE_PARAMETER_MAPPERS: list[ParameterMapper] = [
GOOGLE_PARAMETER_MAPPERS: list[ParameterMapper[EmbeddingsContent]] = [
DimensionsMapper(),
]

Expand Down
3 changes: 2 additions & 1 deletion src/celeste/modalities/images/providers/bfl/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from celeste.providers.bfl.images import config as bfl_config
from celeste.providers.bfl.images.client import BFLImagesClient as _BFLImagesClient
from celeste.providers.bfl.images.utils import encode_image
from celeste.types import ImageContent

from ...client import ImagesClient
from ...io import ImageFinishReason, ImageInput, ImageOutput
Expand All @@ -18,7 +19,7 @@ class BFLImagesClient(_BFLImagesClient, ImagesClient):
"""BFL images client (generate + edit)."""

@classmethod
def parameter_mappers(cls) -> list[ParameterMapper]:
def parameter_mappers(cls) -> list[ParameterMapper[ImageContent]]:
return BFL_PARAMETER_MAPPERS

async def generate(
Expand Down
7 changes: 4 additions & 3 deletions src/celeste/modalities/images/providers/bfl/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
WidthMapper as _WidthMapper,
)
from celeste.providers.bfl.images.utils import add_reference_images
from celeste.types import ImageContent

from ...parameters import ImageParameter


class AspectRatioMapper(ParameterMapper):
class AspectRatioMapper(ParameterMapper[ImageContent]):
"""Map aspect_ratio to BFL width/height parameters.

Converts 'WxH' string to width/height, rounded to nearest multiple of 16.
Expand Down Expand Up @@ -91,7 +92,7 @@ class GuidanceMapper(_GuidanceMapper):
name = ImageParameter.GUIDANCE


class ReferenceImagesMapper(ParameterMapper):
class ReferenceImagesMapper(ParameterMapper[ImageContent]):
name = ImageParameter.REFERENCE_IMAGES

def map(
Expand All @@ -108,7 +109,7 @@ def map(
return add_reference_images(request, validated_value)


BFL_PARAMETER_MAPPERS: list[ParameterMapper] = [
BFL_PARAMETER_MAPPERS: list[ParameterMapper[ImageContent]] = [
AspectRatioMapper(),
PromptUpsamplingMapper(),
SeedMapper(),
Expand Down
3 changes: 2 additions & 1 deletion src/celeste/modalities/images/providers/byteplus/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from celeste.providers.byteplus.images.streaming import (
BytePlusImagesStream as _BytePlusImagesStream,
)
from celeste.types import ImageContent

from ...client import ImagesClient
from ...io import (
Expand Down Expand Up @@ -94,7 +95,7 @@ class BytePlusImagesClient(BytePlusImagesMixin, ImagesClient):
"""BytePlus images client (generate + streaming)."""

@classmethod
def parameter_mappers(cls) -> list[ParameterMapper]:
def parameter_mappers(cls) -> list[ParameterMapper[ImageContent]]:
return BYTEPLUS_PARAMETER_MAPPERS

async def generate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from celeste.providers.byteplus.images.parameters import (
WatermarkMapper as _WatermarkMapper,
)
from celeste.types import ImageContent

from ...parameters import ImageParameter

Expand All @@ -25,7 +26,7 @@ class WatermarkMapper(_WatermarkMapper):
name = ImageParameter.WATERMARK


BYTEPLUS_PARAMETER_MAPPERS: list[ParameterMapper] = [
BYTEPLUS_PARAMETER_MAPPERS: list[ParameterMapper[ImageContent]] = [
AspectRatioMapper(),
QualityMapper(),
WatermarkMapper(),
Expand Down
2 changes: 1 addition & 1 deletion src/celeste/modalities/images/providers/google/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def model_post_init(self, __context: object) -> None:
object.__setattr__(self, "_strategy", strategy)

@classmethod
def parameter_mappers(cls) -> list[ParameterMapper]:
def parameter_mappers(cls) -> list[ParameterMapper[ImageContent]]:
return [*GEMINI_PARAMETER_MAPPERS, *IMAGEN_PARAMETER_MAPPERS]

async def generate(
Expand Down
2 changes: 1 addition & 1 deletion src/celeste/modalities/images/providers/google/gemini.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class GeminiImagesClient(GoogleGenerateContentClient, ImagesClient):
"""Google Gemini client for images modality (generate + edit)."""

@classmethod
def parameter_mappers(cls) -> list[ParameterMapper]:
def parameter_mappers(cls) -> list[ParameterMapper[ImageContent]]:
return GEMINI_PARAMETER_MAPPERS

async def generate(
Expand Down
2 changes: 1 addition & 1 deletion src/celeste/modalities/images/providers/google/imagen.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ImagenImagesClient(GoogleImagenClient, ImagesClient):
"""Google Imagen client for images modality (generate)."""

@classmethod
def parameter_mappers(cls) -> list[ParameterMapper]:
def parameter_mappers(cls) -> list[ParameterMapper[ImageContent]]:
return IMAGEN_PARAMETER_MAPPERS

async def generate(
Expand Down
11 changes: 6 additions & 5 deletions src/celeste/modalities/images/providers/google/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from celeste.providers.google.imagen.parameters import (
SampleCountMapper as _ImagenSampleCountMapper,
)
from celeste.types import ImageContent

from ...parameters import ImageParameter

Expand All @@ -41,32 +42,32 @@ class ImagenNumImagesMapper(_ImagenSampleCountMapper):
name = ImageParameter.NUM_IMAGES


IMAGEN_PARAMETER_MAPPERS: list[ParameterMapper] = [
IMAGEN_PARAMETER_MAPPERS: list[ParameterMapper[ImageContent]] = [
ImagenAspectRatioMapper(),
ImagenQualityMapper(),
ImagenNumImagesMapper(),
]


class GeminiAspectRatioMapper(_GeminiAspectRatioMapper):
class GeminiAspectRatioMapper(_GeminiAspectRatioMapper[ImageContent]):
"""Map aspect_ratio to Gemini generationConfig.imageConfig.aspectRatio."""

name = ImageParameter.ASPECT_RATIO


class GeminiQualityMapper(_GeminiImageSizeMapper):
class GeminiQualityMapper(_GeminiImageSizeMapper[ImageContent]):
"""Map quality to Gemini generationConfig.imageConfig.imageSize."""

name = ImageParameter.QUALITY


class GeminiReferenceImagesMapper(_GeminiMediaContentMapper):
class GeminiReferenceImagesMapper(_GeminiMediaContentMapper[ImageContent]):
"""Map reference_images to Gemini contents.parts."""

name = ImageParameter.REFERENCE_IMAGES


GEMINI_PARAMETER_MAPPERS: list[ParameterMapper] = [
GEMINI_PARAMETER_MAPPERS: list[ParameterMapper[ImageContent]] = [
GeminiAspectRatioMapper(),
GeminiQualityMapper(),
GeminiReferenceImagesMapper(),
Expand Down
3 changes: 2 additions & 1 deletion src/celeste/modalities/images/providers/ollama/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from celeste.providers.ollama.generate.streaming import (
OllamaGenerateStream as _OllamaGenerateStream,
)
from celeste.types import ImageContent

from ...client import ImagesClient
from ...io import (
Expand Down Expand Up @@ -54,7 +55,7 @@ class OllamaImagesClient(OllamaGenerateClient, ImagesClient):
"""Ollama images client (generate only, no edit support yet)."""

@classmethod
def parameter_mappers(cls) -> list[ParameterMapper]:
def parameter_mappers(cls) -> list[ParameterMapper[ImageContent]]:
return OLLAMA_PARAMETER_MAPPERS

async def generate(
Expand Down
5 changes: 3 additions & 2 deletions src/celeste/modalities/images/providers/ollama/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
from celeste.providers.ollama.generate.parameters import (
WidthMapper as _WidthMapper,
)
from celeste.types import ImageContent

from ...parameters import ImageParameter


class AspectRatioMapper(ParameterMapper):
class AspectRatioMapper(ParameterMapper[ImageContent]):
"""Map aspect_ratio to Ollama's width and height parameters.

Parses 'WxH' string and delegates to native mappers.
Expand Down Expand Up @@ -69,7 +70,7 @@ class NegativePromptMapper(_NegativePromptMapper):
name = ImageParameter.NEGATIVE_PROMPT


OLLAMA_PARAMETER_MAPPERS: list[ParameterMapper] = [
OLLAMA_PARAMETER_MAPPERS: list[ParameterMapper[ImageContent]] = [
AspectRatioMapper(),
StepsMapper(),
SeedMapper(),
Expand Down
3 changes: 2 additions & 1 deletion src/celeste/modalities/images/providers/openai/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from celeste.providers.openai.images.streaming import (
OpenAIImagesStream as _OpenAIImagesStream,
)
from celeste.types import ImageContent

from ...client import ImagesClient
from ...io import (
Expand All @@ -35,7 +36,7 @@ class OpenAIImagesClient(OpenAIImagesMixin, ImagesClient):
"""OpenAI images client."""

@classmethod
def parameter_mappers(cls) -> list[ParameterMapper]:
def parameter_mappers(cls) -> list[ParameterMapper[ImageContent]]:
return OPENAI_PARAMETER_MAPPERS

def _init_request(self, inputs: ImageInput) -> dict[str, Any]:
Expand Down
Loading
Loading