fix(adapters/deepseek): enable tool capabilities for reasoner model and handle reasoning_content#2687
Draft
nabiu256 wants to merge 3 commits intoolimorris:mainfrom
Draft
fix(adapters/deepseek): enable tool capabilities for reasoner model and handle reasoning_content#2687nabiu256 wants to merge 3 commits intoolimorris:mainfrom
nabiu256 wants to merge 3 commits intoolimorris:mainfrom
Conversation
Owner
|
Thanks for the PR.
FYI, this was added when the reasoning models did not support tool calling Before I can merge this I'll need test coverage of the reasoning output, as we have for the other adapters. |
Author
I'll get on testing asap. Thank you for the quick answer. |
|
Hi @nabiu256 are you still working on this? I tried your patch recently (on form_messages = function(self, messages)
- messages = adapter_utils.merge_messages(messages)
+ messages = adapter_utils.merge_messages(messages, { "tools", "reasoning" })
messages = adapter_utils.merge_system_messages(messages)+ form_reasoning = function(self, data)
+ local content = vim
+ .iter(data)
+ :map(function(item)
+ return item.content
+ end)
+ :join("")
+ return { content = content }
+ end, parse_message_meta = function(self, data)
local extra = data.extra
- if extra.reasoning_content then
+ if extra.reasoning_content and extra.reasoning_content ~= "" then
data.output.reasoning = { content = extra.reasoning_content } |
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
Fixes two issues in the DeepSeek adapter:
Enables tool capabilities for DeepSeek Reasoner model: The DeepSeek Reasoner model (
deepseek-reasoner) supports function calling/tools but was incorrectly configured withcan_use_tools = false.Adds proper handling of
reasoning_contentfield: DeepSeek's API expects a non-standardreasoning_contentfield for reasoning models instead of the standardreasoningfield used by other providers. This change:reasoningtable/string toreasoning_contentreasoning_contentexists for assistant messages in reasoning modeAI Usage
Used opencode to implement the changes based on DeepSeek API documentation and existing adapter patterns.
Testing
make test_file FILE=tests/adapters/http/test_deepseek.luaChecklist