-
Notifications
You must be signed in to change notification settings - Fork 381
Expand file tree
/
Copy pathbase_dto.py
More file actions
275 lines (237 loc) · 8.93 KB
/
Copy pathbase_dto.py
File metadata and controls
275 lines (237 loc) · 8.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Base Data Transfer Object classes."""
from enum import Enum
from pydantic import BaseModel, ConfigDict
from pydantic.alias_generators import to_camel
class MimeTypeEnum(str, Enum):
"""MIME type for the media."""
IMAGE_JPEG = "image/jpeg"
IMAGE_PNG = "image/png"
IMAGE_WEBP = "image/webp"
IMAGE_HEIC = "image/heic"
IMAGE_HEIF = "image/heif"
IMAGE_AVIF = "image/avif"
VIDEO_MP4 = "video/mp4"
AUDIO_WAV = "audio/wav"
AUDIO_MPEG = "audio/mpeg"
AUDIO_MP3 = "audio/mp3"
AUDIO_OGG = "audio/ogg"
AUDIO_WEBM = "audio/webm"
class WildcardMimeTypeEnum(str, Enum):
"""Wildcard MIME types for search filtering."""
IMAGE_WILDCARD = "image/*"
VIDEO_WILDCARD = "video/*"
AUDIO_WILDCARD = "audio/*"
class GenerationModelEnum(str, Enum):
"""Enum representing the available generation models."""
# Image-Specific Models
IMAGEN_4_UPSCALE_PREVIEW = "imagen-4.0-upscale-preview"
GEMINI_2_5_PRO = "gemini-2.5-pro"
GEMINI_2_5_FLASH = "gemini-2.5-flash"
GEMINI_3_5_FLASH = "gemini-3.5-flash"
GEMINI_1_5_FLASH = "gemini-1.5-flash"
GEMINI_2_5_FLASH_IMAGE_PREVIEW = "gemini-2.5-flash-image-preview"
GEMINI_2_5_FLASH_IMAGE = "gemini-2.5-flash-image"
GEMINI_3_PRO_PREVIEW = "gemini-3-pro-preview"
GEMINI_3_PRO_IMAGE = "gemini-3-pro-image"
GEMINI_3_1_FLASH_IMAGE = "gemini-3.1-flash-image"
GEMINI_3_1_FLASH_LITE_IMAGE = "gemini-3.1-flash-lite-image"
GEMINI_3_FLASH_PREVIEW = "gemini-3-flash-preview"
VTO = "virtual-try-on-001"
# Video-Specific Models
GEMINI_OMNI = "gemini-omni-generate-preview"
GEMINI_OMNI_FLASH_PREVIEW = "gemini-omni-flash-preview"
VEO_3_1_FAST_GENERATE_001 = "veo-3.1-fast-generate-001"
VEO_3_1_LITE_GENERATE_001 = "veo-3.1-lite-generate-001"
VEO_3_1_GENERATE_001 = "veo-3.1-generate-001"
VEO_3_1_PREVIEW = "veo-3.1-generate-preview"
VEO_3_FAST = "veo-3.0-fast-generate-001"
VEO_3_QUALITY = "veo-3.0-generate-001"
VEO_3_FAST_PREVIEW = "veo-3.0-fast-generate-preview"
VEO_3_QUALITY_PREVIEW = "veo-3.0-generate-preview"
# Audio-Specific Models
LYRIA_002 = "lyria-002"
LYRIA_3_CLIP_PREVIEW = "lyria-3-clip-preview"
CHIRP_3 = "chirp_3"
GEMINI_2_5_FLASH_TTS = "gemini-2.5-flash-tts"
GEMINI_2_5_FLASH_LITE_PREVIEW_TTS = "gemini-2.5-flash-lite-preview-tts"
GEMINI_2_5_PRO_TTS = "gemini-2.5-pro-tts"
GEMINI_3_1_FLASH_TTS_PREVIEW = "gemini-3.1-flash-tts-preview"
# Workbench Models
WORKBENCH_RENDER = "workbench-render"
# Deprecated models (For old generations only, do not use)
_DEPRECATED_VTO = "virtual-try-on-preview-08-04"
GEMINI_3_PRO_IMAGE_PREVIEW = "gemini-3-pro-image-preview"
GEMINI_3_1_FLASH_IMAGE_PREVIEW = "gemini-3.1-flash-image-preview"
IMAGEN_4_001 = "imagen-4.0-generate-001"
IMAGEN_4_ULTRA = "imagen-4.0-ultra-generate-001"
IMAGEN_4_ULTRA_PREVIEW = "imagen-4.0-ultra-generate-preview-06-06"
IMAGEN_4_FAST = "imagen-4.0-fast-generate-001"
IMAGEN_4_FAST_PREVIEW = "imagen-4.0-fast-generate-preview-06-06"
IMAGEN_3_001 = "imagen-3.0-generate-001"
IMAGEN_3_FAST = "imagen-3.0-fast-generate-001"
IMAGEN_3_002 = "imagen-3.0-generate-002"
IMAGEGEN_006 = "imagegeneration@006"
IMAGEGEN_005 = "imagegeneration@005"
IMAGEGEN_002 = "imagegeneration@002"
VEO_2_FAST = "veo-2.0-generate-001"
VEO_2_QUALITY = "veo-2.0-fast-generate-001"
VEO_2_GENERATE_EXP = "veo-2.0-generate-exp"
@property
def is_gemini_image_model(self) -> bool:
"""Returns True if the model is a Gemini image generation model."""
return self in [
GenerationModelEnum.GEMINI_2_5_FLASH_IMAGE_PREVIEW,
GenerationModelEnum.GEMINI_2_5_FLASH_IMAGE,
GenerationModelEnum.GEMINI_3_PRO_IMAGE_PREVIEW,
GenerationModelEnum.GEMINI_3_PRO_IMAGE,
GenerationModelEnum.GEMINI_3_1_FLASH_IMAGE_PREVIEW,
GenerationModelEnum.GEMINI_3_1_FLASH_IMAGE,
GenerationModelEnum.GEMINI_3_1_FLASH_LITE_IMAGE,
]
@property
def valid_aspect_ratios(self) -> list["AspectRatioEnum"]:
"""Returns the valid aspect ratios for the model."""
if self in [
GenerationModelEnum.GEMINI_3_1_FLASH_IMAGE_PREVIEW,
GenerationModelEnum.GEMINI_3_1_FLASH_IMAGE,
GenerationModelEnum.GEMINI_3_1_FLASH_LITE_IMAGE,
]:
return [
AspectRatioEnum.RATIO_1_1,
AspectRatioEnum.RATIO_3_4,
AspectRatioEnum.RATIO_4_3,
AspectRatioEnum.RATIO_2_3,
AspectRatioEnum.RATIO_3_2,
AspectRatioEnum.RATIO_4_5,
AspectRatioEnum.RATIO_5_4,
AspectRatioEnum.RATIO_9_16,
AspectRatioEnum.RATIO_16_9,
AspectRatioEnum.RATIO_21_9,
AspectRatioEnum.RATIO_1_4,
AspectRatioEnum.RATIO_4_1,
AspectRatioEnum.RATIO_1_8,
AspectRatioEnum.RATIO_8_1,
]
if self.is_gemini_image_model:
return [
AspectRatioEnum.RATIO_1_1,
AspectRatioEnum.RATIO_3_4,
AspectRatioEnum.RATIO_4_3,
AspectRatioEnum.RATIO_2_3,
AspectRatioEnum.RATIO_3_2,
AspectRatioEnum.RATIO_4_5,
AspectRatioEnum.RATIO_5_4,
AspectRatioEnum.RATIO_9_16,
AspectRatioEnum.RATIO_16_9,
AspectRatioEnum.RATIO_21_9,
]
return [
AspectRatioEnum.RATIO_1_1,
AspectRatioEnum.RATIO_3_4,
AspectRatioEnum.RATIO_4_3,
AspectRatioEnum.RATIO_9_16,
AspectRatioEnum.RATIO_16_9,
]
@property
def max_total_inputs(self) -> int:
"""Returns the maximum number of total inputs allowed for the model."""
if self in [
GenerationModelEnum.GEMINI_3_PRO_IMAGE_PREVIEW,
GenerationModelEnum.GEMINI_3_PRO_IMAGE,
GenerationModelEnum.GEMINI_3_1_FLASH_IMAGE_PREVIEW,
GenerationModelEnum.GEMINI_3_1_FLASH_IMAGE,
GenerationModelEnum.GEMINI_3_1_FLASH_LITE_IMAGE,
]:
return 14
if self.is_gemini_image_model:
return 2
return 1
class AspectRatioEnum(str, Enum):
"""Enum representing the supported aspect ratios."""
# Common Ratios
RATIO_9_16 = "9:16"
RATIO_16_9 = "16:9"
# Image-Specific Ratios
RATIO_1_1 = "1:1"
RATIO_3_4 = "3:4"
RATIO_4_3 = "4:3"
RATIO_2_3 = "2:3"
RATIO_3_2 = "3:2"
RATIO_4_5 = "4:5"
RATIO_5_4 = "5:4"
RATIO_21_9 = "21:9"
RATIO_1_4 = "1:4"
RATIO_4_1 = "4:1"
RATIO_1_8 = "1:8"
RATIO_8_1 = "8:1"
OTHER = "other"
class StyleEnum(str, Enum):
"""Enum representing the supported image styles."""
MODERN = "Modern"
REALISTIC = "Realistic"
VINTAGE = "Vintage"
MONOCHROME = "Monochrome"
FANTASY = "Fantasy"
SKETCH = "Sketch"
PHOTOREALISTIC = "Photorealistic"
CINEMATIC = "Cinematic"
class ColorAndToneEnum(str, Enum):
"""Enum for color and tone styles."""
BLACK_AND_WHITE = "Black & White"
GOLDEN = "Golden"
MONOCHROMATIC = "Monochromatic"
MUTED = "Muted"
PASTEL = "Pastel"
TONED = "Toned"
VIBRANT = "Vibrant"
WARM = "Warm"
COOL = "Cool"
MONOCHROME = "Monochrome"
class LightingEnum(str, Enum):
"""Enum for lighting styles."""
BACKLIGHTING = "Backlighting"
DRAMATIC_LIGHT = "Dramatic Light"
GOLDEN_HOUR = "Golden Hour"
EXPOSURE = "Exposure"
LOW_LIGHTING = "Low Lighting"
MULTIEXPOSURE = "Multiexposure"
STUDIO_LIGHT = "Studio Light"
CINEMATIC = "Cinematic"
STUDIO = "Studio"
NATURAL = "Natural"
DRAMATIC = "Dramatic"
AMBIENT = "Ambient"
class CompositionEnum(str, Enum):
"""Enum for image composition styles."""
CLOSEUP = "Closeup"
KNOLLING = "Knolling"
LANDSCAPE_PHOTOGRAPHY = "Landscape photography"
THROUGH_WINDOW = "Photographed through window"
SHALLOW_DEPTH_OF_FIELD = "Shallow depth of field"
SHOT_FROM_ABOVE = "Shot from above"
SHOT_FROM_BELOW = "Shot from below"
SURFACE_DETAIL = "Surface detail"
WIDE_ANGLE = "Wide angle"
class ReferenceImageTypeEnum(str, Enum):
ASSET = "ASSET"
STYLE = "STYLE"
class BaseDto(BaseModel):
model_config = ConfigDict(
alias_generator=to_camel,
extra="forbid",
populate_by_name=True,
from_attributes=True,
)