File tree 3 files changed +12
-0
lines changed
3 files changed +12
-0
lines changed Original file line number Diff line number Diff line change 3
3
from dataclasses import dataclass , fields , replace
4
4
from typing import Literal
5
5
6
+ from openai .types .shared import Reasoning
7
+
6
8
7
9
@dataclass
8
10
class ModelSettings :
@@ -40,6 +42,11 @@ class ModelSettings:
40
42
max_tokens : int | None = None
41
43
"""The maximum number of output tokens to generate."""
42
44
45
+ reasoning : Reasoning | None = None
46
+ """Configuration options for
47
+ [reasoning models](https://platform.openai.com/docs/guides/reasoning).
48
+ """
49
+
43
50
metadata : dict [str , str ] | None = None
44
51
"""Metadata to include with the model response call."""
45
52
Original file line number Diff line number Diff line change @@ -521,6 +521,8 @@ async def _fetch_response(
521
521
# Match the behavior of Responses where store is True when not given
522
522
store = model_settings .store if model_settings .store is not None else True
523
523
524
+ reasoning_effort = model_settings .reasoning .effort if model_settings .reasoning else None
525
+
524
526
ret = await self ._get_client ().chat .completions .create (
525
527
model = self .model ,
526
528
messages = converted_messages ,
@@ -536,6 +538,7 @@ async def _fetch_response(
536
538
stream = stream ,
537
539
stream_options = {"include_usage" : True } if stream else NOT_GIVEN ,
538
540
store = store ,
541
+ reasoning_effort = self ._non_null_or_not_given (reasoning_effort ),
539
542
extra_headers = _HEADERS ,
540
543
metadata = model_settings .metadata ,
541
544
)
@@ -556,6 +559,7 @@ async def _fetch_response(
556
559
temperature = model_settings .temperature ,
557
560
tools = [],
558
561
parallel_tool_calls = parallel_tool_calls or False ,
562
+ reasoning = model_settings .reasoning ,
559
563
)
560
564
return response , ret
561
565
Original file line number Diff line number Diff line change @@ -247,6 +247,7 @@ async def _fetch_response(
247
247
extra_headers = _HEADERS ,
248
248
text = response_format ,
249
249
store = self ._non_null_or_not_given (model_settings .store ),
250
+ reasoning = self ._non_null_or_not_given (model_settings .reasoning ),
250
251
metadata = model_settings .metadata ,
251
252
)
252
253
You can’t perform that action at this time.
0 commit comments