Skip to content

Commit 23922a6

Browse files
author
yiguang
committed
feat: support seedance and seedream param
1 parent f879748 commit 23922a6

4 files changed

Lines changed: 58 additions & 0 deletions

File tree

volcenginesdkarkruntime/resources/images/images.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
OptimizePromptOptions,
2525
SequentialImageGenerationOptions,
2626
ImagesResponse,
27+
ContentGenerationTool
2728
)
2829
from ...types.images.image_gen_stream_event import ImageGenStreamEvent
2930
from ..._types import Body, Query, Headers
@@ -53,6 +54,8 @@ def generate(
5354
sequential_image_generation: str | None = None,
5455
sequential_image_generation_options: SequentialImageGenerationOptions
5556
| None = None,
57+
tools: list[ContentGenerationTool] | None = None,
58+
output_format: str | None = None,
5659
stream: Optional[Literal[False]] | NotGiven = NOT_GIVEN,
5760
) -> ImagesResponse:
5861
...
@@ -86,6 +89,8 @@ def generate(
8689
sequential_image_generation: str | None = None,
8790
sequential_image_generation_options: SequentialImageGenerationOptions
8891
| None = None,
92+
tools: list[ContentGenerationTool] | None = None,
93+
output_format: str | None = None,
8994
stream: Literal[True],
9095
) -> Stream[ImageGenStreamEvent]: ...
9196

@@ -110,6 +115,8 @@ def generate(
110115
sequential_image_generation: str | None = None,
111116
sequential_image_generation_options: SequentialImageGenerationOptions
112117
| None = None,
118+
tools: list[ContentGenerationTool] | None = None,
119+
output_format: str | None = None,
113120
stream: bool,
114121
) -> ImagesResponse | Stream[ImageGenStreamEvent]: ...
115122

@@ -134,6 +141,8 @@ def generate(
134141
sequential_image_generation: str | None = None,
135142
sequential_image_generation_options: SequentialImageGenerationOptions
136143
| None = None,
144+
tools: list[ContentGenerationTool] | None = None,
145+
output_format: str | None = None,
137146
stream: Optional[Literal[False]] | Literal[True] | NotGiven = NOT_GIVEN,
138147
) -> ImagesResponse | Stream[ImageGenStreamEvent]:
139148
resp = self._post(
@@ -159,6 +168,12 @@ def generate(
159168
if sequential_image_generation_options is not None
160169
else None
161170
),
171+
"tools": (
172+
[t.model_dump(mode="json") for t in tools]
173+
if tools is not None
174+
else None
175+
),
176+
"output_format": output_format,
162177
"stream": stream,
163178
},
164179
options=make_request_options(
@@ -197,6 +212,8 @@ async def generate(
197212
sequential_image_generation: str | None = None,
198213
sequential_image_generation_options: SequentialImageGenerationOptions
199214
| None = None,
215+
tools: list[ContentGenerationTool] | None = None,
216+
output_format: str | None = None,
200217
stream: Optional[Literal[False]] | NotGiven = NOT_GIVEN,
201218
) -> ImagesResponse: ...
202219

@@ -221,6 +238,8 @@ async def generate(
221238
sequential_image_generation: str | None = None,
222239
sequential_image_generation_options: SequentialImageGenerationOptions
223240
| None = None,
241+
tools: list[ContentGenerationTool] | None = None,
242+
output_format: str | None = None,
224243
stream: Literal[True],
225244
) -> AsyncStream[ImageGenStreamEvent]: ...
226245

@@ -245,6 +264,8 @@ async def generate(
245264
sequential_image_generation: str | None = None,
246265
sequential_image_generation_options: SequentialImageGenerationOptions
247266
| None = None,
267+
tools: list[ContentGenerationTool] | None = None,
268+
output_format: str | None = None,
248269
stream: bool,
249270
) -> ImagesResponse | AsyncStream[ImageGenStreamEvent]: ...
250271

@@ -269,6 +290,8 @@ async def generate(
269290
sequential_image_generation: str | None = None,
270291
sequential_image_generation_options: SequentialImageGenerationOptions
271292
| None = None,
293+
tools: list[ContentGenerationTool] | None = None,
294+
output_format: str | None = None,
272295
stream: Optional[Literal[False]] | Literal[True] | NotGiven = NOT_GIVEN,
273296
) -> ImagesResponse | AsyncStream[ImageGenStreamEvent]:
274297
return await self._post(
@@ -294,6 +317,12 @@ async def generate(
294317
if sequential_image_generation_options is not None
295318
else None
296319
),
320+
"tools": (
321+
[t.model_dump(mode="json") for t in tools]
322+
if tools is not None
323+
else None
324+
),
325+
"output_format": output_format,
297326
"stream": stream,
298327
},
299328
options=make_request_options(

volcenginesdkarkruntime/types/images/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313
OptimizePromptOptions,
1414
SequentialImageGenerationOptions,
1515
ImagesResponse,
16+
ContentGenerationTool
1617
)
1718

1819

1920
__all__ = [
2021
"OptimizePromptOptions",
2122
"SequentialImageGenerationOptions",
2223
"ImagesResponse",
24+
"ContentGenerationTool"
2325
]

volcenginesdkarkruntime/types/images/image_gen_completed_event.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,25 @@
1010
# This modified file is released under the same license.
1111

1212

13+
from typing import List, Optional
1314
from volcenginesdkarkruntime._models import BaseModel
1415

1516
__all__ = ["ImageGenCompletedEvent"]
1617

1718

19+
class ToolUsage(BaseModel):
20+
web_search: Optional[int] = None
21+
"""The number of web search."""
22+
1823
class Usage(BaseModel):
1924
generated_images: int
2025
"""The number of images generated."""
2126
output_tokens: int
2227
"""The number of output tokens."""
2328
total_tokens: int
2429
"""The total number of tokens."""
30+
tool_usage: Optional[ToolUsage] = None
31+
"""The total number of images generated by this request."""
2532

2633

2734
class Error(BaseModel):

volcenginesdkarkruntime/types/images/images.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"OptimizePromptOptions",
1818
"SequentialImageGenerationOptions",
1919
"ImagesResponse",
20+
"ContentGenerationTool"
2021
]
2122

2223

@@ -30,9 +31,20 @@ class SequentialImageGenerationOptions(BaseModel):
3031
""" Maximum number of images to generate in this request; effective only when the multi-image feature is enabled """
3132

3233

34+
class ToolUsage(BaseModel):
35+
web_search: Optional[int] = None
36+
"""The number of web search."""
37+
38+
3339
class Usage(BaseModel):
3440
generated_images: int
3541
"""The number of images generated."""
42+
output_tokens: Optional[int] = None
43+
"""The number of images generated by this request."""
44+
total_tokens: Optional[int] = None
45+
"""The total number of images generated by this request."""
46+
tool_usage: Optional[ToolUsage] = None
47+
"""The total number of images generated by this request."""
3648

3749

3850
class Image(BaseModel):
@@ -54,6 +66,11 @@ class Error(BaseModel):
5466
"""The error code for failed image generation"""
5567

5668

69+
class ContentGenerationTool(BaseModel):
70+
type: str
71+
"""The content generation tool used to generate the images."""
72+
73+
5774
class ImagesResponse(BaseModel):
5875
model: str
5976
"""The model used to generated the images."""
@@ -69,3 +86,6 @@ class ImagesResponse(BaseModel):
6986

7087
created_at: int
7188
"""The Unix timestamp when the image was generated."""
89+
90+
tool: List[ContentGenerationTool]
91+
""" The tool used to generate the image."""

0 commit comments

Comments
 (0)