fix(provider): inject chat_template_kwargs for Nvidia NIM deepseek-v4 models#24262
fix(provider): inject chat_template_kwargs for Nvidia NIM deepseek-v4 models#24262Zireael wants to merge 2 commits into
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
…tinue docs - BerriAI/litellm#26469 needs-discussion (config DualCache + batched prefetch, WIP) - anomalyco/opencode#24262 request-changes (NIM deepseek-v4 chat_template_kwargs body-mutating fetch) - continuedev/continue#12216 merge-as-is (openrouter identification headers docs)
|
isnt it enabled by default tho? |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #24264
Type of change
What does this PR do?
Resolves an issue where Nvidia NIM's
deepseek-v4-flashanddeepseek-v4-promodels fail to return a response when used in OpenCode because the Nvidia NIM API explicitly requireschat_template_kwargs: { enable_thinking: true, thinking: true }in the root of the JSON payload for reasoning models.Since the Vercel AI SDK strips unknown options, configuring this via
opencode.jsoncdoes not work. This PR fixes the issue by intercepting the fetch request in thenvidiaprovider definition and manually injecting the requiredchat_template_kwargsinto the JSON body when adeepseek-v4model is used.How did you verify your code works?
By locally overriding the provider configuration and confirming that the injected fetch wrapper successfully allows DeepSeek models from the Nvidia NIM API to stream reasoning and text responses.
Screenshots / recordings
If this is a UI change, please include a screenshot or recording.
Checklist