Merge pull request #3535 from yokuminto/release add reasoning display switch in custom source

3a25550f5b8d4bffe67462cdf5ccebff53c394cd

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

Signed
3 files changed, +14 -1Showing whitespace changes
public/index.html+1 -1
@@ -2000,7 +2000,7 @@
2000 </span>2000 </span>
2001 </div>2001 </div>
2002 </div>2002 </div>
2003 <div class="range-block" data-source="deepseek,openrouter">2003 <div class="range-block" data-source="deepseek,openrouter,custom">
2004 <label for="openai_show_thoughts" class="checkbox_label widthFreeExpand">2004 <label for="openai_show_thoughts" class="checkbox_label widthFreeExpand">
2005 <input id="openai_show_thoughts" type="checkbox" />2005 <input id="openai_show_thoughts" type="checkbox" />
2006 <span>2006 <span>
public/scripts/openai.js+8 -0
@@ -2167,6 +2167,14 @@ function getStreamingReply(data, state) {
2167 state.reasoning += (data.choices?.filter(x => x?.delta?.reasoning)?.[0]?.delta?.reasoning || '');2167 state.reasoning += (data.choices?.filter(x => x?.delta?.reasoning)?.[0]?.delta?.reasoning || '');
2168 }2168 }
2169 return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';2169 return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';
2170 } else if (oai_settings.chat_completion_source === chat_completion_sources.CUSTOM) {
2171 if (oai_settings.show_thoughts) {
2172 state.reasoning +=
2173 data.choices?.filter(x => x?.delta?.reasoning_content)?.[0]?.delta?.reasoning_content ??
2174 data.choices?.filter(x => x?.delta?.reasoning)?.[0]?.delta?.reasoning ??
2175 '';
2176 }
2177 return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';
2170 } else {2178 } else {
2171 return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';2179 return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';
2172 }2180 }
public/scripts/reasoning.js+5 -0
@@ -76,6 +76,11 @@ export function extractReasoningFromData(data) {
76 return data?.choices?.[0]?.message?.reasoning ?? '';76 return data?.choices?.[0]?.message?.reasoning ?? '';
77 case chat_completion_sources.MAKERSUITE:77 case chat_completion_sources.MAKERSUITE:
78 return data?.responseContent?.parts?.filter(part => part.thought)?.map(part => part.text)?.join('\n\n') ?? '';78 return data?.responseContent?.parts?.filter(part => part.thought)?.map(part => part.text)?.join('\n\n') ?? '';
79 case chat_completion_sources.CUSTOM: {
80 return data?.choices?.[0]?.message?.reasoning_content
81 ?? data?.choices?.[0]?.message?.reasoning
82 ?? '';
83 }
79 }84 }
80 break;85 break;
81 }86 }