fix(provider): restore parameter transparency in core LLM provider adapters#6934
Conversation
…apters 核心对话适配器(OpenAI, Anthropic, Gemini)在准备请求 Payload 时未对 kwargs 进行合并,导致插件层传入的自定义参数(如 max_tokens, temperature, timeout 等)失效,回退到提供商的保守默认值。本次修复确保了各主流模型适配器对请求参数的完整透传。
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此 PR 解决了核心 LLM 提供商适配器中一个关键问题,即自定义参数在请求中被忽略,导致模型行为不一致。通过确保正确合并 Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Merging
kwargsdirectly intopayloadswill allow callers to overwrite core keys likemodelandmessages; consider either documenting this explicitly as supported behavior or protecting those keys from being overridden. - For the new
kwargspassthrough, it may be safer to validate or whitelist provider-specific parameters before adding them topayloadsto avoid sending unsupported or malformed options to the upstream APIs.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Merging `kwargs` directly into `payloads` will allow callers to overwrite core keys like `model` and `messages`; consider either documenting this explicitly as supported behavior or protecting those keys from being overridden.
- For the new `kwargs` passthrough, it may be safer to validate or whitelist provider-specific parameters before adding them to `payloads` to avoid sending unsupported or malformed options to the upstream APIs.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Code Review
This pull request enhances the Anthropic, Gemini, and OpenAI chat functions by allowing additional keyword arguments (kwargs) to be passed directly into the API request payload. The review comments suggest an improvement to the merging logic for these kwargs, recommending the use of dictionary unpacking ({**kwargs, ...}) to ensure that internally generated messages and model parameters are not inadvertently overwritten by values present in kwargs, thus improving the robustness and predictability of the API calls.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 645c482f69
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Hi, this change has caused numerous incompatibilities. I will keep it reverted until a more thorough audit can be conducted. |
收到 |
Modifications / 改动点
核心对话适配器(OpenAI, Anthropic, Gemini)在准备请求 Payload 时未对 kwargs 进行合并,导致插件层传入的自定义参数(如 max_tokens, temperature, timeout 等)失效,回退到提供商的保守默认值。本次修复确保了各主流模型适配器对请求参数的完整透传。
Checklist / 检查清单
😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
/ 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
/ 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。
🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in
requirements.txtandpyproject.toml./ 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到
requirements.txt和pyproject.toml文件相应位置。😮 My changes do not introduce malicious code.
/ 我的更改没有引入恶意代码。
Summary by Sourcery
Bug Fixes: