NanoGPT: Add reasoning content display Fixes #4643

e4d779d4500e2b7f0e3cc6734bb68488c60a7fa8

Cohee <18619528+Cohee1207@users.noreply.github.com>

3 files changed, +4 -2Showing whitespace changes
public/index.html+1 -1
@@ -2058,7 +2058,7 @@
2058 </span>2058 </span>
2059 </div>2059 </div>
2060 </div>2060 </div>
2061 <div class="range-block" data-source="deepseek,aimlapi,openrouter,custom,claude,xai,makersuite,vertexai,pollinations,moonshot,mistralai,fireworks,cometapi,electronhub,azure_openai">2061 <div class="range-block" data-source="deepseek,aimlapi,openrouter,custom,claude,xai,makersuite,vertexai,pollinations,moonshot,mistralai,fireworks,cometapi,electronhub,azure_openai,nanogpt">
2062 <label for="openai_show_thoughts" class="checkbox_label widthFreeExpand">2062 <label for="openai_show_thoughts" class="checkbox_label widthFreeExpand">
2063 <input id="openai_show_thoughts" type="checkbox" />2063 <input id="openai_show_thoughts" type="checkbox" />
2064 <span data-i18n="Request model reasoning">Request model reasoning</span>2064 <span data-i18n="Request model reasoning">Request model reasoning</span>
public/scripts/openai.js+1 -1
@@ -2681,7 +2681,7 @@ export function getStreamingReply(data, state, { chatCompletionSource = null, ov
2681 state.reasoning += (data.choices?.filter(x => x?.delta?.reasoning)?.[0]?.delta?.reasoning || '');2681 state.reasoning += (data.choices?.filter(x => x?.delta?.reasoning)?.[0]?.delta?.reasoning || '');
2682 }2682 }
2683 return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';2683 return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';
2684 } else if ([chat_completion_sources.CUSTOM, chat_completion_sources.POLLINATIONS, chat_completion_sources.AIMLAPI, chat_completion_sources.MOONSHOT, chat_completion_sources.COMETAPI, chat_completion_sources.ELECTRONHUB].includes(chat_completion_source)) {2684 } else if ([chat_completion_sources.CUSTOM, chat_completion_sources.POLLINATIONS, chat_completion_sources.AIMLAPI, chat_completion_sources.MOONSHOT, chat_completion_sources.COMETAPI, chat_completion_sources.ELECTRONHUB, chat_completion_sources.NANOGPT].includes(chat_completion_source)) {
2685 if (show_thoughts) {2685 if (show_thoughts) {
2686 state.reasoning +=2686 state.reasoning +=
2687 data.choices?.filter(x => x?.delta?.reasoning_content)?.[0]?.delta?.reasoning_content ??2687 data.choices?.filter(x => x?.delta?.reasoning_content)?.[0]?.delta?.reasoning_content ??
public/scripts/reasoning.js+2 -0
@@ -125,6 +125,8 @@ export function extractReasoningFromData(data, {
125 case chat_completion_sources.POLLINATIONS:125 case chat_completion_sources.POLLINATIONS:
126 case chat_completion_sources.MOONSHOT:126 case chat_completion_sources.MOONSHOT:
127 case chat_completion_sources.COMETAPI:127 case chat_completion_sources.COMETAPI:
128 case chat_completion_sources.ELECTRONHUB:
129 case chat_completion_sources.NANOGPT:
128 case chat_completion_sources.CUSTOM: {130 case chat_completion_sources.CUSTOM: {
129 return data?.choices?.[0]?.message?.reasoning_content131 return data?.choices?.[0]?.message?.reasoning_content
130 ?? data?.choices?.[0]?.message?.reasoning132 ?? data?.choices?.[0]?.message?.reasoning