Merge branch 'staging' into feature/access-log-middleware

b12cd9fe057c7e8b4666e107ca5a8befc853e1b9

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

8 files changed, +59 -27Ignore whitespace
default/!DO-NOT-EDIT-THESE-FILES.txt+13 -0
@@ -0,0 +1,13 @@
1+These are master copies of the default content files and are managed by SillyTavern.
2+
3+Editing any of these files would not only have no effect, but will also cause merge conflicts during update pulls.
4+
5+You should edit their respective copies instead, for example:
6+
7+1. /default/config.yaml => /config.yaml
8+2. /default/public/css/user.css => /public/css/user.css
9+etc.
10+
11+Any questions? You're always welcome at our official documentation website:
12+
13+https://docs.sillytavern.app/
public/index.html+5 -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>
@@ -3253,6 +3253,10 @@
32533253 <option value="sonar">sonar</option>
32543254 <option value="sonar-pro">sonar-pro</option>
32553255 <option value="sonar-reasoning">sonar-reasoning</option>
3256+ <option value="sonar-reasoning-pro">sonar-reasoning-pro</option>
3257+ </optgroup>
3258+ <optgroup label="Offline Models">
3259+ <option value="r1-1776">r1-1776</option>
32563260 </optgroup>
32573261 <optgroup label="Deprecated Models">
32583262 <!-- These are scheduled for deprecation after 2/22/2025 -->
public/scripts/chats.js+1 -1
@@ -1487,7 +1487,7 @@ jQuery(function () {
14871487 ...chat.filter(x => x?.extra?.type !== system_message_types.ASSISTANT_NOTE),
14881488 ];
14891489
14901490 download(JSONchatToSave.stringifymap(chatToSave,(m) null,=> 4JSON.stringify(m)).join('\n'), `Assistant - ${humanizedDateTime()}.jsonjsonl`, 'application/json');
14911491 });
14921492
14931493 // Do not change. #attachFile is added by extension.
public/scripts/openai.js+9 -1
@@ -2167,6 +2167,14 @@ 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 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 ?? '';
21702178 } else {
21712179 return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';
21722180 }
@@ -4387,7 +4395,7 @@ async function onModelChange() {
43874395 if (oai_settings.max_context_unlocked) {
43884396 $('#openai_max_context').attr('max', unlocked_max);
43894397 }
43904398 else if (['sonar', 'sonar-reasoning', 'sonar-reasoning-pro', 'r1-1776'].includes(oai_settings.perplexity_model)) {
43914399 $('#openai_max_context').attr('max', 127000);
43924400 }
43934401 else if (['sonar-pro'].includes(oai_settings.perplexity_model)) {
public/scripts/reasoning.js+8 -2
@@ -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 }
@@ -338,14 +343,15 @@ export class ReasoningHandler {
338343 return mesChanged;
339344 }
340345
341346 if (this.state === ReasoningState.None || this.#isHiddenReasoningModel) {
342347 // If streamed message starts with the opening, cut it out and put all inside reasoning
343348 if (message.mes.startsWith(power_user.reasoning.prefix) && message.mes.length > power_user.reasoning.prefix.length) {
344349 this.#isParsingReasoning = true;
345350
346351 // Manually set starting state here, as we might already have received the ending suffix
347352 this.state = ReasoningState.Thinking;
348353 this.startTime = this.startTime ?? this.initialTime;
354+ this.endTime = null;
349355 }
350356 }
351357
public/scripts/tokenizers.js+1 -1
@@ -679,7 +679,7 @@ export function getTokenizerModel() {
679679 }
680680
681681 if (oai_settings.chat_completion_source === chat_completion_sources.PERPLEXITY) {
682682 if (oai_settings.perplexity_model.includes('sonar-reasoning') || oai_settings.perplexity_model.includes('r1-1776')) {
683683 return deepseekTokenizer;
684684 }
685685 if (oai_settings.perplexity_model.includes('llama-3') || oai_settings.perplexity_model.includes('llama3')) {
public/style.css+22 -20
@@ -55,6 +55,10 @@
5555 --interactable-outline-color: var(--white100);
5656 --interactable-outline-color-faint: var(--white20a);
5757
58+ --reasoning-body-color: var(--SmartThemeEmColor);
59+ --reasoning-em-color: color-mix(in srgb, var(--SmartThemeEmColor) 67%, var(--SmartThemeBlurTintColor) 33%);
60+ --reasoning-saturation: 0.5;
61+
5862
5963 /*Default Theme, will be changed by ToolCool Color Picker*/
6064 --SmartThemeBodyColor: rgb(220, 220, 210);
@@ -348,13 +352,13 @@ input[type='checkbox']:focus-visible {
348352
349353.mes_reasoning {
350354 display: block;
351355 border-left: 2px solid var(--SmartThemeEmColorreasoning-body-color);
352356 border-radius: 2px;
353357 padding: 5px;
354358 padding-left: 14px;
355359 margin-bottom: 0.5em;
356360 overflow-y: auto;
357- color: var(--SmartThemeEmColor);
361+ color: hsl(from var(--reasoning-body-color) h calc(s * var(--reasoning-saturation)) l);
358362}
359363
360364.mes_reasoning_details {
@@ -374,18 +378,6 @@ input[type='checkbox']:focus-visible {
374378 margin-bottom: 0;
375379}
376380
377-.mes_reasoning em,
378-.mes_reasoning i,
379-.mes_reasoning u,
380-.mes_reasoning q,
381-.mes_reasoning blockquote {
382- filter: saturate(0.5);
383-}
384-
385-.mes_reasoning_details .mes_reasoning em {
386- color: color-mix(in srgb, var(--SmartThemeEmColor) 67%, var(--SmartThemeBlurTintColor) 33%);
387-}
388-
389381.mes_reasoning_header_block {
390382 flex-grow: 1;
391383}
@@ -461,26 +453,36 @@ input[type='checkbox']:focus-visible {
461453}
462454
463455.mes_text i,
464456.mes_text em, {
457+ color: var(--SmartThemeEmColor);
458+}
465459.mes_reasoning i,
466460.mes_reasoning em {
467- color: var(--SmartThemeEmColor);
461+ color: hsl(from var(--reasoning-em-color) h calc(s * var(--reasoning-saturation)) l);
468462}
469463
470464.mes_text q i,
471465.mes_text q em {
472466 color: inherit;
473467}
468+.mes_reasoning q i,
469+.mes_reasoning q em {
470+ color: hsl(from var(--SmartThemeQuoteColor) h calc(s * var(--reasoning-saturation)) l);
471+}
474472
475473.mes_text u, {
476-.mes_reasoning u {
477474 color: var(--SmartThemeUnderlineColor);
478475}
476+.mes_reasoning u {
477+ color: hsl(from var(--SmartThemeUnderlineColor) h calc(s * var(--reasoning-saturation)) l);
478+}
479479
480480.mes_text q, {
481-.mes_reasoning q {
482481 color: var(--SmartThemeQuoteColor);
483482}
483+.mes_reasoning q {
484+ color: hsl(from var(--SmartThemeQuoteColor) h calc(s * var(--reasoning-saturation)) l);
485+}
484486
485487.mes_text font[color] em,
486488.mes_text font[color] i,
server.js+0 -1
@@ -244,7 +244,6 @@ const cliArguments = yargs(hideBin(process.argv))
244244 describe: 'Request proxy URL (HTTP or SOCKS protocols)',
245245 }).option('requestProxyBypass', {
246246 type: 'array',
247- default: null,
248247 describe: 'Request proxy bypass list (space separated list of hosts)',
249248 }).parseSync();
250249