Skip to content

Commit eb0e1e7

Browse files
committed
o3-mini and reasoning_effort option, refs #728
1 parent 656d8fa commit eb0e1e7

File tree

4 files changed

+49
-4
lines changed

4 files changed

+49
-4
lines changed

docs/openai-models.md

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ OpenAI Chat: o1
5050
OpenAI Chat: o1-2024-12-17
5151
OpenAI Chat: o1-preview
5252
OpenAI Chat: o1-mini
53+
OpenAI Chat: o3-mini
5354
OpenAI Completion: gpt-3.5-turbo-instruct (aliases: 3.5-instruct, chatgpt-instruct)
5455
```
5556
<!-- [[[end]]] -->

docs/usage.md

+14
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ OpenAI Chat: o1
484484
logit_bias: dict, str
485485
seed: int
486486
json_object: boolean
487+
reasoning_effort: str
487488
Attachment types:
488489
image/gif, image/jpeg, image/png, image/webp
489490
OpenAI Chat: o1-2024-12-17
@@ -497,6 +498,7 @@ OpenAI Chat: o1-2024-12-17
497498
logit_bias: dict, str
498499
seed: int
499500
json_object: boolean
501+
reasoning_effort: str
500502
Attachment types:
501503
image/gif, image/jpeg, image/png, image/webp
502504
OpenAI Chat: o1-preview
@@ -521,6 +523,18 @@ OpenAI Chat: o1-mini
521523
logit_bias: dict, str
522524
seed: int
523525
json_object: boolean
526+
OpenAI Chat: o3-mini
527+
Options:
528+
temperature: float
529+
max_tokens: int
530+
top_p: float
531+
frequency_penalty: float
532+
presence_penalty: float
533+
stop: str
534+
logit_bias: dict, str
535+
seed: int
536+
json_object: boolean
537+
reasoning_effort: str
524538
OpenAI Completion: gpt-3.5-turbo-instruct (aliases: 3.5-instruct, chatgpt-instruct)
525539
Options:
526540
temperature: float

llm/cli.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1139,9 +1139,9 @@ def models_list(options, async_, query):
11391139
any_of = [{"type": field["type"]}]
11401140
types = ", ".join(
11411141
[
1142-
_type_lookup.get(item["type"], item["type"])
1142+
_type_lookup.get(item.get("type"), item.get("type", "str"))
11431143
for item in any_of
1144-
if item["type"] != "null"
1144+
if item.get("type") != "null"
11451145
]
11461146
)
11471147
bits = ["\n ", name, ": ", types]

llm/default_plugins/openai_models.py

+32-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
)
99
import click
1010
import datetime
11+
from enum import Enum
1112
import httpx
1213
import openai
1314
import os
@@ -71,8 +72,8 @@ def register_models(register):
7172
# o1
7273
for model_id in ("o1", "o1-2024-12-17"):
7374
register(
74-
Chat(model_id, vision=True, can_stream=False),
75-
AsyncChat(model_id, vision=True, can_stream=False),
75+
Chat(model_id, vision=True, can_stream=False, reasoning=True),
76+
AsyncChat(model_id, vision=True, can_stream=False, reasoning=True),
7677
)
7778

7879
register(
@@ -83,6 +84,10 @@ def register_models(register):
8384
Chat("o1-mini", allows_system_prompt=False),
8485
AsyncChat("o1-mini", allows_system_prompt=False),
8586
)
87+
register(
88+
Chat("o3-mini", reasoning=True),
89+
AsyncChat("o3-mini", reasoning=True),
90+
)
8691
# The -instruct completion model
8792
register(
8893
Completion("gpt-3.5-turbo-instruct", default_max_tokens=256),
@@ -322,6 +327,27 @@ def validate_logit_bias(cls, logit_bias):
322327
return validated_logit_bias
323328

324329

330+
class ReasoningEffortEnum(str, Enum):
331+
low = "low"
332+
medium = "medium"
333+
high = "high"
334+
335+
336+
class OptionsForReasoning(SharedOptions):
337+
json_object: Optional[bool] = Field(
338+
description="Output a valid JSON object {...}. Prompt must mention JSON.",
339+
default=None,
340+
)
341+
reasoning_effort: Optional[ReasoningEffortEnum] = Field(
342+
description=(
343+
"Constraints effort on reasoning for reasoning models. Currently supported "
344+
"values are low, medium, and high. Reducing reasoning effort can result in "
345+
"faster responses and fewer tokens used on reasoning in a response."
346+
),
347+
default=None,
348+
)
349+
350+
325351
def _attachment(attachment):
326352
url = attachment.url
327353
base64_content = ""
@@ -355,6 +381,7 @@ def __init__(
355381
can_stream=True,
356382
vision=False,
357383
audio=False,
384+
reasoning=False,
358385
allows_system_prompt=True,
359386
):
360387
self.model_id = model_id
@@ -371,6 +398,9 @@ def __init__(
371398

372399
self.attachment_types = set()
373400

401+
if reasoning:
402+
self.Options = OptionsForReasoning
403+
374404
if vision:
375405
self.attachment_types.update(
376406
{

0 commit comments

Comments
 (0)