Repository navigation
Conversation
1. Rename max_tokens to max_completion_tokens in OpenAICompatibleProvider for GPT-5 family and o-series models, which reject max_tokens on Chat Completions 2. Drop a non-default temperature for the o-series and the original gpt-5/gpt-5-mini/gpt-5-nano, which only accept the default temperature 3. Apply the normalization in both chat() and chat_stream() and add request-shape regression tests
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #153. Sampler calls go out through
OpenAICompatibleProvider.chat()/chat_stream(), which copied the caller's kwargs straight into the request. With an OpenAI reasoning model (gpt-5, gpt-5-mini, gpt-5.4, o3, …) every call was rejected with a 400 —Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead— so no algorithm was generated, and the provider connectivity test in the web UI failed the same way with a valid key.Changes
In
src/llm4ad/infra/provider/openai_compatible.py:_normalize_request_kwargs(), applied in bothchat()andchat_stream()before the request is built.gpt-5-chatvariants excluded — they are plain chat models), a caller'smax_tokensis renamed tomax_completion_tokens; an explicitly passedmax_completion_tokenswins.gpt-5,gpt-5-mini,gpt-5-nano, including dated snapshots), which reject any temperature other than 1, a non-defaulttemperatureis dropped so the request does not fail on the next parameter. Later GPT-5.x models keep their temperature.Tests
Eleven new request-shape tests in
tests/unit/provider/test_openai_compatible.py, using that file's mocked-client style:gpt-5.4-minichat: budget arrives asmax_completion_tokens=4096, nomax_tokens, temperature kept;o3/o4-mini/gpt-5/gpt-5-mini/gpt-5-nano: budget renamed and non-default temperature dropped;gpt-5withtemperature=1: kept (it is the models' own default);gpt-4o,gpt-5-chat-latest, anddeepseek-chatpassmax_tokensandtemperaturethrough unchanged;chat_streamwithgpt-5.4-mini: same normalization on the streaming path.Verification: the provider test file goes from 24 to 35 passing; with the provider change reverted, 8 of the new tests fail (the 3 guards stay green by design). A full
pytestrun shows a failure set identical to the unmodified baseline (9 pre-existing failures in unrelated AST/evaluator/settings tests), with exactly the 11 new tests added to the pass count.ruff checkandmypyare clean on the changed files.