fix(llm_judge): OpenAI base URL, max_completion_tokens for reasoning models, PIL image support#1381
Open
Luodian wants to merge 2 commits into
Open
fix(llm_judge): OpenAI base URL, max_completion_tokens for reasoning models, PIL image support#1381Luodian wants to merge 2 commits into
Luodian wants to merge 2 commits into
Conversation
…asoning models, PIL image support
…reasoning models in async provider
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
OPENAI_API_URLdefault (.../v1/chat/completions/v1) that was being passed straight into theOpenAI(base_url=...)client; now stores a clean base URL (defaulthttps://api.openai.com/v1) and appends/chat/completionsonly for the raw-requestsfallback path.base_urlinto theAsyncOpenAI(...)client construction -- previously a customOPENAI_API_URLoverride was silently ignored by the async client (only theaiohttpfallback respected it).max_completion_tokensinstead ofmax_tokensforgpt-5*/o1*/o3*/o4*models in both the sync and async providers, via a sharedbuild_sampling_kwargshelper (single source of truth so the two can't drift). For those reasoning models the helper also omitstemperature, which they reject at non-default values.PIL.Image.Imageobjects directly inOpenAIProvider._add_images_to_messages(in addition to file-path strings and pre-encoded bytes), reusing the existingencode_image_to_base64helper which already supportsUnion[Image.Image, str].Compatibility note
OPENAI_API_URLnow means a base URL (e.g.https://api.openai.com/v1or your proxy's base). If you previously set it to a full.../chat/completionsendpoint, drop that suffix — the SDK client appends the route itself.Test plan
python3 -m py_compileon changed filesuvx ruff check-- cleanOPENAI_API_URLresolves correctly for both sync and async clients and fallback paths; PIL image branch produces a correctdata:image/jpeg;base64,...URL; existing bytes-branch behavior unchangedgpt-4o->max_tokens+temperature;gpt-5-mini/o3->max_completion_tokensonly (notemperature, nomax_tokens); sync and async providers verified to share the same helper objectReview pass (2026-07-06)
Self-review caught that the original commit applied the
max_completion_tokensswitch to the sync provider only — the async provider (the default concurrent path) still sentmax_tokens, and both providers always senttemperature. Follow-up commit centralizes the logic inbuild_sampling_kwargs(used by both) and fixes staleimagestype hints.Follow-up candidate (out of scope here):
azure_openai.py/async_azure_openai.pyhave the same latent issue (always sendtemperature+max_tokens); the shared helper is import-ready for them.