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 @@
1These are master copies of the default content files and are managed by SillyTavern.
2
3Editing any of these files would not only have no effect, but will also cause merge conflicts during update pulls.
4
5You should edit their respective copies instead, for example:
6
71. /default/config.yaml => /config.yaml
82. /default/public/css/user.css => /public/css/user.css
9etc.
10
11Any questions? You're always welcome at our official documentation website:
12
13https://docs.sillytavern.app/
public/index.html+5 -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>
@@ -3253,6 +3253,10 @@
3253 <option value="sonar">sonar</option>3253 <option value="sonar">sonar</option>
3254 <option value="sonar-pro">sonar-pro</option>3254 <option value="sonar-pro">sonar-pro</option>
3255 <option value="sonar-reasoning">sonar-reasoning</option>3255 <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>
3256 </optgroup>3260 </optgroup>
3257 <optgroup label="Deprecated Models">3261 <optgroup label="Deprecated Models">
3258 <!-- These are scheduled for deprecation after 2/22/2025 -->3262 <!-- These are scheduled for deprecation after 2/22/2025 -->
public/scripts/chats.js+1 -1
@@ -1487,7 +1487,7 @@ jQuery(function () {
1487 ...chat.filter(x => x?.extra?.type !== system_message_types.ASSISTANT_NOTE),1487 ...chat.filter(x => x?.extra?.type !== system_message_types.ASSISTANT_NOTE),
1488 ];1488 ];
14891489
1490 download(JSON.stringify(chatToSave, null, 4), `Assistant - ${humanizedDateTime()}.json`, 'application/json');1490 download(chatToSave.map((m) => JSON.stringify(m)).join('\n'), `Assistant - ${humanizedDateTime()}.jsonl`, 'application/json');
1491 });1491 });
14921492
1493 // Do not change. #attachFile is added by extension.1493 // Do not change. #attachFile is added by extension.
public/scripts/openai.js+9 -1
@@ -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 }
@@ -4387,7 +4395,7 @@ async function onModelChange() {
4387 if (oai_settings.max_context_unlocked) {4395 if (oai_settings.max_context_unlocked) {
4388 $('#openai_max_context').attr('max', unlocked_max);4396 $('#openai_max_context').attr('max', unlocked_max);
4389 }4397 }
4390 else if (['sonar', 'sonar-reasoning'].includes(oai_settings.perplexity_model)) {4398 else if (['sonar', 'sonar-reasoning', 'sonar-reasoning-pro', 'r1-1776'].includes(oai_settings.perplexity_model)) {
4391 $('#openai_max_context').attr('max', 127000);4399 $('#openai_max_context').attr('max', 127000);
4392 }4400 }
4393 else if (['sonar-pro'].includes(oai_settings.perplexity_model)) {4401 else if (['sonar-pro'].includes(oai_settings.perplexity_model)) {
public/scripts/reasoning.js+8 -2
@@ -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 }
@@ -338,14 +343,15 @@ export class ReasoningHandler {
338 return mesChanged;343 return mesChanged;
339 }344 }
340345
341 if (this.state === ReasoningState.None) {346 if (this.state === ReasoningState.None || this.#isHiddenReasoningModel) {
342 // If streamed message starts with the opening, cut it out and put all inside reasoning347 // If streamed message starts with the opening, cut it out and put all inside reasoning
343 if (message.mes.startsWith(power_user.reasoning.prefix) && message.mes.length > power_user.reasoning.prefix.length) {348 if (message.mes.startsWith(power_user.reasoning.prefix) && message.mes.length > power_user.reasoning.prefix.length) {
344 this.#isParsingReasoning = true;349 this.#isParsingReasoning = true;
345350
346 // Manually set starting state here, as we might already have received the ending suffix351 // Manually set starting state here, as we might already have received the ending suffix
347 this.state = ReasoningState.Thinking;352 this.state = ReasoningState.Thinking;
348 this.startTime = this.initialTime;353 this.startTime = this.startTime ?? this.initialTime;
354 this.endTime = null;
349 }355 }
350 }356 }
351357
public/scripts/tokenizers.js+1 -1
@@ -679,7 +679,7 @@ export function getTokenizerModel() {
679 }679 }
680680
681 if (oai_settings.chat_completion_source === chat_completion_sources.PERPLEXITY) {681 if (oai_settings.chat_completion_source === chat_completion_sources.PERPLEXITY) {
682 if (oai_settings.perplexity_model.includes('sonar-reasoning')) {682 if (oai_settings.perplexity_model.includes('sonar-reasoning') || oai_settings.perplexity_model.includes('r1-1776')) {
683 return deepseekTokenizer;683 return deepseekTokenizer;
684 }684 }
685 if (oai_settings.perplexity_model.includes('llama-3') || oai_settings.perplexity_model.includes('llama3')) {685 if (oai_settings.perplexity_model.includes('llama-3') || oai_settings.perplexity_model.includes('llama3')) {
public/style.css+22 -20
@@ -55,6 +55,10 @@
55 --interactable-outline-color: var(--white100);55 --interactable-outline-color: var(--white100);
56 --interactable-outline-color-faint: var(--white20a);56 --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
59 /*Default Theme, will be changed by ToolCool Color Picker*/63 /*Default Theme, will be changed by ToolCool Color Picker*/
60 --SmartThemeBodyColor: rgb(220, 220, 210);64 --SmartThemeBodyColor: rgb(220, 220, 210);
@@ -348,13 +352,13 @@ input[type='checkbox']:focus-visible {
348352
349.mes_reasoning {353.mes_reasoning {
350 display: block;354 display: block;
351 border-left: 2px solid var(--SmartThemeEmColor);355 border-left: 2px solid var(--reasoning-body-color);
352 border-radius: 2px;356 border-radius: 2px;
353 padding: 5px;357 padding: 5px;
354 padding-left: 14px;358 padding-left: 14px;
355 margin-bottom: 0.5em;359 margin-bottom: 0.5em;
356 overflow-y: auto;360 overflow-y: auto;
357 color: var(--SmartThemeEmColor);361 color: hsl(from var(--reasoning-body-color) h calc(s * var(--reasoning-saturation)) l);
358}362}
359363
360.mes_reasoning_details {364.mes_reasoning_details {
@@ -374,18 +378,6 @@ input[type='checkbox']:focus-visible {
374 margin-bottom: 0;378 margin-bottom: 0;
375}379}
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
389.mes_reasoning_header_block {381.mes_reasoning_header_block {
390 flex-grow: 1;382 flex-grow: 1;
391}383}
@@ -461,26 +453,36 @@ input[type='checkbox']:focus-visible {
461}453}
462454
463.mes_text i,455.mes_text i,
464.mes_text em,456.mes_text em {
457 color: var(--SmartThemeEmColor);
458}
465.mes_reasoning i,459.mes_reasoning i,
466.mes_reasoning em {460.mes_reasoning em {
467 color: var(--SmartThemeEmColor);461 color: hsl(from var(--reasoning-em-color) h calc(s * var(--reasoning-saturation)) l);
468}462}
469463
470.mes_text q i,464.mes_text q i,
471.mes_text q em {465.mes_text q em {
472 color: inherit;466 color: inherit;
473}467}
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
475.mes_text u,473.mes_text u {
476.mes_reasoning u {
477 color: var(--SmartThemeUnderlineColor);474 color: var(--SmartThemeUnderlineColor);
478}475}
476.mes_reasoning u {
477 color: hsl(from var(--SmartThemeUnderlineColor) h calc(s * var(--reasoning-saturation)) l);
478}
479479
480.mes_text q,480.mes_text q {
481.mes_reasoning q {
482 color: var(--SmartThemeQuoteColor);481 color: var(--SmartThemeQuoteColor);
483}482}
483.mes_reasoning q {
484 color: hsl(from var(--SmartThemeQuoteColor) h calc(s * var(--reasoning-saturation)) l);
485}
484486
485.mes_text font[color] em,487.mes_text font[color] em,
486.mes_text font[color] i,488.mes_text font[color] i,
server.js+0 -1
@@ -244,7 +244,6 @@ const cliArguments = yargs(hideBin(process.argv))
244 describe: 'Request proxy URL (HTTP or SOCKS protocols)',244 describe: 'Request proxy URL (HTTP or SOCKS protocols)',
245 }).option('requestProxyBypass', {245 }).option('requestProxyBypass', {
246 type: 'array',246 type: 'array',
247 default: null,
248 describe: 'Request proxy bypass list (space separated list of hosts)',247 describe: 'Request proxy bypass list (space separated list of hosts)',
249 }).parseSync();248 }).parseSync();
250249