Update to latest staging, thinking separation is now built in.

On Deepseek, you can just prefill <think> and use the provided regexes at the bottom of this rentry. As well, other providers tend to just send you the thinking block as part of the response.

Lets you regex the model thoughts section by wrapping it in <thinking></thinking>.

diff --git a/public/script.js b/public/script.js
index 2bbc88c9e..d0adc59ae 100644
--- a/public/script.js
+++ b/public/script.js
@@ -5675,7 +5675,7 @@ function extractMessageFromData(data) {
     const content = getTextContext();

     if (main_api === 'openai' && oai_settings.chat_completion_source === chat_completion_sources.DEEPSEEK && oai_settings.show_thoughts) {
-        const thoughts = data?.choices?.[0]?.message?.reasoning_content ?? '';
+        const thoughts = "<thinking>" + (data?.choices?.[0]?.message?.reasoning_content ?? '') + "</thinking>";
         return [thoughts, content].filter(x => x).join('\n\n');
     }

diff --git a/public/scripts/openai.js b/public/scripts/openai.js
index 55a9858af..f6a936479 100644
--- a/public/scripts/openai.js
+++ b/public/scripts/openai.js
@@ -2155,9 +2155,11 @@ function getStreamingReply(data, state) {
         return data?.delta?.message?.content?.text || data?.delta?.message?.tool_plan || '';
     } else if (oai_settings.chat_completion_source === chat_completion_sources.DEEPSEEK) {
         const hadThoughts = state.hadThoughts;
-        const thoughts = data.choices?.filter(x => oai_settings.show_thoughts || !x?.delta?.reasoning_content)?.[0]?.delta?.reasoning_content || '';
+        let thoughts = data.choices?.filter(x => oai_settings.show_thoughts || !x?.delta?.reasoning_content)?.[0]?.delta?.reasoning_content || '';
+        if (thoughts && !hadThoughts) { thoughts = "<thinking>" + thoughts; }
         const content = data.choices?.[0]?.delta?.content || '';
         state.hadThoughts = !!thoughts;
+        if (hadThoughts && !thoughts) { thoughts = thoughts + "</thinking>"; }
         const separator = hadThoughts && !thoughts ? '\n\n' : '';
         return [thoughts, separator, content].filter(x => x).join('\n\n');
     } else  {

FAQ

Q: How do I...?
A: Copy and paste the above block to your AI and ask it your question. I promise it can answer your question.

Q: Regex for this feel?
A: https://files.catbox.moe/qy5itf.json https://files.catbox.moe/gwtwe3.json

Edit Report
Pub: 21 Jan 2025 02:42 UTC
Edit: 27 Jan 2025 20:33 UTC
Views: 1649