Skip to content

Commit b02c120

Browse files
author
hks
committed
feat: support reasoning effort
1 parent 088b67f commit b02c120

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

volcenginesdkarkruntime/resources/beta/chat/completions.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
from ....types.chat.chat_completion_tool_choice_option_param import (
5757
ChatCompletionToolChoiceOptionParam,
5858
)
59+
from ....types.shared.reasoning_effort import ReasoningEffort
60+
5961

6062
__all__ = ["Completions", "AsyncCompletions"]
6163

@@ -100,6 +102,7 @@ def parse(
100102
top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
101103
top_p: Optional[float] | NotGiven = NOT_GIVEN,
102104
user: str | NotGiven = NOT_GIVEN,
105+
reasoning_effort: Optional[ReasoningEffort] | NotGiven = NOT_GIVEN,
103106
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
104107
# The extra values given here take precedence over values defined on the client or passed to this method.
105108
extra_headers: Headers | None = None,
@@ -147,6 +150,7 @@ def parser(
147150
"top_logprobs": top_logprobs,
148151
"top_p": top_p,
149152
"user": user,
153+
"reasoning_effort": reasoning_effort,
150154
},
151155
completion_create_params.CompletionCreateParams,
152156
),
@@ -188,6 +192,7 @@ def stream(
188192
top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
189193
top_p: Optional[float] | NotGiven = NOT_GIVEN,
190194
user: str | NotGiven = NOT_GIVEN,
195+
reasoning_effort: Optional[ReasoningEffort] | NotGiven = NOT_GIVEN,
191196
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
192197
# The extra values given here take precedence over values defined on the client or passed to this method.
193198
extra_headers: Headers | None = None,
@@ -202,6 +207,7 @@ def stream(
202207

203208
api_request: partial[Stream[ChatCompletionChunk]] = partial(
204209
self._client.chat.completions.create,
210+
reasoning_effort=reasoning_effort,
205211
messages=messages,
206212
model=model,
207213
stream=True,
@@ -274,6 +280,7 @@ async def parse(
274280
top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
275281
top_p: Optional[float] | NotGiven = NOT_GIVEN,
276282
user: str | NotGiven = NOT_GIVEN,
283+
reasoning_effort: Optional[ReasoningEffort] | NotGiven = NOT_GIVEN,
277284
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
278285
# The extra values given here take precedence over values defined on the client or passed to this method.
279286
extra_headers: Headers | None = None,
@@ -321,6 +328,7 @@ def parser(
321328
"top_logprobs": top_logprobs,
322329
"top_p": top_p,
323330
"user": user,
331+
"reasoning_effort": reasoning_effort,
324332
},
325333
completion_create_params.CompletionCreateParams,
326334
),
@@ -362,6 +370,7 @@ def stream(
362370
top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
363371
top_p: Optional[float] | NotGiven = NOT_GIVEN,
364372
user: str | NotGiven = NOT_GIVEN,
373+
reasoning_effort: Optional[ReasoningEffort] | NotGiven = NOT_GIVEN,
365374
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
366375
# The extra values given here take precedence over values defined on the client or passed to this method.
367376
extra_headers: Headers | None = None,
@@ -397,6 +406,7 @@ def stream(
397406
top_logprobs=top_logprobs,
398407
top_p=top_p,
399408
user=user,
409+
reasoning_effort=reasoning_effort,
400410
extra_headers=extra_headers,
401411
extra_query=extra_query,
402412
extra_body=extra_body,

volcenginesdkarkruntime/resources/chat/completions.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from ..._base_client import make_request_options
3636
from ..._resource import SyncAPIResource, AsyncAPIResource
3737
from ..._compat import cached_property
38-
38+
from ...types.shared.reasoning_effort import ReasoningEffort
3939
from ..._response import (
4040
to_raw_response_wrapper,
4141
async_to_raw_response_wrapper,
@@ -191,6 +191,7 @@ def create(
191191
response_format: completion_create_params.ResponseFormat | None = None,
192192
thinking: completion_create_params.Thinking | None = None,
193193
max_completion_tokens: Optional[int] | None = None,
194+
reasoning_effort: Optional[ReasoningEffort] | None = None,
194195
user: str | None = None,
195196
extra_headers: Headers | None = None,
196197
extra_query: Query | None = None,
@@ -214,6 +215,7 @@ def create(
214215
}
215216
extra_headers["X-Encrypt-Info"] = json.dumps(info)
216217

218+
217219
resp = self._post(
218220
"/chat/completions",
219221
body={
@@ -241,6 +243,7 @@ def create(
241243
"response_format": response_format,
242244
"thinking": thinking,
243245
"max_completion_tokens": max_completion_tokens,
246+
"reasoning_effort": reasoning_effort,
244247
},
245248
options=make_request_options(
246249
extra_headers=extra_headers,
@@ -252,7 +255,6 @@ def create(
252255
stream=stream or False,
253256
stream_cls=Stream[ChatCompletionChunk],
254257
)
255-
256258
if is_encrypt:
257259
resp = self._decrypt(e2e_key, e2e_nonce, resp)
258260
return resp
@@ -358,6 +360,7 @@ async def create(
358360
response_format: completion_create_params.ResponseFormat | None = None,
359361
thinking: completion_create_params.Thinking | None = None,
360362
max_completion_tokens: Optional[int] | None = None,
363+
reasoning_effort: Optional[ReasoningEffort] | None = None,
361364
extra_headers: Headers | None = None,
362365
extra_query: Query | None = None,
363366
extra_body: Body | None = None,
@@ -407,6 +410,7 @@ async def create(
407410
"response_format": response_format,
408411
"thinking": thinking,
409412
"max_completion_tokens": max_completion_tokens,
413+
"reasoning_effort": reasoning_effort,
410414
},
411415
options=make_request_options(
412416
extra_headers=extra_headers,
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
# Copyright (c) [2025] [OpenAI]
3+
# Copyright (c) [2025] [ByteDance Ltd. and/or its affiliates.]
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# This file has been modified by [ByteDance Ltd. and/or its affiliates.] on 2025.7
7+
#
8+
# Original file was released under Apache License Version 2.0, with the full license text
9+
# available at https://github.com/openai/openai-python/blob/main/LICENSE.
10+
#
11+
# This modified file is released under the same license.
12+
from typing import Optional
13+
from typing_extensions import Literal, TypeAlias
14+
15+
__all__ = ["ReasoningEffort"]
16+
17+
ReasoningEffort: TypeAlias = Optional[Literal["minimal", "low", "medium", "high"]]

0 commit comments

Comments
 (0)