Removing <think>....</think> blocks from Deepseek responses #579
Replies: 8 comments 15 replies
-
Here's an improved version for org-mode only. Instead of removing the block, it wraps it in an org-mode drawer named
|
Beta Was this translation helpful? Give feedback.
-
When converting responses to org-mode formatting, it would perhaps be convenient to get the chain of thought in a collapsible drawer, i.e.:
|
Beta Was this translation helpful? Give feedback.
-
@erwald and @karthink , just one question about this: would the hook prevent the concatenation of the successive CoT's to the context? |
Beta Was this translation helpful? Give feedback.
-
@erwald and @karthink , just one question about this:
would the hook prevent the concatenation of the successive CoT's to the context?
If the CoT text is in the buffer, it's in the conversation context. So if you want it to be, you shouldn't delete it from the buffer.
|
Beta Was this translation helpful? Give feedback.
-
Nop, I don't want it to be in the context. Actually I am asking because of what is said in the [deepseek api](https://api-docs.deepseek.com/guides/reasoning_model). In particular because of this:
"_Please note that if the reasoning_content field is included in the sequence of input messages, the API will return a 400 error. Therefore, you should remove the reasoning_content field from the API response before making the API request_"
It looks like deepseek's API is different from OpenAI's, or that the OpenAI API has new features that gptel doesn't support. Either way, the "reasoning_content" field is not added to the chat buffer so it should work as expected.
|
Beta Was this translation helpful? Give feedback.
-
(setq-local outline-regexp "<.*" outline-heading-end-regexp "\n") This works to collapse the think block with outline-minor-mode. I would appreciate some help with doing this while preserving the default markdown mode outline regexps. |
Beta Was this translation helpful? Give feedback.
-
Is there any simple way to have the text appear in a separate buffer? |
Beta Was this translation helpful? Give feedback.
-
You can now show the reasoning block along the response, or in another buffer, or ignore it, or more. Including it along with the response will cause it to be enclosed in an Org block or markdown backticks. See the user option This should work for all backends that use reasoning blocks, including Claude (3-7-sonnet), Deepseek, Openrouter, Grok, Github Models and more. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am running a Deepseek R1 model via LM Studio and it always returns responses that look like this:
My objective is to remove the entire
<think>...</think>
block and the extra newline it brings, because I only care about capturing the actual response. Heres my code that does this based on another answer I found here in the discussion area about trimming responses.With this hook enabled, now the response would be truncated to
Truth
.Beta Was this translation helpful? Give feedback.
All reactions