mirror of
				https://github.com/SillyTavern/SillyTavern.git
				synced 2025-06-05 21:59:27 +02:00 
			
		
		
		
	Remove reasoning from queit prompt results if auto-parse is enabled
Fixes #3457
This commit is contained in:
		| @@ -269,7 +269,7 @@ import { initSettingsSearch } from './scripts/setting-search.js'; | |||||||
| import { initBulkEdit } from './scripts/bulk-edit.js'; | import { initBulkEdit } from './scripts/bulk-edit.js'; | ||||||
| import { deriveTemplatesFromChatTemplate } from './scripts/chat-templates.js'; | import { deriveTemplatesFromChatTemplate } from './scripts/chat-templates.js'; | ||||||
| import { getContext } from './scripts/st-context.js'; | import { getContext } from './scripts/st-context.js'; | ||||||
| import { extractReasoningFromData, initReasoning, PromptReasoning, updateReasoningTimeUI } from './scripts/reasoning.js'; | import { extractReasoningFromData, initReasoning, PromptReasoning, removeReasoningFromString, updateReasoningTimeUI } from './scripts/reasoning.js'; | ||||||
|  |  | ||||||
| // API OBJECT FOR EXTERNAL WIRING | // API OBJECT FOR EXTERNAL WIRING | ||||||
| globalThis.SillyTavern = { | globalThis.SillyTavern = { | ||||||
| @@ -2793,7 +2793,8 @@ export async function generateQuietPrompt(quiet_prompt, quietToLoud, skipWIAN, q | |||||||
|             TempResponseLength.save(main_api, responseLength); |             TempResponseLength.save(main_api, responseLength); | ||||||
|             eventHook = TempResponseLength.setupEventHook(main_api); |             eventHook = TempResponseLength.setupEventHook(main_api); | ||||||
|         } |         } | ||||||
|         return await Generate('quiet', options); |         const result = await Generate('quiet', options); | ||||||
|  |         return removeReasoningFromString(result); | ||||||
|     } finally { |     } finally { | ||||||
|         if (responseLengthCustomized && TempResponseLength.isCustomized()) { |         if (responseLengthCustomized && TempResponseLength.isCustomized()) { | ||||||
|             TempResponseLength.restore(main_api); |             TempResponseLength.restore(main_api); | ||||||
|   | |||||||
| @@ -446,6 +446,20 @@ function setReasoningEventHandlers() { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Removes reasoning from a string if auto-parsing is enabled. | ||||||
|  |  * @param {string} str Input string | ||||||
|  |  * @returns {string} Output string | ||||||
|  |  */ | ||||||
|  | export function removeReasoningFromString(str) { | ||||||
|  |     if (!power_user.reasoning.auto_parse) { | ||||||
|  |         return str; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     const parsedReasoning = parseReasoningFromString(str); | ||||||
|  |     return parsedReasoning?.content ?? str; | ||||||
|  | } | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Parses reasoning from a string using the power user reasoning settings. |  * Parses reasoning from a string using the power user reasoning settings. | ||||||
|  * @typedef {Object} ParsedReasoning |  * @typedef {Object} ParsedReasoning | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user