Remove reasoning from queit prompt results if auto-parse is enabled Fixes #3457
| @@ -269,7 +269,7 @@ import { initSettingsSearch } from './scripts/setting-search.js'; | ||
| 269 | 269 | import { initBulkEdit } from './scripts/bulk-edit.js'; |
| 270 | 270 | import { deriveTemplatesFromChatTemplate } from './scripts/chat-templates.js'; |
| 271 | 271 | import { getContext } from './scripts/st-context.js'; |
| 272 | 272 | import { extractReasoningFromData, initReasoning, PromptReasoning, removeReasoningFromString, updateReasoningTimeUI } from './scripts/reasoning.js'; |
| 273 | 273 | |
| 274 | 274 | // API OBJECT FOR EXTERNAL WIRING |
| 275 | 275 | globalThis.SillyTavern = { |
| @@ -2793,7 +2793,8 @@ export async function generateQuietPrompt(quiet_prompt, quietToLoud, skipWIAN, q | ||
| 2793 | 2793 | TempResponseLength.save(main_api, responseLength); |
| 2794 | 2794 | eventHook = TempResponseLength.setupEventHook(main_api); |
| 2795 | 2795 | } |
| 2796 | 2796 | returnconst result = await Generate('quiet', options); |
| 2797 | + return removeReasoningFromString(result); | |
| 2797 | 2798 | } finally { |
| 2798 | 2799 | if (responseLengthCustomized && TempResponseLength.isCustomized()) { |
| 2799 | 2800 | TempResponseLength.restore(main_api); |
| @@ -447,6 +447,20 @@ function setReasoningEventHandlers() { | ||
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | /** |
| 450 | + * Removes reasoning from a string if auto-parsing is enabled. | |
| 451 | + * @param {string} str Input string | |
| 452 | + * @returns {string} Output string | |
| 453 | + */ | |
| 454 | +export function removeReasoningFromString(str) { | |
| 455 | + if (!power_user.reasoning.auto_parse) { | |
| 456 | + return str; | |
| 457 | + } | |
| 458 | + | |
| 459 | + const parsedReasoning = parseReasoningFromString(str); | |
| 460 | + return parsedReasoning?.content ?? str; | |
| 461 | +} | |
| 462 | + | |
| 463 | +/** | |
| 450 | 464 | * Parses reasoning from a string using the power user reasoning settings. |
| 451 | 465 | * @typedef {Object} ParsedReasoning |
| 452 | 466 | * @property {string} reasoning Reasoning block |