Merge branch 'staging' into bogus-localstorage
| @@ -269,7 +269,7 @@ import { initSettingsSearch } from './scripts/setting-search.js'; | |||
| 269 | import { initBulkEdit } from './scripts/bulk-edit.js'; | 269 | import { initBulkEdit } from './scripts/bulk-edit.js'; |
| 270 | import { deriveTemplatesFromChatTemplate } from './scripts/chat-templates.js'; | 270 | import { deriveTemplatesFromChatTemplate } from './scripts/chat-templates.js'; |
| 271 | import { getContext } from './scripts/st-context.js'; | 271 | import { getContext } from './scripts/st-context.js'; |
| 272 | import { extractReasoningFromData, initReasoning, PromptReasoning, updateReasoningTimeUI } from './scripts/reasoning.js'; | 272 | import { extractReasoningFromData, initReasoning, PromptReasoning, removeReasoningFromString, updateReasoningTimeUI } from './scripts/reasoning.js'; |
| 273 | import { accountStorage } from './scripts/util/AccountStorage.js'; | 273 | import { accountStorage } from './scripts/util/AccountStorage.js'; |
| 274 | 274 | ||
| 275 | // API OBJECT FOR EXTERNAL WIRING | 275 | // API OBJECT FOR EXTERNAL WIRING |
| @@ -2794,7 +2794,8 @@ export async function generateQuietPrompt(quiet_prompt, quietToLoud, skipWIAN, q | |||
| 2794 | TempResponseLength.save(main_api, responseLength); | 2794 | TempResponseLength.save(main_api, responseLength); |
| 2795 | eventHook = TempResponseLength.setupEventHook(main_api); | 2795 | eventHook = TempResponseLength.setupEventHook(main_api); |
| 2796 | } | 2796 | } |
| 2797 | return await Generate('quiet', options); | 2797 | const result = await Generate('quiet', options); |
| 2798 | return removeReasoningFromString(result); | ||
| 2798 | } finally { | 2799 | } finally { |
| 2799 | if (responseLengthCustomized && TempResponseLength.isCustomized()) { | 2800 | if (responseLengthCustomized && TempResponseLength.isCustomized()) { |
| 2800 | TempResponseLength.restore(main_api); | 2801 | 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 | * Parses reasoning from a string using the power user reasoning settings. | 464 | * Parses reasoning from a string using the power user reasoning settings. |
| 451 | * @typedef {Object} ParsedReasoning | 465 | * @typedef {Object} ParsedReasoning |
| 452 | * @property {string} reasoning Reasoning block | 466 | * @property {string} reasoning Reasoning block |