Skip to content

Commit aa2cd8a

Browse files
author
潘婉宁
committed
feat: support video url
1 parent 724385e commit aa2cd8a

File tree

9 files changed

+42
-22
lines changed

9 files changed

+42
-22
lines changed

volcenginesdkarkruntime/_utils/_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def removeprefix(string: str, prefix: str) -> str:
349349
Backport of `str.removeprefix` for Python < 3.9
350350
"""
351351
if string.startswith(prefix):
352-
return string[len(prefix):]
352+
return string[len(prefix) :]
353353
return string
354354

355355

volcenginesdkarkruntime/resources/batch_chat/completions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def _process_messages(
7171
)
7272
)
7373

74+
7475
def _calculate_retry_timeout(retry_times) -> float:
7576
nbRetries = min(retry_times, MAX_RETRY_DELAY / INITIAL_RETRY_DELAY)
7677
sleep_seconds = min(INITIAL_RETRY_DELAY * pow(2, nbRetries), MAX_RETRY_DELAY)
@@ -134,7 +135,6 @@ def _process_messages(
134135
)
135136
)
136137

137-
138138
def _encrypt(
139139
self,
140140
model: str,

volcenginesdkarkruntime/resources/images/images.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,19 @@ def generate(
5252
class AsyncImages(AsyncAPIResource):
5353
@async_apikey_required
5454
async def generate(
55-
self,
56-
*,
57-
model: str,
58-
prompt: str,
59-
response_format: str | None = None,
60-
size: str | None = None,
61-
seed: int | None = None,
62-
guidance_scale: float | None = None,
63-
watermark: bool | None = None,
64-
extra_headers: Headers | None = None,
65-
extra_query: Query | None = None,
66-
extra_body: Body | None = None,
67-
timeout: float | httpx.Timeout | None = None,
55+
self,
56+
*,
57+
model: str,
58+
prompt: str,
59+
response_format: str | None = None,
60+
size: str | None = None,
61+
seed: int | None = None,
62+
guidance_scale: float | None = None,
63+
watermark: bool | None = None,
64+
extra_headers: Headers | None = None,
65+
extra_query: Query | None = None,
66+
extra_body: Body | None = None,
67+
timeout: float | httpx.Timeout | None = None,
6868
) -> ImagesResponse:
6969
return await self._post(
7070
"/images/generations",

volcenginesdkarkruntime/types/bot_chat/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@
99
"BotChatCompletionChunk",
1010
"BotChatCompletion",
1111
]
12-

volcenginesdkarkruntime/types/chat/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
from .chat_completion_stream_options_param import (
2020
ChatCompletionStreamOptionsParam as ChatCompletionStreamOptionsParam,
2121
)
22-
from .chat_completion_stream_options_param import (
23-
ChatCompletionStreamOptionsParam as ChatCompletionStreamOptionsParam,
24-
)
2522
from .chat_completion_tool_param import (
2623
ChatCompletionToolParam as ChatCompletionToolParam,
2724
)

volcenginesdkarkruntime/types/chat/chat_completion_content_part_param.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@
66
from .chat_completion_content_part_image_param import (
77
ChatCompletionContentPartImageParam,
88
)
9+
from .chat_completion_content_part_video_param import (
10+
ChatCompletionContentPartVideoParam,
11+
)
912

1013
__all__ = ["ChatCompletionContentPartParam"]
1114

1215
ChatCompletionContentPartParam = Union[
13-
ChatCompletionContentPartTextParam, ChatCompletionContentPartImageParam
16+
ChatCompletionContentPartTextParam,
17+
ChatCompletionContentPartImageParam,
18+
ChatCompletionContentPartVideoParam,
1419
]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from __future__ import annotations
2+
3+
from typing_extensions import Literal, Required, TypedDict
4+
5+
__all__ = ["ChatCompletionContentPartVideoParam", "VideoURL"]
6+
7+
8+
class VideoURL(TypedDict, total=False):
9+
url: Required[str]
10+
"""Either a URL of the video or the base64 encoded video data."""
11+
12+
fps: float
13+
"""The sampling fps of the video."""
14+
15+
16+
class ChatCompletionContentPartVideoParam(TypedDict, total=False):
17+
video_url: Required[VideoURL]
18+
19+
type: Required[Literal["video_url"]]
20+
"""The type of the content part."""

volcenginesdkarkruntime/types/context/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@
1414
"TruncationStrategy",
1515
"TTLTypes",
1616
]
17-
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .images import ImagesResponse
1+
from .images import ImagesResponse

0 commit comments

Comments
 (0)