mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-13 10:30:14 +01:00
Apply regex to multiswipe reasoning, set reasoning_type to Parsed
This commit is contained in:
parent
71a3aefe86
commit
73230272f3
@ -1107,8 +1107,12 @@ function parseReasoningFromString(str, { strict = true } = {}) {
|
||||
/**
|
||||
* Parse reasoning in an array of swipe strings if auto-parsing is enabled.
|
||||
* @param {string[]} swipes Array of swipe strings
|
||||
* @param {{extra: {reasoning: string, reasoning_duration: number}}[]} swipeInfoArray Array of swipe info objects
|
||||
* @param {{extra: ReasoningMessageExtra}[]} swipeInfoArray Array of swipe info objects
|
||||
* @param {number?} duration Duration of the reasoning
|
||||
* @typedef {object} ReasoningMessageExtra Extra reasoning data
|
||||
* @property {string} reasoning Reasoning block
|
||||
* @property {number} reasoning_duration Duration of the reasoning block
|
||||
* @property {string} reasoning_type Type of reasoning block
|
||||
*/
|
||||
export function parseReasoningInSwipes(swipes, swipeInfoArray, duration) {
|
||||
if (!power_user.reasoning.auto_parse) {
|
||||
@ -1123,9 +1127,10 @@ export function parseReasoningInSwipes(swipes, swipeInfoArray, duration) {
|
||||
for (let index = 0; index < swipes.length; index++) {
|
||||
const parsedReasoning = parseReasoningFromString(swipes[index]);
|
||||
if (parsedReasoning) {
|
||||
swipes[index] = parsedReasoning.content;
|
||||
swipes[index] = getRegexedString(parsedReasoning.content, regex_placement.REASONING);
|
||||
swipeInfoArray[index].extra.reasoning = parsedReasoning.reasoning;
|
||||
swipeInfoArray[index].extra.reasoning_duration = duration;
|
||||
swipeInfoArray[index].extra.reasoning_type = ReasoningType.Parsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user