Skip to content

Commit 14fdc7c

Browse files
Add GPT-5.1 family support
- keep gpt-5.1 chat variants out of reasoning payloads - add regression test covering the updated heuristic Reference: - https://openai.com/index/gpt-5-1-for-developers/ - https://platform.openai.com/docs/models/gpt-5.1 - https://platform.openai.com/docs/models/gpt-5.1-chat-latest
1 parent ba2c1c8 commit 14fdc7c

File tree

5 files changed

+48
-3
lines changed

5 files changed

+48
-3
lines changed

app/openai_constants.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
GPT_5_MODEL = "gpt-5"
3434
GPT_5_MINI_MODEL = "gpt-5-mini"
3535
GPT_5_NANO_MODEL = "gpt-5-nano"
36+
GPT_5_1_CHAT_LATEST_MODEL = "gpt-5.1-chat-latest"
37+
GPT_5_1_MODEL = "gpt-5.1"
38+
GPT_5_1_2025_11_13_MODEL = "gpt-5.1-2025-11-13"
3639
O3_MODEL = "o3"
3740
O4_MINI_MODEL = "o4-mini"
3841
GPT_5_2025_08_07_MODEL = "gpt-5-2025-08-07"
@@ -77,11 +80,13 @@
7780
GPT_4O_MINI_2024_07_18_MODEL: (3, 1),
7881
# GPT-5 chat latest
7982
GPT_5_CHAT_LATEST_MODEL: (3, 1),
83+
GPT_5_1_CHAT_LATEST_MODEL: (3, 1),
8084
GPT_5_SEARCH_API_2025_10_14_MODEL: (3, 1),
8185
# GPT-5 family (dated)
8286
GPT_5_2025_08_07_MODEL: (3, 1),
8387
GPT_5_MINI_2025_08_07_MODEL: (3, 1),
8488
GPT_5_NANO_2025_08_07_MODEL: (3, 1),
89+
GPT_5_1_2025_11_13_MODEL: (3, 1),
8590
# Reasoning models (dated)
8691
O3_2025_04_16_MODEL: (3, 1),
8792
O4_MINI_2025_04_16_MODEL: (3, 1),
@@ -103,6 +108,7 @@
103108
GPT_5_MODEL: GPT_5_2025_08_07_MODEL,
104109
GPT_5_MINI_MODEL: GPT_5_MINI_2025_08_07_MODEL,
105110
GPT_5_NANO_MODEL: GPT_5_NANO_2025_08_07_MODEL,
111+
GPT_5_1_MODEL: GPT_5_1_2025_11_13_MODEL,
106112
GPT_5_SEARCH_API_MODEL: GPT_5_SEARCH_API_2025_10_14_MODEL,
107113
O3_MODEL: O3_2025_04_16_MODEL,
108114
O4_MINI_MODEL: O4_MINI_2025_04_16_MODEL,
@@ -134,11 +140,13 @@
134140
GPT_4_1_NANO_2025_04_14_MODEL: 1048576,
135141
# GPT-5 chat latest
136142
GPT_5_CHAT_LATEST_MODEL: 128000,
143+
GPT_5_1_CHAT_LATEST_MODEL: 128000,
137144
GPT_5_SEARCH_API_2025_10_14_MODEL: 128000,
138145
# GPT-5 family (dated)
139146
GPT_5_2025_08_07_MODEL: 128000,
140147
GPT_5_MINI_2025_08_07_MODEL: 128000,
141148
GPT_5_NANO_2025_08_07_MODEL: 128000,
149+
GPT_5_1_2025_11_13_MODEL: 128000,
142150
# Reasoning models (dated)
143151
O3_2025_04_16_MODEL: 128000,
144152
O4_MINI_2025_04_16_MODEL: 128000,

app/openai_ops.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,15 @@ def messages_within_context_window(
8686
def _is_reasoning(model: str) -> bool:
8787
"""Returns True if the model is a reasoning model under Chat Completions.
8888
89-
Excludes chat models like gpt-5-chat-latest and gpt-5-search-api. Matches o3*, o4*, and
90-
non-chat gpt-5* families. Case-insensitive and safe with None/empty.
89+
Excludes chat models like gpt-5-chat-latest, gpt-5.1-chat-latest, and gpt-5-search-api.
90+
Matches o3*, o4*, and non-chat gpt-5* families. Case-insensitive and safe with None/empty.
9191
"""
9292
if not model:
9393
return False
9494
ml = model.lower()
95-
if ml.startswith("gpt-5-chat") or ml.startswith("gpt-5-search"):
95+
# Treat any gpt-5 family chat/search variants (including numbered updates)
96+
# as regular chat models so they keep sampling params.
97+
if ml.startswith("gpt-5") and ("-chat" in ml or "-search" in ml):
9698
return False
9799
return (
98100
ml.startswith("o1")

app/slack_ui.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
GPT_4O_MINI_MODEL,
99
GPT_4_1_MODEL,
1010
GPT_4_1_MINI_MODEL,
11+
GPT_5_1_CHAT_LATEST_MODEL,
12+
GPT_5_1_MODEL,
1113
GPT_5_CHAT_LATEST_MODEL,
1214
GPT_5_MODEL,
1315
GPT_5_MINI_MODEL,
@@ -440,6 +442,14 @@ def build_configure_modal(context: BoltContext) -> dict:
440442
)
441443

442444
options = [
445+
{
446+
"text": {"type": "plain_text", "text": "GPT-5.1-chat-latest"},
447+
"value": GPT_5_1_CHAT_LATEST_MODEL,
448+
},
449+
{
450+
"text": {"type": "plain_text", "text": "GPT-5.1"},
451+
"value": GPT_5_1_MODEL,
452+
},
443453
{
444454
"text": {"type": "plain_text", "text": "GPT-5-chat-latest"},
445455
"value": GPT_5_CHAT_LATEST_MODEL,

tests/model_constants_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@
66
MODEL_CONTEXT_LENGTHS,
77
GPT_4_MODEL,
88
GPT_4_0613_MODEL,
9+
GPT_5_1_MODEL,
10+
GPT_5_1_2025_11_13_MODEL,
911
)
1012

1113
def test_alias_resolution():
1214
"""Tests that a model alias resolves to its specific version."""
1315
assert resolve_model_alias(GPT_4_MODEL) == GPT_4_0613_MODEL
1416

17+
18+
def test_gpt_5_1_alias_resolution():
19+
"""Ensures the GPT-5.1 alias resolves to the dated release."""
20+
assert resolve_model_alias(GPT_5_1_MODEL) == GPT_5_1_2025_11_13_MODEL
21+
1522
def test_unregistered_model_fails():
1623
"""Tests that resolving an unregistered model raises NotImplementedError."""
1724
# First, test the resolver

tests/openai_ops_test.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,24 @@ def fake_calculate_num_tokens(messages, model=None): # type: ignore[no-redef]
149149
assert captured["model"] == GPT_4O_MODEL
150150

151151

152+
@pytest.mark.parametrize(
153+
"model,expected",
154+
[
155+
("gpt-5-chat-latest", False),
156+
("gpt-5.1-chat-latest", False),
157+
("gpt-5-search-api", False),
158+
("gpt-5.1-2025-11-13", True),
159+
("gpt-5-nano", True),
160+
("o3", True),
161+
("o4-mini", True),
162+
("o1-preview", True),
163+
("gpt-4o", False),
164+
],
165+
)
166+
def test_is_reasoning_heuristics(model, expected):
167+
assert ops._is_reasoning(model) is expected
168+
169+
152170
@pytest.mark.parametrize("api_type", ["openai", "azure"])
153171
@pytest.mark.parametrize(
154172
"model,is_reasoning,temperature,timeout,user",

0 commit comments

Comments
 (0)