Skip to content

Commit bb0cd90

Browse files
authored
adding reasoning effort param (#46)
1 parent c772c1f commit bb0cd90

File tree

3 files changed

+26
-36
lines changed

3 files changed

+26
-36
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,5 @@ venv.bak/
108108
# JetBrains Folder
109109
.idea
110110

111+
# uv package management
112+
uv.lock

predictionguard/src/chat.py

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def create(
9898
max_tokens: Optional[int] = None,
9999
parallel_tool_calls: Optional[bool] = None,
100100
presence_penalty: Optional[float] = None,
101+
reasoning_effort: Optional[str] = None,
101102
stop: Optional[
102103
Union[
103104
str, List[str]
@@ -124,11 +125,13 @@ def create(
124125
:param frequency_penalty: The frequency penalty to use.
125126
:param logit_bias: The logit bias to use.
126127
:param max_completion_tokens: The maximum amount of tokens the model should return.
128+
:param max_tokens: Deprecated, please use max_completion_tokens instead.
127129
:param parallel_tool_calls: The parallel tool calls to use.
128130
:param presence_penalty: The presence penalty to use.
131+
:param reasoning_effort: How much effort for model to use for reasoning. Only supported by reasoning models.
129132
:param stop: The completion stopping criteria.
130133
:param stream: Option to stream the API response
131-
:param temperature: The consistency of the model responses to the same prompt. The higher the more consistent.
134+
:param temperature: The consistency of the model responses to the same prompt. The higher it is set, the more consistent.
132135
:param tool_choice: The tool choice to use.
133136
:param tools: Options to pass to the tool choice.
134137
:param top_p: The sampling for the model to use.
@@ -157,6 +160,7 @@ def create(
157160
max_completion_tokens,
158161
parallel_tool_calls,
159162
presence_penalty,
163+
reasoning_effort,
160164
stop,
161165
stream,
162166
temperature,
@@ -182,6 +186,7 @@ def _generate_chat(
182186
max_completion_tokens,
183187
parallel_tool_calls,
184188
presence_penalty,
189+
reasoning_effort,
185190
stop,
186191
stream,
187192
temperature,
@@ -311,40 +316,23 @@ def stream_generator(url, headers, payload, stream, timeout):
311316
elif entry["type"] == "text":
312317
continue
313318

314-
# TODO: Remove `tool_choice` check when null value available in API
315-
if tool_choice is None:
316-
payload_dict = {
317-
"model": model,
318-
"messages": messages,
319-
"frequency_penalty": frequency_penalty,
320-
"logit_bias": logit_bias,
321-
"max_completion_tokens": max_completion_tokens,
322-
"parallel_tool_calls": parallel_tool_calls,
323-
"presence_penalty": presence_penalty,
324-
"stop": stop,
325-
"stream": stream,
326-
"temperature": temperature,
327-
"tools": tools,
328-
"top_p": top_p,
329-
"top_k": top_k,
330-
}
331-
else:
332-
payload_dict = {
333-
"model": model,
334-
"messages": messages,
335-
"frequency_penalty": frequency_penalty,
336-
"logit_bias": logit_bias,
337-
"max_completion_tokens": max_completion_tokens,
338-
"parallel_tool_calls": parallel_tool_calls,
339-
"presence_penalty": presence_penalty,
340-
"stop": stop,
341-
"stream": stream,
342-
"temperature": temperature,
343-
"tool_choice": tool_choice,
344-
"tools": tools,
345-
"top_p": top_p,
346-
"top_k": top_k,
347-
}
319+
payload_dict = {
320+
"model": model,
321+
"messages": messages,
322+
"frequency_penalty": frequency_penalty,
323+
"logit_bias": logit_bias,
324+
"max_completion_tokens": max_completion_tokens,
325+
"parallel_tool_calls": parallel_tool_calls,
326+
"presence_penalty": presence_penalty,
327+
"reasoning_effort": reasoning_effort,
328+
"stop": stop,
329+
"stream": stream,
330+
"temperature": temperature,
331+
"tool_choice": tool_choice,
332+
"tools": tools,
333+
"top_p": top_p,
334+
"top_k": top_k,
335+
}
348336

349337
if input:
350338
payload_dict["input"] = input

predictionguard/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Setting the package version
2-
__version__ = "2.9.1"
2+
__version__ = "2.9.2"

0 commit comments

Comments
 (0)