Skip to content

Commit ae95510

Browse files
author
BitsAdmin
committed
Merge branch 'feat/gen_from_reasoning' into 'integration_2025-10-30_1074886721538'
feat: [development task] ark runtime (1783638) See merge request iaasng/volcengine-python-sdk!892
2 parents 8489d5e + 4b4bdb3 commit ae95510

File tree

71 files changed

+1657
-313
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1657
-313
lines changed

volcenginesdkarkruntime/resources/encryption.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import json
1111
import warnings
1212
from copy import deepcopy
13+
from urllib.parse import urlparse
1314
from typing import (
1415
Union,
1516
Iterable,
@@ -187,14 +188,21 @@ def _process_messages(
187188
if part.get("type", None) == "text":
188189
part["text"] = f(part["text"])
189190
elif part.get("type", None) == "image_url":
190-
if part["image_url"]["url"].startswith("data:"):
191+
parse_result = urlparse(part["image_url"]["url"])
192+
if parse_result.scheme == 'data':
191193
part["image_url"]["url"] = f(
192194
part["image_url"]["url"])
193-
else:
195+
elif parse_result.scheme == 'http' or parse_result.scheme == 'https':
194196
warnings.warn(
195197
"encryption is not supported for image url, "
196198
"please use base64 image if you want encryption"
197199
)
200+
else:
201+
raise TypeError(
202+
"encryption is not supported for image url scheme {}".format(
203+
parse_result
204+
)
205+
)
198206
else:
199207
raise TypeError(
200208
"encryption is not supported for content type {}".format(

volcenginesdkarkruntime/resources/responses/responses.py

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Copyright (c) [2025] [OpenAI]
32
# Copyright (c) [2025] [ByteDance Ltd. and/or its affiliates.]
43
# SPDX-License-Identifier: Apache-2.0
@@ -41,12 +40,15 @@
4140
from ...types.responses.response_stream_event import ResponseStreamEvent
4241
from ...types.responses.response_text_config_param import ResponseTextConfigParam
4342
from ...types.responses.response_caching_param import ResponseCaching
43+
from ...types.shared_params import Reasoning
4444
from volcenginesdkarkruntime.types.shared_params.thinking import Thinking
4545

4646
__all__ = ["Responses", "AsyncResponses"]
4747

4848

49-
def _add_beta_headers(extra_headers: Headers | None = None, tools: Iterable[ToolParam] | None = ()) -> Headers:
49+
def _add_beta_headers(
50+
extra_headers: Headers | None = None, tools: Iterable[ToolParam] | None = ()
51+
) -> Headers:
5052
if tools is None:
5153
return extra_headers
5254
for tool_param in tools:
@@ -95,6 +97,7 @@ def create(
9597
extra_query: Query | None = None,
9698
extra_body: Body | None = None,
9799
timeout: float | httpx.Timeout | None | None = None,
100+
reasoning: Optional[Reasoning] | None = None,
98101
) -> Response | Stream[ResponseStreamEvent]:
99102
extra_headers = _add_beta_headers(extra_headers, tools)
100103
resp = self._post(
@@ -117,6 +120,7 @@ def create(
117120
"top_p": top_p,
118121
"max_tool_calls": max_tool_calls,
119122
"expire_at": expire_at,
123+
"reasoning": reasoning,
120124
},
121125
options=make_request_options(
122126
extra_headers=extra_headers,
@@ -134,14 +138,15 @@ def retrieve(
134138
self,
135139
response_id: str,
136140
*,
137-
138141
extra_headers: Headers | None = None,
139142
extra_query: Query | None = None,
140143
extra_body: Body | None = None,
141144
timeout: float | httpx.Timeout | None = None,
142145
) -> Response:
143146
if not response_id:
144-
raise ValueError(f"Expected a non-empty value for `response_id` but received {response_id!r}")
147+
raise ValueError(
148+
f"Expected a non-empty value for `response_id` but received {response_id!r}"
149+
)
145150
return self._get(
146151
f"/responses/{response_id}",
147152
options=make_request_options(
@@ -165,12 +170,17 @@ def delete(
165170
timeout: float | httpx.Timeout | None = None,
166171
) -> None:
167172
if not response_id:
168-
raise ValueError(f"Expected a non-empty value for `response_id` but received {response_id!r}")
173+
raise ValueError(
174+
f"Expected a non-empty value for `response_id` but received {response_id!r}"
175+
)
169176
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
170177
return self._delete(
171178
f"/responses/{response_id}",
172179
options=make_request_options(
173-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
180+
extra_headers=extra_headers,
181+
extra_query=extra_query,
182+
extra_body=extra_body,
183+
timeout=timeout,
174184
),
175185
cast_to=type(None),
176186
)
@@ -210,6 +220,7 @@ async def create(
210220
extra_query: Query | None = None,
211221
extra_body: Body | None = None,
212222
timeout: float | httpx.Timeout | None | None = None,
223+
reasoning: Optional[Reasoning] | None = None,
213224
) -> Response | AsyncStream[ResponseStreamEvent]:
214225
extra_headers = _add_beta_headers(extra_headers, tools)
215226
resp = await self._post(
@@ -232,6 +243,7 @@ async def create(
232243
"top_p": top_p,
233244
"max_tool_calls": max_tool_calls,
234245
"expire_at": expire_at,
246+
"reasoning": reasoning,
235247
},
236248
options=make_request_options(
237249
extra_headers=extra_headers,
@@ -247,17 +259,18 @@ async def create(
247259
return resp
248260

249261
async def retrieve(
250-
self,
251-
response_id: str,
252-
*,
253-
254-
extra_headers: Headers | None = None,
255-
extra_query: Query | None = None,
256-
extra_body: Body | None = None,
257-
timeout: float | httpx.Timeout | None = None,
262+
self,
263+
response_id: str,
264+
*,
265+
extra_headers: Headers | None = None,
266+
extra_query: Query | None = None,
267+
extra_body: Body | None = None,
268+
timeout: float | httpx.Timeout | None = None,
258269
) -> Response:
259270
if not response_id:
260-
raise ValueError(f"Expected a non-empty value for `response_id` but received {response_id!r}")
271+
raise ValueError(
272+
f"Expected a non-empty value for `response_id` but received {response_id!r}"
273+
)
261274
return await self._get(
262275
f"/responses/{response_id}",
263276
options=make_request_options(
@@ -272,21 +285,26 @@ async def retrieve(
272285
)
273286

274287
async def delete(
275-
self,
276-
response_id: str,
277-
*,
278-
extra_headers: Headers | None = None,
279-
extra_query: Query | None = None,
280-
extra_body: Body | None = None,
281-
timeout: float | httpx.Timeout | None = None,
288+
self,
289+
response_id: str,
290+
*,
291+
extra_headers: Headers | None = None,
292+
extra_query: Query | None = None,
293+
extra_body: Body | None = None,
294+
timeout: float | httpx.Timeout | None = None,
282295
) -> None:
283296
if not response_id:
284-
raise ValueError(f"Expected a non-empty value for `response_id` but received {response_id!r}")
297+
raise ValueError(
298+
f"Expected a non-empty value for `response_id` but received {response_id!r}"
299+
)
285300
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
286301
return await self._delete(
287302
f"/responses/{response_id}",
288303
options=make_request_options(
289-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
304+
extra_headers=extra_headers,
305+
extra_query=extra_query,
306+
extra_body=extra_body,
307+
timeout=timeout,
290308
),
291309
cast_to=type(None),
292310
)

volcenginesdkarkruntime/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
ResponseFormatText as ResponseFormatText,
1717
ResponseFormatJSONObject as ResponseFormatJSONObject,
1818
ResponseFormatJSONSchema as ResponseFormatJSONSchema,
19+
Reasoning as Reasoning,
20+
ReasoningEffort as ReasoningEffort,
1921
)
2022
from .embedding import Embedding as Embedding
2123
from .completion_usage import CompletionUsage as CompletionUsage
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright (c) [2025] [OpenAI]
2+
# Copyright (c) [2025] [ByteDance Ltd. and/or its affiliates.]
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
# This file has been modified by [ByteDance Ltd. and/or its affiliates.] on 2025.7
6+
#
7+
# Original file was released under Apache License Version 2.0, with the full license text
8+
# available at https://github.com/openai/openai-python/blob/main/LICENSE.
9+
#
10+
# This modified file is released under the same license.
11+
12+
from __future__ import annotations
13+
14+
from typing import Optional
15+
16+
from typing_extensions import Literal
17+
18+
from ..._models import BaseModel
19+
20+
__all__ = ["AudioChunkingStrategy"]
21+
22+
23+
class AudioChunkingStrategy(BaseModel):
24+
type: Literal["server_vad"]
25+
26+
prefix_padding_ms: Optional[int] = None
27+
28+
silence_duration_ms: Optional[int] = None
29+
30+
threshold: Optional[float] = None
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) [2025] [OpenAI]
2+
# Copyright (c) [2025] [ByteDance Ltd. and/or its affiliates.]
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
# This file has been modified by [ByteDance Ltd. and/or its affiliates.] on 2025.7
6+
#
7+
# Original file was released under Apache License Version 2.0, with the full license text
8+
# available at https://github.com/openai/openai-python/blob/main/LICENSE.
9+
#
10+
# This modified file is released under the same license.
11+
12+
from __future__ import annotations
13+
14+
from typing import Optional
15+
16+
from typing_extensions import Literal, Required, TypedDict
17+
18+
__all__ = ["AudioChunkingStrategyParam"]
19+
20+
21+
class AudioChunkingStrategyParam(TypedDict, total=False):
22+
type: Required[Literal["server_vad"]]
23+
24+
prefix_padding_ms: Optional[int]
25+
26+
silence_duration_ms: Optional[int]
27+
28+
threshold: Optional[float]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (c) [2025] [OpenAI]
2+
# Copyright (c) [2025] [ByteDance Ltd. and/or its affiliates.]
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
# This file has been modified by [ByteDance Ltd. and/or its affiliates.] on 2025.7
6+
#
7+
# Original file was released under Apache License Version 2.0, with the full license text
8+
# available at https://github.com/openai/openai-python/blob/main/LICENSE.
9+
#
10+
# This modified file is released under the same license.
11+
12+
from __future__ import annotations
13+
14+
from typing import Optional
15+
16+
from ..._models import BaseModel
17+
18+
__all__ = ["ImageProcessGroundingOptions"]
19+
20+
21+
class ImageProcessGroundingOptions(BaseModel):
22+
type: Optional[str] = None
23+
"""`disabled` or `enabled`."""
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (c) [2025] [OpenAI]
2+
# Copyright (c) [2025] [ByteDance Ltd. and/or its affiliates.]
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
# This file has been modified by [ByteDance Ltd. and/or its affiliates.] on 2025.7
6+
#
7+
# Original file was released under Apache License Version 2.0, with the full license text
8+
# available at https://github.com/openai/openai-python/blob/main/LICENSE.
9+
#
10+
# This modified file is released under the same license.
11+
12+
from __future__ import annotations
13+
14+
from typing import Optional
15+
16+
from typing_extensions import TypedDict
17+
18+
__all__ = ["ImageProcessGroundingOptionsParam"]
19+
20+
21+
class ImageProcessGroundingOptionsParam(TypedDict, total=False):
22+
type: Optional[str]
23+
"""`disabled` or `enabled`."""
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (c) [2025] [OpenAI]
2+
# Copyright (c) [2025] [ByteDance Ltd. and/or its affiliates.]
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
# This file has been modified by [ByteDance Ltd. and/or its affiliates.] on 2025.7
6+
#
7+
# Original file was released under Apache License Version 2.0, with the full license text
8+
# available at https://github.com/openai/openai-python/blob/main/LICENSE.
9+
#
10+
# This modified file is released under the same license.
11+
12+
from __future__ import annotations
13+
14+
from typing import Optional
15+
16+
from ..._models import BaseModel
17+
18+
__all__ = ["ImageProcessPointOptions"]
19+
20+
21+
class ImageProcessPointOptions(BaseModel):
22+
type: Optional[str] = None
23+
"""`disabled` or `enabled`."""
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (c) [2025] [OpenAI]
2+
# Copyright (c) [2025] [ByteDance Ltd. and/or its affiliates.]
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
# This file has been modified by [ByteDance Ltd. and/or its affiliates.] on 2025.7
6+
#
7+
# Original file was released under Apache License Version 2.0, with the full license text
8+
# available at https://github.com/openai/openai-python/blob/main/LICENSE.
9+
#
10+
# This modified file is released under the same license.
11+
12+
from __future__ import annotations
13+
14+
from typing import Optional
15+
16+
from typing_extensions import TypedDict
17+
18+
__all__ = ["ImageProcessPointOptionsParam"]
19+
20+
21+
class ImageProcessPointOptionsParam(TypedDict, total=False):
22+
type: Optional[str]
23+
"""`disabled` or `enabled`."""
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (c) [2025] [OpenAI]
2+
# Copyright (c) [2025] [ByteDance Ltd. and/or its affiliates.]
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
# This file has been modified by [ByteDance Ltd. and/or its affiliates.] on 2025.7
6+
#
7+
# Original file was released under Apache License Version 2.0, with the full license text
8+
# available at https://github.com/openai/openai-python/blob/main/LICENSE.
9+
#
10+
# This modified file is released under the same license.
11+
12+
from __future__ import annotations
13+
14+
from typing import Optional
15+
16+
from ..._models import BaseModel
17+
18+
__all__ = ["ImageProcessRotateOptions"]
19+
20+
21+
class ImageProcessRotateOptions(BaseModel):
22+
type: Optional[str] = None
23+
"""`disabled` or `enabled`."""

0 commit comments

Comments
 (0)