feat(providers): route non-standard generate_kwargs into extra_body#4689
Merged
lalaliat merged 3 commits intoJun 2, 2026
Merged
Conversation
DashScope's web search (enable_search) and other provider-specific
parameters must be passed via the OpenAI SDK's extra_body parameter,
not as top-level kwargs. The SDK's create() method rejects unknown
keyword arguments with TypeError.
This adds an __init__ override in OpenAIChatModelCompat that
automatically moves any generate_kwargs keys not recognized by the
OpenAI SDK into extra_body, so they are correctly included in the
HTTP request body. Users can now simply configure
{"enable_search": true} in generate_kwargs and it will work.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Hi @leoleils, this is your 9th Pull Request. 📋 About PR TemplateTo help maintainers review your PR faster, please make sure to include:
Complete PR information helps speed up the review process. You can edit the PR description to add these details. 🙌 Join Developer CommunityThanks so much for your contribution! We'd love to invite you to join the official QwenPaw developer group! You can find the Discord and DingTalk group links under the "Developer Community" section on our docs page: We truly appreciate your enthusiasm—and look forward to your future contributions! 😊 We'll review your PR soon. |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
lalaliat
reviewed
May 29, 2026
e70bb7b to
9262b25
Compare
9262b25 to
562a83b
Compare
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
562a83b to
73cd3f2
Compare
This was referenced Jun 2, 2026
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.

Description
Non-standard provider parameters (e.g. DashScope's
enable_search) configured ingenerate_kwargsare silently rejected by the OpenAI Python SDK, becauseclient.chat.completions.create()does not accept unknown keyword arguments.This PR adds an
__init__override inOpenAIChatModelCompatthat automatically moves unrecognizedgenerate_kwargskeys intoextra_body, so they are correctly included in the HTTP request body.Users can now simply configure
{"enable_search": true}in a model'sgenerate_kwargsand DashScope web search will work.Related Issue: Fixes #4688
Security Considerations: N/A
Type of Change
Component(s) Affected
Checklist
pre-commit run --all-fileslocally and it passespytestor as relevant) and they passTesting
{"enable_search": true}in a DashScope model'sgenerate_kwargsvia UItemperature,max_tokens) still work as top-level kwargs{"extra_body": {"enable_search": true}}form also worksLocal Verification Evidence
Additional Notes
The
_OPENAI_CREATE_PARAMSfrozenset is derived from the OpenAI Python SDK'sAsyncCompletions.create()method signature. If the SDK adds new parameters in future versions, they would simply remain as top-level kwargs (correct behavior) — no update needed unless a new SDK param name collides with a provider-specific param name (extremely unlikely).