Skip to content

Commit 72a1cf3

Browse files
fix(capabilities): add explicit usage and finish_reason types to Output classes (withceleste#100)
Override usage and finish_reason field types in capability Output classes to ensure proper Pydantic serialization. Without explicit type annotations, Pydantic uses the base Usage/FinishReason schema (empty) instead of the capability-specific subclass fields.
1 parent dfbc5fc commit 72a1cf3

File tree

8 files changed

+20
-7
lines changed

8 files changed

+20
-7
lines changed

packages/capabilities/image-generation/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "celeste-image-generation"
3-
version = "0.3.6"
3+
version = "0.3.7"
44
description = "Image generation package for Celeste AI. Unified interface for all providers"
55
authors = [{name = "Kamilbenkirane", email = "kamil@withceleste.ai"}]
66
readme = "README.md"

packages/capabilities/image-generation/src/celeste_image_generation/io.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Input and output types for image generation."""
22

3+
from pydantic import Field
4+
35
from celeste.artifacts import ImageArtifact
46
from celeste.io import Chunk, FinishReason, Input, Output, Usage
57

@@ -39,7 +41,8 @@ class ImageGenerationUsage(Usage):
3941
class ImageGenerationOutput(Output[ImageArtifact | list[ImageArtifact]]):
4042
"""Output with ImageArtifact content (single or multiple)."""
4143

42-
pass
44+
usage: ImageGenerationUsage = Field(default_factory=ImageGenerationUsage)
45+
finish_reason: ImageGenerationFinishReason | None = None
4346

4447

4548
class ImageGenerationChunk(Chunk[ImageArtifact]):

packages/capabilities/speech-generation/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "celeste-speech-generation"
3-
version = "0.3.6"
3+
version = "0.3.7"
44
description = "Speech generation package for Celeste AI. Unified interface for all providers"
55
authors = [{name = "Kamilbenkirane", email = "kamil@withceleste.ai"}]
66
readme = "README.md"

packages/capabilities/speech-generation/src/celeste_speech_generation/io.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Input and output types for speech generation."""
22

3+
from pydantic import Field
4+
35
from celeste.artifacts import AudioArtifact
46
from celeste.io import Chunk, FinishReason, Input, Output, Usage
57

@@ -24,6 +26,9 @@ class SpeechGenerationFinishReason(FinishReason):
2426
class SpeechGenerationOutput(Output[AudioArtifact]):
2527
"""Output with audio artifact content."""
2628

29+
usage: SpeechGenerationUsage = Field(default_factory=SpeechGenerationUsage)
30+
finish_reason: SpeechGenerationFinishReason | None = None
31+
2732

2833
class SpeechGenerationChunk(Chunk[bytes]):
2934
"""Typed chunk for speech generation streaming.

packages/capabilities/text-generation/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "celeste-text-generation"
3-
version = "0.3.6"
3+
version = "0.3.7"
44
description = "Text generation package for Celeste AI. Unified interface for all providers"
55
authors = [{name = "Kamilbenkirane", email = "kamil@withceleste.ai"}]
66
readme = "README.md"

packages/capabilities/text-generation/src/celeste_text_generation/io.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Input and output types for text generation."""
22

3+
from pydantic import Field
4+
35
from celeste.io import Chunk, FinishReason, Input, Output, Usage
46

57

@@ -35,7 +37,8 @@ class TextGenerationUsage(Usage):
3537
class TextGenerationOutput[Content](Output[Content]):
3638
"""Output with text or structured content."""
3739

38-
pass
40+
usage: TextGenerationUsage = Field(default_factory=TextGenerationUsage)
41+
finish_reason: TextGenerationFinishReason | None = None
3942

4043

4144
class TextGenerationChunk(Chunk[str]):

packages/capabilities/video-generation/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "celeste-video-generation"
3-
version = "0.3.6"
3+
version = "0.3.7"
44
description = "Video generation package for Celeste AI. Unified interface for all providers"
55
authors = [{name = "Kamilbenkirane", email = "kamil@withceleste.ai"}]
66
readme = "README.md"

packages/capabilities/video-generation/src/celeste_video_generation/io.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Input and output types for video generation."""
22

3+
from pydantic import Field
4+
35
from celeste.artifacts import VideoArtifact
46
from celeste.io import Input, Output, Usage
57

@@ -23,7 +25,7 @@ class VideoGenerationUsage(Usage):
2325
class VideoGenerationOutput(Output[VideoArtifact]):
2426
"""Output with VideoArtifact content."""
2527

26-
pass
28+
usage: VideoGenerationUsage = Field(default_factory=VideoGenerationUsage)
2729

2830

2931
__all__ = [

0 commit comments

Comments
 (0)