reasoning or reasoning_content

13f76c974ea4361da5ef40a8245e1fd078d79065

yokuminto <yokuminto@qq.com>

3 files changed, +15 -2Ignore whitespace
public/index.html+1 -1
@@ -2000,7 +2000,7 @@
20002000 </span>
20012001 </div>
20022002 </div>
20032003 <div class="range-block" data-source="deepseek,openrouter,custom">
20042004 <label for="openai_show_thoughts" class="checkbox_label widthFreeExpand">
20052005 <input id="openai_show_thoughts" type="checkbox" />
20062006 <span>
public/scripts/openai.js+9 -1
@@ -2167,7 +2167,15 @@ function getStreamingReply(data, state) {
21672167 state.reasoning += (data.choices?.filter(x => x?.delta?.reasoning)?.[0]?.delta?.reasoning || '');
21682168 }
21692169 return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';
2170- } else {
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 ?? '';
2178+ }else{
21712179 return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';
21722180 }
21732181}
public/scripts/reasoning.js+5 -0
@@ -76,6 +76,11 @@ export function extractReasoningFromData(data) {
7676 return data?.choices?.[0]?.message?.reasoning ?? '';
7777 case chat_completion_sources.MAKERSUITE:
7878 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+ }
7984 }
8085 break;
8186 }