This commit is contained in:
@@ -94,6 +94,7 @@ curl http://127.0.0.1:8000/v1/chat/completions \
|
|||||||
## Supported Models
|
## Supported Models
|
||||||
|
|
||||||
- `gpt-5.5`
|
- `gpt-5.5`
|
||||||
|
- `gpt-5.5-pro` (preset for `gpt-5.5` with xhigh reasoning)
|
||||||
- `gpt-5.4`
|
- `gpt-5.4`
|
||||||
- `gpt-5.4-mini`
|
- `gpt-5.4-mini`
|
||||||
- `gpt-5.2`
|
- `gpt-5.2`
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ from .model_registry import normalize_model_name
|
|||||||
PRIORITY_SUPPORTED_MODELS = frozenset(
|
PRIORITY_SUPPORTED_MODELS = frozenset(
|
||||||
(
|
(
|
||||||
"gpt-5.4",
|
"gpt-5.4",
|
||||||
|
"gpt-5.5",
|
||||||
"gpt-5.2",
|
"gpt-5.2",
|
||||||
"gpt-5.1",
|
"gpt-5.1",
|
||||||
"gpt-5",
|
"gpt-5",
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class ModelSpec:
|
|||||||
allowed_efforts: frozenset[str]
|
allowed_efforts: frozenset[str]
|
||||||
variant_efforts: tuple[str, ...]
|
variant_efforts: tuple[str, ...]
|
||||||
uses_codex_instructions: bool = False
|
uses_codex_instructions: bool = False
|
||||||
|
preset_effort: str | None = None
|
||||||
|
|
||||||
|
|
||||||
_MODEL_SPECS = (
|
_MODEL_SPECS = (
|
||||||
@@ -61,6 +62,14 @@ _MODEL_SPECS = (
|
|||||||
allowed_efforts=frozenset(("none", "low", "medium", "high", "xhigh")),
|
allowed_efforts=frozenset(("none", "low", "medium", "high", "xhigh")),
|
||||||
variant_efforts=("xhigh", "high", "medium", "low", "none"),
|
variant_efforts=("xhigh", "high", "medium", "low", "none"),
|
||||||
),
|
),
|
||||||
|
ModelSpec(
|
||||||
|
public_id="gpt-5.5-pro",
|
||||||
|
upstream_id="gpt-5.5",
|
||||||
|
aliases=("gpt5.5-pro", "gpt-5.5-pro-latest"),
|
||||||
|
allowed_efforts=frozenset(("none", "low", "medium", "high", "xhigh")),
|
||||||
|
variant_efforts=(),
|
||||||
|
preset_effort="xhigh",
|
||||||
|
),
|
||||||
ModelSpec(
|
ModelSpec(
|
||||||
public_id="gpt-5.3-codex",
|
public_id="gpt-5.3-codex",
|
||||||
upstream_id="gpt-5.3-codex",
|
upstream_id="gpt-5.3-codex",
|
||||||
@@ -127,12 +136,12 @@ _MODEL_SPECS = (
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
_SPECS_BY_UPSTREAM = {spec.upstream_id: spec for spec in _MODEL_SPECS}
|
_SPECS_BY_PUBLIC_ID = {spec.public_id: spec for spec in _MODEL_SPECS}
|
||||||
_ALIASES = {}
|
_ALIASES = {}
|
||||||
for _spec in _MODEL_SPECS:
|
for _spec in _MODEL_SPECS:
|
||||||
_ALIASES[_spec.public_id] = _spec.upstream_id
|
_ALIASES[_spec.public_id] = _spec.public_id
|
||||||
for _alias in _spec.aliases:
|
for _alias in _spec.aliases:
|
||||||
_ALIASES[_alias] = _spec.upstream_id
|
_ALIASES[_alias] = _spec.public_id
|
||||||
|
|
||||||
|
|
||||||
def _strip_model_name(model: str | None) -> tuple[str, str | None]:
|
def _strip_model_name(model: str | None) -> tuple[str, str | None]:
|
||||||
@@ -155,10 +164,10 @@ def _strip_model_name(model: str | None) -> tuple[str, str | None]:
|
|||||||
|
|
||||||
def model_spec_for_name(model: str | None) -> ModelSpec | None:
|
def model_spec_for_name(model: str | None) -> ModelSpec | None:
|
||||||
base, _ = _strip_model_name(model)
|
base, _ = _strip_model_name(model)
|
||||||
upstream_id = _ALIASES.get(base)
|
public_id = _ALIASES.get(base)
|
||||||
if not upstream_id:
|
if not public_id:
|
||||||
return None
|
return None
|
||||||
return _SPECS_BY_UPSTREAM.get(upstream_id)
|
return _SPECS_BY_PUBLIC_ID.get(public_id)
|
||||||
|
|
||||||
|
|
||||||
def normalize_model_name(model: str | None, debug_model: str | None = None) -> str:
|
def normalize_model_name(model: str | None, debug_model: str | None = None) -> str:
|
||||||
@@ -187,6 +196,9 @@ def allowed_efforts_for_model(model: str | None) -> frozenset[str]:
|
|||||||
|
|
||||||
def extract_reasoning_from_model_name(model: str | None) -> dict[str, str] | None:
|
def extract_reasoning_from_model_name(model: str | None) -> dict[str, str] | None:
|
||||||
_, effort = _strip_model_name(model)
|
_, effort = _strip_model_name(model)
|
||||||
|
if not effort:
|
||||||
|
spec = model_spec_for_name(model)
|
||||||
|
effort = spec.preset_effort if spec is not None else None
|
||||||
if not effort:
|
if not effort:
|
||||||
return None
|
return None
|
||||||
return {"effort": effort}
|
return {"effort": effort}
|
||||||
|
|||||||
@@ -2,7 +2,12 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from chatmock.model_registry import allowed_efforts_for_model, list_public_models, normalize_model_name
|
from chatmock.model_registry import (
|
||||||
|
allowed_efforts_for_model,
|
||||||
|
extract_reasoning_from_model_name,
|
||||||
|
list_public_models,
|
||||||
|
normalize_model_name,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ModelRegistryTests(unittest.TestCase):
|
class ModelRegistryTests(unittest.TestCase):
|
||||||
@@ -11,6 +16,7 @@ class ModelRegistryTests(unittest.TestCase):
|
|||||||
self.assertEqual(normalize_model_name("gpt5.4"), "gpt-5.4")
|
self.assertEqual(normalize_model_name("gpt5.4"), "gpt-5.4")
|
||||||
self.assertEqual(normalize_model_name("gpt5.4-mini"), "gpt-5.4-mini")
|
self.assertEqual(normalize_model_name("gpt5.4-mini"), "gpt-5.4-mini")
|
||||||
self.assertEqual(normalize_model_name("gpt5.5"), "gpt-5.5")
|
self.assertEqual(normalize_model_name("gpt5.5"), "gpt-5.5")
|
||||||
|
self.assertEqual(normalize_model_name("gpt-5.5-pro"), "gpt-5.5")
|
||||||
self.assertEqual(normalize_model_name("gpt5.3-codex-spark"), "gpt-5.3-codex-spark")
|
self.assertEqual(normalize_model_name("gpt5.3-codex-spark"), "gpt-5.3-codex-spark")
|
||||||
self.assertEqual(normalize_model_name("codex"), "codex-mini-latest")
|
self.assertEqual(normalize_model_name("codex"), "codex-mini-latest")
|
||||||
|
|
||||||
@@ -24,13 +30,19 @@ class ModelRegistryTests(unittest.TestCase):
|
|||||||
|
|
||||||
def test_allowed_efforts_follow_registry(self) -> None:
|
def test_allowed_efforts_follow_registry(self) -> None:
|
||||||
self.assertEqual(allowed_efforts_for_model("gpt-5.5"), frozenset(("none", "low", "medium", "high", "xhigh")))
|
self.assertEqual(allowed_efforts_for_model("gpt-5.5"), frozenset(("none", "low", "medium", "high", "xhigh")))
|
||||||
|
self.assertEqual(allowed_efforts_for_model("gpt-5.5-pro"), frozenset(("none", "low", "medium", "high", "xhigh")))
|
||||||
self.assertEqual(allowed_efforts_for_model("gpt-5.4"), frozenset(("none", "low", "medium", "high", "xhigh")))
|
self.assertEqual(allowed_efforts_for_model("gpt-5.4"), frozenset(("none", "low", "medium", "high", "xhigh")))
|
||||||
self.assertEqual(allowed_efforts_for_model("gpt-5.4-mini"), frozenset(("low", "medium", "high", "xhigh")))
|
self.assertEqual(allowed_efforts_for_model("gpt-5.4-mini"), frozenset(("low", "medium", "high", "xhigh")))
|
||||||
self.assertEqual(allowed_efforts_for_model("gpt-5.1-codex"), frozenset(("low", "medium", "high")))
|
self.assertEqual(allowed_efforts_for_model("gpt-5.1-codex"), frozenset(("low", "medium", "high")))
|
||||||
|
|
||||||
|
def test_pro_preset_uses_xhigh_reasoning(self) -> None:
|
||||||
|
self.assertEqual(extract_reasoning_from_model_name("gpt-5.5-pro"), {"effort": "xhigh"})
|
||||||
|
self.assertEqual(extract_reasoning_from_model_name("gpt-5.5-pro-low"), {"effort": "low"})
|
||||||
|
|
||||||
def test_public_models_include_variants(self) -> None:
|
def test_public_models_include_variants(self) -> None:
|
||||||
model_ids = list_public_models(expose_reasoning_models=True)
|
model_ids = list_public_models(expose_reasoning_models=True)
|
||||||
self.assertIn("gpt-5.5", model_ids)
|
self.assertIn("gpt-5.5", model_ids)
|
||||||
|
self.assertIn("gpt-5.5-pro", model_ids)
|
||||||
self.assertIn("gpt-5.4", model_ids)
|
self.assertIn("gpt-5.4", model_ids)
|
||||||
self.assertIn("gpt-5.4-mini", model_ids)
|
self.assertIn("gpt-5.4-mini", model_ids)
|
||||||
self.assertIn("gpt-5.3-codex-spark", model_ids)
|
self.assertIn("gpt-5.3-codex-spark", model_ids)
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ class RouteTests(unittest.TestCase):
|
|||||||
body = response.get_json()
|
body = response.get_json()
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
model_ids = [item["id"] for item in body["data"]]
|
model_ids = [item["id"] for item in body["data"]]
|
||||||
|
self.assertIn("gpt-5.5", model_ids)
|
||||||
|
self.assertIn("gpt-5.5-pro", model_ids)
|
||||||
self.assertIn("gpt-5.4", model_ids)
|
self.assertIn("gpt-5.4", model_ids)
|
||||||
self.assertIn("gpt-5.4-mini", model_ids)
|
self.assertIn("gpt-5.4-mini", model_ids)
|
||||||
self.assertIn("gpt-5.3-codex-spark", model_ids)
|
self.assertIn("gpt-5.3-codex-spark", model_ids)
|
||||||
|
|||||||
Reference in New Issue
Block a user