Skip to content

Commit fb94d8e

Browse files
author
lmh
committed
fix: preprocess configs
1 parent 8e95117 commit fb94d8e

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

volcenginesdkarkruntime/resources/files.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import httpx
1919

2020
from .. import _legacy_response
21-
from ..types import FilePurpose, file_list_params, file_create_params
21+
from ..types import FilePurpose, PreprocessConfigs, file_list_params, file_create_params
2222
from .._types import Body, Query, Headers, FileTypes
2323
from .._utils import (
2424
extract_files,
@@ -66,6 +66,7 @@ def create(
6666
file: FileTypes,
6767
purpose: FilePurpose,
6868
expires_at: datetime.datetime | int | None = None,
69+
preprocess_configs: PreprocessConfigs | None = None,
6970
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
7071
# The extra values given here take precedence over values defined on the client or passed to this method.
7172
extra_headers: Headers | None = None,
@@ -97,6 +98,7 @@ def create(
9798
"file": file,
9899
"purpose": purpose,
99100
"expires_at": expires_at,
101+
"preprocess_configs": preprocess_configs,
100102
}
101103
)
102104
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
@@ -304,6 +306,7 @@ async def create(
304306
file: FileTypes,
305307
purpose: FilePurpose,
306308
expire_at: int | None = None,
309+
preprocess_configs: PreprocessConfigs | None = None,
307310
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
308311
# The extra values given here take precedence over values defined on the client or passed to this method.
309312
extra_headers: Headers | None = None,
@@ -335,6 +338,7 @@ async def create(
335338
"file": file,
336339
"purpose": purpose,
337340
"expire_at": expire_at,
341+
"preprocess_configs": preprocess_configs,
338342
}
339343
)
340344
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])

volcenginesdkarkruntime/resources/responses/responses.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
RESPONSES_MULTIMODAL_CONTENT_DATA_KEYS = {
5454
"input_image": "image_url",
5555
"input_video": "video_url",
56-
"input_file": "file_data",
56+
"input_file": "file_url",
5757
}
5858

5959
FILE_PATH_SCHEME = "file"
@@ -367,7 +367,9 @@ async def _prepare_responses_input_file(self, content: ResponseInputContentParam
367367
file = await self._client.files.create(file=file_path, purpose="user_data")
368368
file = await self._client.files.wait_for_processing(id=file.id)
369369
if file.status != "active":
370-
raise ArkAPIError(f"File path: {full_path},id: {file.id} processing failed with status {file.status}.")
370+
raise ArkAPIError(
371+
f"File path: {full_path},id: {file.id} processing failed with status {file.status}."
372+
)
371373

372374
# replace with file id
373375
content[content_data_key] = None

volcenginesdkarkruntime/types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@
2525
)
2626
from .file_purpose import FilePurpose as FilePurpose
2727
from .file_list_params import FileListParams as FileListParams
28+
from .file_create_params import PreprocessConfigs as PreprocessConfigs

volcenginesdkarkruntime/types/file_create_params.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from .._types import FileTypes
1717
from .file_purpose import FilePurpose
1818

19-
__all__ = ["FileCreateParams"]
19+
__all__ = ["FileCreateParams", "PreprocessConfigs"]
2020

2121

2222
class FileCreateParams(TypedDict, total=False):
@@ -31,6 +31,9 @@ class FileCreateParams(TypedDict, total=False):
3131
"""The expiration timestamp for the file.
3232
"""
3333

34+
preprocess_configs: Optional[PreprocessConfigs]
35+
"""The preprocess configs of the file."""
36+
3437

3538
class Video(TypedDict, total=False):
3639
"""The video configs of the file."""

volcenginesdkexamples/volcenginesdkarkruntime/async_responses_video.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ async def main():
1212
file = await client.files.create(
1313
# replace with your local video path
1414
file=open("ark_vlm_video_input.mp4", "rb"),
15-
purpose="user_data"
15+
purpose="user_data",
16+
preprocess_configs={
17+
"video": {
18+
"fps": 0.3, # define the sampling fps of the video, default is 1.0
19+
}
20+
}
1621
)
1722
print(f"File uploaded: {file.id}")
1823

0 commit comments

Comments
 (0)