Enable reasoning parsing for Pollinations and AIML

982dca58ba36bf805c18edddfc605969d50c5cad

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

2 files changed, +3 -1Showing whitespace changes
public/scripts/openai.js+1 -1
@@ -2544,7 +2544,7 @@ export function getStreamingReply(data, state, { chatCompletionSource = null, ov
2544 state.reasoning += (data.choices?.filter(x => x?.delta?.reasoning)?.[0]?.delta?.reasoning || '');2544 state.reasoning += (data.choices?.filter(x => x?.delta?.reasoning)?.[0]?.delta?.reasoning || '');
2545 }2545 }
2546 return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';2546 return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';
2547 } else if (chat_completion_source === chat_completion_sources.CUSTOM) {2547 } else if ([chat_completion_sources.CUSTOM, chat_completion_sources.POLLINATIONS, chat_completion_sources.AIMLAPI].includes(chat_completion_source)) {
2548 if (show_thoughts) {2548 if (show_thoughts) {
2549 state.reasoning +=2549 state.reasoning +=
2550 data.choices?.filter(x => x?.delta?.reasoning_content)?.[0]?.delta?.reasoning_content ??2550 data.choices?.filter(x => x?.delta?.reasoning_content)?.[0]?.delta?.reasoning_content ??
public/scripts/reasoning.js+2 -0
@@ -118,6 +118,8 @@ export function extractReasoningFromData(data, {
118 return data?.responseContent?.parts?.filter(part => part.thought)?.map(part => part.text)?.join('\n\n') ?? '';118 return data?.responseContent?.parts?.filter(part => part.thought)?.map(part => part.text)?.join('\n\n') ?? '';
119 case chat_completion_sources.CLAUDE:119 case chat_completion_sources.CLAUDE:
120 return data?.content?.find(part => part.type === 'thinking')?.thinking ?? '';120 return data?.content?.find(part => part.type === 'thinking')?.thinking ?? '';
121 case chat_completion_sources.AIMLAPI:
122 case chat_completion_sources.POLLINATIONS:
121 case chat_completion_sources.CUSTOM: {123 case chat_completion_sources.CUSTOM: {
122 return data?.choices?.[0]?.message?.reasoning_content124 return data?.choices?.[0]?.message?.reasoning_content
123 ?? data?.choices?.[0]?.message?.reasoning125 ?? data?.choices?.[0]?.message?.reasoning