From bad806312dcf530ceb5d65edd9c0558a4e7c810e Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Wed, 19 Feb 2025 23:42:28 +0200 Subject: [PATCH 01/10] Auto-extend session cookie every 30 minutes --- public/scripts/user.js | 26 ++++++++++++++++++++++++++ server.js | 8 +++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/public/scripts/user.js b/public/scripts/user.js index 4aa61967b..705542940 100644 --- a/public/scripts/user.js +++ b/public/scripts/user.js @@ -9,6 +9,9 @@ import { ensureImageFormatSupported, getBase64Async, humanFileSize } from './uti export let currentUser = null; export let accountsEnabled = false; +// Extend the session every 30 minutes +const SESSION_EXTEND_INTERVAL = 30 * 60 * 1000; + /** * Enable or disable user account controls in the UI. * @param {boolean} isEnabled User account controls enabled @@ -894,6 +897,24 @@ async function slugify(text) { } } +/** + * Pings the server to extend the user session. + */ +async function extendUserSession() { + try { + const response = await fetch('/api/ping?extend=1', { + method: 'GET', + headers: getRequestHeaders(), + }); + + if (!response.ok) { + throw new Error('Ping did not succeed', { cause: response.status }); + } + } catch (error) { + console.error('Failed to extend user session', error); + } +} + jQuery(() => { $('#logout_button').on('click', () => { logout(); @@ -904,4 +925,9 @@ jQuery(() => { $('#account_button').on('click', () => { openUserProfile(); }); + setInterval(async () => { + if (currentUser) { + await extendUserSession(); + } + }, SESSION_EXTEND_INTERVAL); }); diff --git a/server.js b/server.js index 18f5cba1a..950907ae8 100644 --- a/server.js +++ b/server.js @@ -556,7 +556,13 @@ app.use('/api/users', usersPublicRouter); // Everything below this line requires authentication app.use(requireLoginMiddleware); -app.get('/api/ping', (_, response) => response.sendStatus(204)); +app.get('/api/ping', (request, response) => { + if (request.query.extend && request.session) { + request.session.touch = Date.now(); + } + + response.sendStatus(204); +}); // File uploads app.use(multer({ dest: uploadsPath, limits: { fieldSize: 10 * 1024 * 1024 } }).single('avatar')); From b17fdcbfd9fdf6e542e83943cc27538a70960113 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 21 Feb 2025 12:46:49 +0000 Subject: [PATCH 02/10] Fix assistant chat export format --- public/scripts/chats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/scripts/chats.js b/public/scripts/chats.js index 042030f2c..a6f2432d2 100644 --- a/public/scripts/chats.js +++ b/public/scripts/chats.js @@ -1487,7 +1487,7 @@ jQuery(function () { ...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. From 29c71fe8f17edfcc37e66a37a2fa723221f63c10 Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Fri, 21 Feb 2025 17:30:56 +0100 Subject: [PATCH 03/10] Update reasoning block coloring to CSS vars --- public/style.css | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/public/style.css b/public/style.css index 6278d9960..3b07f593d 100644 --- a/public/style.css +++ b/public/style.css @@ -55,6 +55,9 @@ --interactable-outline-color: var(--white100); --interactable-outline-color-faint: var(--white20a); + --reasoning-mix-rate: 50%; + --reasoning-mix-color: var(--grey30); + /*Default Theme, will be changed by ToolCool Color Picker*/ --SmartThemeBodyColor: rgb(220, 220, 210); @@ -354,7 +357,7 @@ input[type='checkbox']:focus-visible { padding-left: 14px; margin-bottom: 0.5em; overflow-y: auto; - color: var(--SmartThemeEmColor); + color: color-mix(in srgb, var(--SmartThemeBodyColor) var(--reasoning-mix-rate), var(--reasoning-mix-color)); } .mes_reasoning_details { @@ -374,18 +377,6 @@ input[type='checkbox']:focus-visible { 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 { flex-grow: 1; } @@ -461,26 +452,36 @@ input[type='checkbox']:focus-visible { } .mes_text i, -.mes_text em, +.mes_text em { + color: var(--SmartThemeEmColor); +} .mes_reasoning i, .mes_reasoning em { - color: var(--SmartThemeEmColor); + color: color-mix(in srgb, var(--SmartThemeEmColor) var(--reasoning-mix-rate), var(--reasoning-mix-color)); } .mes_text q i, .mes_text q em { color: inherit; } - -.mes_text u, -.mes_reasoning u { - color: var(--SmartThemeUnderlineColor); +.mes_reasoning q i, +.mes_reasoning q em { + color: color-mix(in srgb, var(--SmartThemeQuoteColor) var(--reasoning-mix-rate), var(--reasoning-mix-color)); } -.mes_text q, -.mes_reasoning q { +.mes_text u { + color: var(--SmartThemeUnderlineColor); +} +.mes_reasoning u { + color: color-mix(in srgb, var(--SmartThemeUnderlineColor) var(--reasoning-mix-rate), var(--reasoning-mix-color)); +} + +.mes_text q { color: var(--SmartThemeQuoteColor); } +.mes_reasoning q { + color: color-mix(in srgb, var(--SmartThemeQuoteColor) var(--reasoning-mix-rate), var(--reasoning-mix-color)); +} .mes_text font[color] em, .mes_text font[color] i, From b0a2f241d20a826ef2e5c3d0cf8e3c88151cb4af Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Fri, 21 Feb 2025 18:01:25 +0100 Subject: [PATCH 04/10] Fix hidden reasoning not allowing manual parsing --- public/scripts/reasoning.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/public/scripts/reasoning.js b/public/scripts/reasoning.js index 44927d83f..2d4711db2 100644 --- a/public/scripts/reasoning.js +++ b/public/scripts/reasoning.js @@ -338,14 +338,15 @@ export class ReasoningHandler { 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 (message.mes.startsWith(power_user.reasoning.prefix) && message.mes.length > power_user.reasoning.prefix.length) { this.#isParsingReasoning = true; // Manually set starting state here, as we might already have received the ending suffix this.state = ReasoningState.Thinking; - this.startTime = this.initialTime; + this.startTime = this.startTime ?? this.initialTime; + this.endTime = null; } } From 0cc0d6763ed95f9a0e331858838aef7f05c39c08 Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Fri, 21 Feb 2025 19:40:36 +0100 Subject: [PATCH 05/10] Use hsl instead of color-mix for reasoning css --- public/style.css | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/public/style.css b/public/style.css index 3b07f593d..bafc9e288 100644 --- a/public/style.css +++ b/public/style.css @@ -55,8 +55,9 @@ --interactable-outline-color: var(--white100); --interactable-outline-color-faint: var(--white20a); - --reasoning-mix-rate: 50%; - --reasoning-mix-color: var(--grey30); + --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*/ @@ -351,13 +352,13 @@ input[type='checkbox']:focus-visible { .mes_reasoning { display: block; - border-left: 2px solid var(--SmartThemeEmColor); + border-left: 2px solid var(--reasoning-body-color); border-radius: 2px; padding: 5px; padding-left: 14px; margin-bottom: 0.5em; overflow-y: auto; - color: color-mix(in srgb, var(--SmartThemeBodyColor) var(--reasoning-mix-rate), var(--reasoning-mix-color)); + color: hsl(from var(--reasoning-body-color) h calc(s * var(--reasoning-saturation)) l); } .mes_reasoning_details { @@ -457,7 +458,7 @@ input[type='checkbox']:focus-visible { } .mes_reasoning i, .mes_reasoning em { - color: color-mix(in srgb, var(--SmartThemeEmColor) var(--reasoning-mix-rate), var(--reasoning-mix-color)); + color: hsl(from var(--reasoning-em-color) h calc(s * var(--reasoning-saturation)) l); } .mes_text q i, @@ -466,21 +467,21 @@ input[type='checkbox']:focus-visible { } .mes_reasoning q i, .mes_reasoning q em { - color: color-mix(in srgb, var(--SmartThemeQuoteColor) var(--reasoning-mix-rate), var(--reasoning-mix-color)); + color: hsl(from var(--SmartThemeQuoteColor) h calc(s * var(--reasoning-saturation)) l); } .mes_text u { color: var(--SmartThemeUnderlineColor); } .mes_reasoning u { - color: color-mix(in srgb, var(--SmartThemeUnderlineColor) var(--reasoning-mix-rate), var(--reasoning-mix-color)); + color: hsl(from var(--SmartThemeUnderlineColor) h calc(s * var(--reasoning-saturation)) l); } .mes_text q { color: var(--SmartThemeQuoteColor); } .mes_reasoning q { - color: color-mix(in srgb, var(--SmartThemeQuoteColor) var(--reasoning-mix-rate), var(--reasoning-mix-color)); + color: hsl(from var(--SmartThemeQuoteColor) h calc(s * var(--reasoning-saturation)) l); } .mes_text font[color] em, From 6e5db5c41ad99bc690bb636d99b787c4747888ee Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 21 Feb 2025 23:03:49 +0200 Subject: [PATCH 06/10] Perplexity: Add new models --- public/index.html | 4 ++++ public/scripts/openai.js | 2 +- public/scripts/tokenizers.js | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/public/index.html b/public/index.html index ea1267429..123c4032d 100644 --- a/public/index.html +++ b/public/index.html @@ -3253,6 +3253,10 @@ + + + + diff --git a/public/scripts/openai.js b/public/scripts/openai.js index 39b3970ad..71b59f93a 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -4387,7 +4387,7 @@ async function onModelChange() { if (oai_settings.max_context_unlocked) { $('#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); } else if (['sonar-pro'].includes(oai_settings.perplexity_model)) { diff --git a/public/scripts/tokenizers.js b/public/scripts/tokenizers.js index 9a4995206..c20ae2706 100644 --- a/public/scripts/tokenizers.js +++ b/public/scripts/tokenizers.js @@ -679,7 +679,7 @@ export function getTokenizerModel() { } 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; } if (oai_settings.perplexity_model.includes('llama-3') || oai_settings.perplexity_model.includes('llama3')) { From d32adb8d1d1a68399bcf92e9cb4942e431b85e2c Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 21 Feb 2025 23:07:33 +0200 Subject: [PATCH 07/10] Fix requestProxyBypass command line default value Closes #3528 --- server.js | 1 - 1 file changed, 1 deletion(-) diff --git a/server.js b/server.js index b83a79235..67d706192 100644 --- a/server.js +++ b/server.js @@ -243,7 +243,6 @@ const cliArguments = yargs(hideBin(process.argv)) describe: 'Request proxy URL (HTTP or SOCKS protocols)', }).option('requestProxyBypass', { type: 'array', - default: null, describe: 'Request proxy bypass list (space separated list of hosts)', }).parseSync(); From 13f76c974ea4361da5ef40a8245e1fd078d79065 Mon Sep 17 00:00:00 2001 From: yokuminto Date: Sat, 22 Feb 2025 16:01:46 +0800 Subject: [PATCH 08/10] reasoning or reasoning_content --- public/index.html | 2 +- public/scripts/openai.js | 10 +++++++++- public/scripts/reasoning.js | 5 +++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/public/index.html b/public/index.html index 123c4032d..d4fc97b5c 100644 --- a/public/index.html +++ b/public/index.html @@ -2000,7 +2000,7 @@ -
+