Merge branch 'staging' into text-completion-include-reasoning

7d937b36daef6117f9388aaa5aa8af046107db66

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

5 files changed, +41 -14Ignore whitespace
public/script.js+8 -6
@@ -2003,7 +2003,7 @@ export function messageFormatting(mes, ch_name, isSystem, isUser, messageId, san
20032003 return '';
20042004 }
20052005
20062006 if (Number(messageId) === 0 && !isSystem && !isUser && !isReasoning) {
20072007 const mesBeforeReplace = mes;
20082008 const chatMessage = chat[messageId];
20092009 mes = substituteParams(mes, undefined, ch_name);
@@ -3171,7 +3171,7 @@ class StreamingProcessor {
31713171 this.sendTextarea.dispatchEvent(new Event('input', { bubbles: true }));
31723172 }
31733173 else {
31743174 await saveReply(this.type, text, true, '', [], '');
31753175 messageId = chat.length - 1;
31763176 this.#checkDomElements(messageId);
31773177 this.showMessageButtons(messageId);
@@ -3365,7 +3365,7 @@ class StreamingProcessor {
33653365 const timestamps = [];
33663366 for await (const { text, swipes, logprobs, toolCalls, state } of this.generator()) {
33673367 timestamps.push(Date.now());
33683368 if (this.isStopped || this.abortController.signal.aborted) {
33693369 return;
33703370 }
33713371
@@ -3863,10 +3863,8 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
38633863
38643864 const reasoning = new PromptReasoning();
38653865 for (let i = coreChat.length - 1; i >= 0; i--) {
3866- if (reasoning.isLimitReached()) {
3867- break;
3868- }
38693866 const depth = coreChat.length - i - 1;
3867+ const isPrefix = isContinue && i === coreChat.length - 1;
38703868 coreChat[i] = {
38713869 ...coreChat[i],
38723870 mes: reasoning.addToMessage(
@@ -3876,8 +3874,12 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
38763874 regex_placement.REASONING,
38773875 { isPrompt: true, depth: depth },
38783876 ),
3877+ isPrefix,
38793878 ),
38803879 };
3880+ if (reasoning.isLimitReached()) {
3881+ break;
3882+ }
38813883 }
38823884
38833885 // Determine token limit
public/scripts/backgrounds.js+14 -4
@@ -96,8 +96,13 @@ function highlightLockedBackground() {
9696 });
9797}
9898
99+/**
100+ * Locks the background for the current chat
101+ * @param {Event} e Click event
102+ * @returns {string} Empty string
103+ */
99104function onLockBackgroundClick(e) {
100105 e?.stopPropagation();
101106
102107 const chatName = getCurrentChatId();
103108
@@ -114,8 +119,13 @@ function onLockBackgroundClick(e) {
114119 return '';
115120}
116121
122+/**
123+ * Locks the background for the current chat
124+ * @param {Event} e Click event
125+ * @returns {string} Empty string
126+ */
117127function onUnlockBackgroundClick(e) {
118128 e?.stopPropagation();
119129 removeBackgroundMetadata();
120130 unsetCustomBackground();
121131 highlightLockedBackground();
@@ -513,12 +523,12 @@ export function initBackgrounds() {
513523 $('#add_bg_button').on('change', onBackgroundUploadSelected);
514524 $('#bg-filter').on('input', onBackgroundFilterInput);
515525 SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'lockbg',
516- callback: onLockBackgroundClick,
526+ callback: () => onLockBackgroundClick(new CustomEvent('click')),
517527 aliases: ['bglock'],
518528 helpString: 'Locks a background for the currently selected chat',
519529 }));
520530 SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'unlockbg',
521- callback: onUnlockBackgroundClick,
531+ callback: () => onUnlockBackgroundClick(new CustomEvent('click')),
522532 aliases: ['bgunlock'],
523533 helpString: 'Unlocks a background for the currently selected chat',
524534 }));
public/scripts/reasoning.js+12 -3
@@ -50,11 +50,12 @@ export class PromptReasoning {
5050 * Add reasoning to a message according to the power user settings.
5151 * @param {string} content Message content
5252 * @param {string} reasoning Message reasoning
53+ * @param {boolean} isPrefix Whether this is the last message prefix
5354 * @returns {string} Message content with reasoning
5455 */
5556 addToMessage(content, reasoning, isPrefix) {
5657 // Disabled or reached limit of additions
5758 if (!isPrefix && (!power_user.reasoning.add_to_prompts || this.counter >= power_user.reasoning.max_additions)) {
5859 return content;
5960 }
6061
@@ -71,6 +72,11 @@ export class PromptReasoning {
7172 const separator = substituteParams(power_user.reasoning.separator || '');
7273 const suffix = substituteParams(power_user.reasoning.suffix || '');
7374
75+ // Combine parts with reasoning only
76+ if (isPrefix && !content) {
77+ return `${prefix}${reasoning}`;
78+ }
79+
7480 // Combine parts with reasoning and content
7581 return `${prefix}${reasoning}${suffix}${separator}${content}`;
7682 }
@@ -117,6 +123,7 @@ function loadReasoningSettings() {
117123function registerReasoningSlashCommands() {
118124 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
119125 name: 'reasoning-get',
126+ aliases: ['get-reasoning'],
120127 returns: ARGUMENT_TYPE.STRING,
121128 helpString: t`Get the contents of a reasoning block of a message. Returns an empty string if the message does not have a reasoning block.`,
122129 unnamedArgumentList: [
@@ -136,6 +143,7 @@ function registerReasoningSlashCommands() {
136143
137144 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
138145 name: 'reasoning-set',
146+ aliases: ['set-reasoning'],
139147 returns: ARGUMENT_TYPE.STRING,
140148 helpString: t`Set the reasoning block of a message. Returns the reasoning block content.`,
141149 namedArgumentList: [
@@ -170,6 +178,7 @@ function registerReasoningSlashCommands() {
170178
171179 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
172180 name: 'reasoning-parse',
181+ aliases: ['parse-reasoning'],
173182 returns: 'reasoning string',
174183 helpString: t`Extracts the reasoning block from a string using the Reasoning Formatting settings.`,
175184 namedArgumentList: [
@@ -218,7 +227,7 @@ function registerReasoningMacros() {
218227 MacrosParser.registerMacro('reasoningSeparator', () => power_user.reasoning.separator, t`Reasoning Separator`);
219228}
220229
221230function setReasoningEventHandlers() {
222231 $(document).on('click', '.mes_reasoning_copy', (e) => {
223232 e.stopPropagation();
224233 e.preventDefault();
public/scripts/textgen-models.js+6 -0
@@ -54,6 +54,12 @@ const OPENROUTER_PROVIDERS = [
5454 'xAI',
5555 'Cloudflare',
5656 'SF Compute',
57+ 'Minimax',
58+ 'Nineteen',
59+ 'Liquid',
60+ 'Nebius',
61+ 'Chutes',
62+ 'Kluster',
5763 '01.AI',
5864 'HuggingFace',
5965 'Mancer',
src/endpoints/stable-diffusion.js+1 -1
@@ -533,6 +533,7 @@ comfy.post('/delete-workflow', jsonParser, async (request, response) => {
533533
534534comfy.post('/generate', jsonParser, async (request, response) => {
535535 try {
536+ let item;
536537 const url = new URL(urlJoin(request.body.url, '/prompt'));
537538
538539 const controller = new AbortController();
@@ -557,7 +558,6 @@ comfy.post('/generate', jsonParser, async (request, response) => {
557558 /** @type {any} */
558559 const data = await promptResult.json();
559560 const id = data.prompt_id;
560- let item;
561561 const historyUrl = new URL(urlJoin(request.body.url, '/history'));
562562 while (true) {
563563 const result = await fetch(historyUrl);