Update GPT settings for gpt-5.5
This commit is contained in:
@@ -7,17 +7,33 @@ import pytest
|
||||
from ea_py.config import load_runtime_config
|
||||
|
||||
|
||||
def test_load_runtime_config_uses_gpt55_defaults(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""Default OpenAI settings follow the GPT-5.5 Responses API contract."""
|
||||
monkeypatch.setenv("OPENAI_API_KEY", "test-key")
|
||||
monkeypatch.delenv("OPENAI_MODEL", raising=False)
|
||||
monkeypatch.delenv("OPENAI_REASONING_EFFORT", raising=False)
|
||||
monkeypatch.delenv("OPENAI_TEXT_VERBOSITY", raising=False)
|
||||
|
||||
actual = load_runtime_config()
|
||||
|
||||
assert actual.model == "gpt-5.5"
|
||||
assert actual.reasoning_effort == "low"
|
||||
assert actual.text_verbosity == "low"
|
||||
|
||||
|
||||
def test_load_runtime_config_reads_model_and_reasoning_from_env(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""OpenAI model and reasoning effort can be overridden without code edits."""
|
||||
monkeypatch.setenv("OPENAI_API_KEY", "test-key")
|
||||
monkeypatch.setenv("OPENAI_MODEL", "gpt-test")
|
||||
monkeypatch.setenv("OPENAI_REASONING_EFFORT", "low")
|
||||
monkeypatch.setenv("OPENAI_TEXT_VERBOSITY", "medium")
|
||||
|
||||
actual = load_runtime_config()
|
||||
|
||||
assert actual.api_key == "test-key"
|
||||
assert actual.model == "gpt-test"
|
||||
assert actual.reasoning_effort == "low"
|
||||
assert actual.text_verbosity == "medium"
|
||||
|
||||
|
||||
def test_load_runtime_config_rejects_invalid_reasoning_effort(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
@@ -27,3 +43,13 @@ def test_load_runtime_config_rejects_invalid_reasoning_effort(monkeypatch: pytes
|
||||
|
||||
with pytest.raises(RuntimeError, match="OPENAI_REASONING_EFFORT"):
|
||||
load_runtime_config()
|
||||
|
||||
|
||||
def test_load_runtime_config_rejects_invalid_text_verbosity(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""Invalid text verbosity should fail before an API call is attempted."""
|
||||
monkeypatch.setenv("OPENAI_API_KEY", "test-key")
|
||||
monkeypatch.delenv("OPENAI_REASONING_EFFORT", raising=False)
|
||||
monkeypatch.setenv("OPENAI_TEXT_VERBOSITY", "tiny")
|
||||
|
||||
with pytest.raises(RuntimeError, match="OPENAI_TEXT_VERBOSITY"):
|
||||
load_runtime_config()
|
||||
|
||||
@@ -23,7 +23,7 @@ class FakeResponse:
|
||||
|
||||
def __init__(self, *, output_text: str, incomplete_details: object | None = None) -> None:
|
||||
self.output_text = output_text
|
||||
self.model = "gpt-5.5-2026-04-23"
|
||||
self.model = "gpt-5.5"
|
||||
self.status = "completed"
|
||||
self.incomplete_details = incomplete_details
|
||||
self.error = None
|
||||
@@ -50,23 +50,25 @@ class FakeClient:
|
||||
self.responses = FakeResponsesResource(response)
|
||||
|
||||
|
||||
def test_call_responses_api_sends_reasoning_and_omits_temperature() -> None:
|
||||
"""GPT-5.5 requests should use reasoning controls instead of temperature."""
|
||||
def test_call_responses_api_sends_reasoning_text_controls_and_omits_temperature() -> None:
|
||||
"""GPT-5.5 requests should use reasoning/text controls instead of temperature."""
|
||||
fake_client = FakeClient(FakeResponse(output_text=" 0\n"))
|
||||
|
||||
actual = call_responses_api(
|
||||
client=fake_client, # type: ignore[arg-type]
|
||||
model="gpt-5.5-2026-04-23",
|
||||
model="gpt-5.5",
|
||||
reasoning_effort="none",
|
||||
system_content="Return one number.",
|
||||
user_text="Classify.",
|
||||
image_data_urls=[],
|
||||
max_output_tokens=128,
|
||||
text_verbosity="low",
|
||||
)
|
||||
|
||||
assert actual.text == "0"
|
||||
assert fake_client.responses.create_params["reasoning"] == {"effort": "none"}
|
||||
assert fake_client.responses.create_params["max_output_tokens"] == 128
|
||||
assert fake_client.responses.create_params["text"] == {"verbosity": "low"}
|
||||
assert "temperature" not in fake_client.responses.create_params
|
||||
|
||||
|
||||
@@ -87,17 +89,21 @@ def test_call_responses_api_sends_structured_text_format() -> None:
|
||||
|
||||
actual = call_responses_api(
|
||||
client=fake_client, # type: ignore[arg-type]
|
||||
model="gpt-5.5-2026-04-23",
|
||||
model="gpt-5.5",
|
||||
reasoning_effort="low",
|
||||
system_content="Return JSON.",
|
||||
user_text="Classify.",
|
||||
image_data_urls=[],
|
||||
max_output_tokens=128,
|
||||
response_text_format=response_text_format,
|
||||
text_verbosity="low",
|
||||
)
|
||||
|
||||
assert actual.text.startswith("{")
|
||||
assert fake_client.responses.create_params["text"] == {"format": response_text_format}
|
||||
assert fake_client.responses.create_params["text"] == {
|
||||
"format": response_text_format,
|
||||
"verbosity": "low",
|
||||
}
|
||||
|
||||
|
||||
def test_call_responses_api_returns_incomplete_diagnostics_for_empty_text() -> None:
|
||||
@@ -111,7 +117,7 @@ def test_call_responses_api_returns_incomplete_diagnostics_for_empty_text() -> N
|
||||
|
||||
actual = call_responses_api(
|
||||
client=fake_client, # type: ignore[arg-type]
|
||||
model="gpt-5.5-2026-04-23",
|
||||
model="gpt-5.5",
|
||||
reasoning_effort="low",
|
||||
system_content="Return one number.",
|
||||
user_text="Classify.",
|
||||
|
||||
Reference in New Issue
Block a user