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

This commit is contained in:
Cohee
2025-02-22 13:49:36 +02:00
8 changed files with 61 additions and 29 deletions

View File

@ -0,0 +1,13 @@
These are master copies of the default content files and are managed by SillyTavern.
Editing any of these files would not only have no effect, but will also cause merge conflicts during update pulls.
You should edit their respective copies instead, for example:
1. /default/config.yaml => /config.yaml
2. /default/public/css/user.css => /public/css/user.css
etc.
Any questions? You're always welcome at our official documentation website:
https://docs.sillytavern.app/

View File

@ -2000,7 +2000,7 @@
</span> </span>
</div> </div>
</div> </div>
<div class="range-block" data-source="deepseek,openrouter"> <div class="range-block" data-source="deepseek,openrouter,custom">
<label for="openai_show_thoughts" class="checkbox_label widthFreeExpand"> <label for="openai_show_thoughts" class="checkbox_label widthFreeExpand">
<input id="openai_show_thoughts" type="checkbox" /> <input id="openai_show_thoughts" type="checkbox" />
<span> <span>
@ -3253,6 +3253,10 @@
<option value="sonar">sonar</option> <option value="sonar">sonar</option>
<option value="sonar-pro">sonar-pro</option> <option value="sonar-pro">sonar-pro</option>
<option value="sonar-reasoning">sonar-reasoning</option> <option value="sonar-reasoning">sonar-reasoning</option>
<option value="sonar-reasoning-pro">sonar-reasoning-pro</option>
</optgroup>
<optgroup label="Offline Models">
<option value="r1-1776">r1-1776</option>
</optgroup> </optgroup>
<optgroup label="Deprecated Models"> <optgroup label="Deprecated Models">
<!-- These are scheduled for deprecation after 2/22/2025 --> <!-- These are scheduled for deprecation after 2/22/2025 -->

View File

@ -1487,7 +1487,7 @@ jQuery(function () {
...chat.filter(x => x?.extra?.type !== system_message_types.ASSISTANT_NOTE), ...chat.filter(x => x?.extra?.type !== system_message_types.ASSISTANT_NOTE),
]; ];
download(JSON.stringify(chatToSave, null, 4), `Assistant - ${humanizedDateTime()}.json`, 'application/json'); download(chatToSave.map((m) => JSON.stringify(m)).join('\n'), `Assistant - ${humanizedDateTime()}.jsonl`, 'application/json');
}); });
// Do not change. #attachFile is added by extension. // Do not change. #attachFile is added by extension.

View File

@ -2167,6 +2167,14 @@ function getStreamingReply(data, state) {
state.reasoning += (data.choices?.filter(x => x?.delta?.reasoning)?.[0]?.delta?.reasoning || ''); state.reasoning += (data.choices?.filter(x => x?.delta?.reasoning)?.[0]?.delta?.reasoning || '');
} }
return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? ''; return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';
} else if (oai_settings.chat_completion_source === chat_completion_sources.CUSTOM) {
if (oai_settings.show_thoughts) {
state.reasoning +=
data.choices?.filter(x => x?.delta?.reasoning_content)?.[0]?.delta?.reasoning_content ??
data.choices?.filter(x => x?.delta?.reasoning)?.[0]?.delta?.reasoning ??
'';
}
return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';
} else { } else {
return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? ''; return data.choices?.[0]?.delta?.content ?? data.choices?.[0]?.message?.content ?? data.choices?.[0]?.text ?? '';
} }
@ -4387,7 +4395,7 @@ async function onModelChange() {
if (oai_settings.max_context_unlocked) { if (oai_settings.max_context_unlocked) {
$('#openai_max_context').attr('max', unlocked_max); $('#openai_max_context').attr('max', unlocked_max);
} }
else if (['sonar', 'sonar-reasoning'].includes(oai_settings.perplexity_model)) { else if (['sonar', 'sonar-reasoning', 'sonar-reasoning-pro', 'r1-1776'].includes(oai_settings.perplexity_model)) {
$('#openai_max_context').attr('max', 127000); $('#openai_max_context').attr('max', 127000);
} }
else if (['sonar-pro'].includes(oai_settings.perplexity_model)) { else if (['sonar-pro'].includes(oai_settings.perplexity_model)) {

View File

@ -76,6 +76,11 @@ export function extractReasoningFromData(data) {
return data?.choices?.[0]?.message?.reasoning ?? ''; return data?.choices?.[0]?.message?.reasoning ?? '';
case chat_completion_sources.MAKERSUITE: case chat_completion_sources.MAKERSUITE:
return data?.responseContent?.parts?.filter(part => part.thought)?.map(part => part.text)?.join('\n\n') ?? ''; return data?.responseContent?.parts?.filter(part => part.thought)?.map(part => part.text)?.join('\n\n') ?? '';
case chat_completion_sources.CUSTOM: {
return data?.choices?.[0]?.message?.reasoning_content
?? data?.choices?.[0]?.message?.reasoning
?? '';
}
} }
break; break;
} }
@ -338,14 +343,15 @@ export class ReasoningHandler {
return mesChanged; return mesChanged;
} }
if (this.state === ReasoningState.None) { if (this.state === ReasoningState.None || this.#isHiddenReasoningModel) {
// If streamed message starts with the opening, cut it out and put all inside reasoning // If streamed message starts with the opening, cut it out and put all inside reasoning
if (message.mes.startsWith(power_user.reasoning.prefix) && message.mes.length > power_user.reasoning.prefix.length) { if (message.mes.startsWith(power_user.reasoning.prefix) && message.mes.length > power_user.reasoning.prefix.length) {
this.#isParsingReasoning = true; this.#isParsingReasoning = true;
// Manually set starting state here, as we might already have received the ending suffix // Manually set starting state here, as we might already have received the ending suffix
this.state = ReasoningState.Thinking; this.state = ReasoningState.Thinking;
this.startTime = this.initialTime; this.startTime = this.startTime ?? this.initialTime;
this.endTime = null;
} }
} }

View File

@ -679,7 +679,7 @@ export function getTokenizerModel() {
} }
if (oai_settings.chat_completion_source === chat_completion_sources.PERPLEXITY) { if (oai_settings.chat_completion_source === chat_completion_sources.PERPLEXITY) {
if (oai_settings.perplexity_model.includes('sonar-reasoning')) { if (oai_settings.perplexity_model.includes('sonar-reasoning') || oai_settings.perplexity_model.includes('r1-1776')) {
return deepseekTokenizer; return deepseekTokenizer;
} }
if (oai_settings.perplexity_model.includes('llama-3') || oai_settings.perplexity_model.includes('llama3')) { if (oai_settings.perplexity_model.includes('llama-3') || oai_settings.perplexity_model.includes('llama3')) {

View File

@ -55,6 +55,10 @@
--interactable-outline-color: var(--white100); --interactable-outline-color: var(--white100);
--interactable-outline-color-faint: var(--white20a); --interactable-outline-color-faint: var(--white20a);
--reasoning-body-color: var(--SmartThemeEmColor);
--reasoning-em-color: color-mix(in srgb, var(--SmartThemeEmColor) 67%, var(--SmartThemeBlurTintColor) 33%);
--reasoning-saturation: 0.5;
/*Default Theme, will be changed by ToolCool Color Picker*/ /*Default Theme, will be changed by ToolCool Color Picker*/
--SmartThemeBodyColor: rgb(220, 220, 210); --SmartThemeBodyColor: rgb(220, 220, 210);
@ -348,13 +352,13 @@ input[type='checkbox']:focus-visible {
.mes_reasoning { .mes_reasoning {
display: block; display: block;
border-left: 2px solid var(--SmartThemeEmColor); border-left: 2px solid var(--reasoning-body-color);
border-radius: 2px; border-radius: 2px;
padding: 5px; padding: 5px;
padding-left: 14px; padding-left: 14px;
margin-bottom: 0.5em; margin-bottom: 0.5em;
overflow-y: auto; overflow-y: auto;
color: var(--SmartThemeEmColor); color: hsl(from var(--reasoning-body-color) h calc(s * var(--reasoning-saturation)) l);
} }
.mes_reasoning_details { .mes_reasoning_details {
@ -374,18 +378,6 @@ input[type='checkbox']:focus-visible {
margin-bottom: 0; margin-bottom: 0;
} }
.mes_reasoning em,
.mes_reasoning i,
.mes_reasoning u,
.mes_reasoning q,
.mes_reasoning blockquote {
filter: saturate(0.5);
}
.mes_reasoning_details .mes_reasoning em {
color: color-mix(in srgb, var(--SmartThemeEmColor) 67%, var(--SmartThemeBlurTintColor) 33%);
}
.mes_reasoning_header_block { .mes_reasoning_header_block {
flex-grow: 1; flex-grow: 1;
} }
@ -461,26 +453,36 @@ input[type='checkbox']:focus-visible {
} }
.mes_text i, .mes_text i,
.mes_text em, .mes_text em {
color: var(--SmartThemeEmColor);
}
.mes_reasoning i, .mes_reasoning i,
.mes_reasoning em { .mes_reasoning em {
color: var(--SmartThemeEmColor); color: hsl(from var(--reasoning-em-color) h calc(s * var(--reasoning-saturation)) l);
} }
.mes_text q i, .mes_text q i,
.mes_text q em { .mes_text q em {
color: inherit; color: inherit;
} }
.mes_reasoning q i,
.mes_text u, .mes_reasoning q em {
.mes_reasoning u { color: hsl(from var(--SmartThemeQuoteColor) h calc(s * var(--reasoning-saturation)) l);
color: var(--SmartThemeUnderlineColor);
} }
.mes_text q, .mes_text u {
.mes_reasoning q { color: var(--SmartThemeUnderlineColor);
}
.mes_reasoning u {
color: hsl(from var(--SmartThemeUnderlineColor) h calc(s * var(--reasoning-saturation)) l);
}
.mes_text q {
color: var(--SmartThemeQuoteColor); color: var(--SmartThemeQuoteColor);
} }
.mes_reasoning q {
color: hsl(from var(--SmartThemeQuoteColor) h calc(s * var(--reasoning-saturation)) l);
}
.mes_text font[color] em, .mes_text font[color] em,
.mes_text font[color] i, .mes_text font[color] i,

View File

@ -244,7 +244,6 @@ const cliArguments = yargs(hideBin(process.argv))
describe: 'Request proxy URL (HTTP or SOCKS protocols)', describe: 'Request proxy URL (HTTP or SOCKS protocols)',
}).option('requestProxyBypass', { }).option('requestProxyBypass', {
type: 'array', type: 'array',
default: null,
describe: 'Request proxy bypass list (space separated list of hosts)', describe: 'Request proxy bypass list (space separated list of hosts)',
}).parseSync(); }).parseSync();