-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include DeepSeek's reasoning_content when present #592
base: master
Are you sure you want to change the base?
Conversation
@z80dev Thanks for the PR! I have some suggestions to simplify the parser functions, I'll explain when I next have some time. For now I wanted to mention some thoughts about the
Making the switch part of the backend definition makes it difficult to do this. Essentially you have to run (setf (gptel-backend-show-reasoning (gptel-get-backend "Deepseek")) t) Considering the above points, perhaps it makes sense to make this configurable at the gptel level instead of the gptel-backend level? Perhaps via a switch like |
Regarding the UI, I agree that a quick toggle option is needed. In my testing I often find the reasoning output interesting but not really relevant for the work, therefore showing a side buffer |
Good idea! I first started implementing with a separate variable (scoped only to deepseek), but then migrated to backend-level config for this because sometimes I wanted one backend to show reasoning, and another not showing reasoning. For this to work with a global toggle, I would have to be flipped each time I make a request which is not ideal and yes the point about having reasoning in the main gptel buffer or in a side buffer is another good point. Another option to consider is having the reasoning be put under a sub-heading (so all this shows how differently our use-cases can be, and we should prioritize flexibility to not get in developer's way I will start with refactoring the toggle to be a variable instead of part of the backend config, and make it so it can also be set per-buffer via the transient. this supports my use-case I mentioned above (some backends I want the reasoning to show, others not) without making it part of the backend config. then I will look into "reasoning output destinations" like a collapsed or uncollapsed heading, or a separate buffer, or just in-place |
I'm not sure what you are comparing this with, because it's the same amount of work in both approaches, but a gptel-level toggle can be more versatile.
The advantage of the latter is that you can additionally use a single backend both with and without reasoning included. In the former you'd have to define two identical deepseek backends (but for the show-reasoning property) to be able to do that.
You can do exactly this with a post response hook. See my comment here.
You just have to use the
Perhaps |
@z80dev I'd like to merge this, as I'm getting many issues/discussions requesting this feature on the tracker. Do you think you'll be able to incorporate the changes we discussed soon? |
@karthink |
It's a little involved so I'll explain when I get a reasonably sized chunk of free time, hopefully soon. |
and redefine gptel-deepseek to use this variable in its parsing to determine whether to include reasoning
Can you provide me with the log for a medium sized deepseek-reasoner response? Both streaming and non-streaming, although the former is more important. To propose changes to the parsers, I need to understand what the output looks like. I don't have Deepseek access so I'm flying blind right now. |
(when (and reasoning-content | ||
(not (equal reasoning-content :null)) | ||
gptel-include-reasoning) | ||
(unless (plist-get info :header-printed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Headers feels like a front-end detail for sure. This would be a block / drawer in org and a source block in markdown.
@karthink this is where I think a TYPE
argument in the callback would be useful for allowing the front-end to differentiate reasoning as a message type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Headers feels like a front-end detail for sure.
Yes, my plan for Deepseek integration is different from this, and in line with separating the response parser from the UI. I need to look at some Deepseek response logs to make a proposal.
@karthink this is where I think a TYPE argument in the callback would be useful for allowing the front-end to differentiate reasoning as a message type.
TYPE
will not fly, but I've already covered alternatives in detail in my response to your suggestion.
https://github.com/marketplace/models/azureml-deepseek/DeepSeek-R1/playground |
Changes in #626 are highly relevant to new response types and the frontend / backend separation.
I'm likely to begin hacking on this PR. It looks okay except for bundling reasoning in with chat.
@sg-qwt did you actually authenticate against it? Please share details so I can catch up. |
Just get a Github PAT(no need to tick any permission), you're good to go. The model always includes |
I'm about to crash. If you are awake, I need an eli5. Put the PAT in auth info? How can I add some headers to set super low token and reasoning limits if I just want to be sure and get enough sample requests? |
I tested it with Github models, and the situation is a little more complicated than it appears. The Github models API just adds literal This PR is for the Deepseek API. I can't get access to the API, so I need to see some logs (both streaming and non-streaming) before I can decide how best to handle the parsing. Handling the |
Creates a separate backend for DeepSeek that inherits from the (mostly compatible) OpenAI backend.
Adds parsing and formatting of reasoning content, and a constructor argument for the backend to configure reasoning inclusion.