mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Replace macros in DRY sequence breakers
This commit is contained in:
@ -1064,6 +1064,34 @@ function getLogprobsNumber() {
|
|||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces {{macro}} in a comma-separated or serialized JSON array string.
|
||||||
|
* @param {string} str Input string
|
||||||
|
* @returns {string} Output string
|
||||||
|
*/
|
||||||
|
function replaceMacrosInList(str) {
|
||||||
|
if (!str || typeof str !== 'string') {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const array = JSON.parse(str);
|
||||||
|
if (!Array.isArray(array)) {
|
||||||
|
throw new Error('Not an array');
|
||||||
|
}
|
||||||
|
for (let i = 0; i < array.length; i++) {
|
||||||
|
array[i] = substituteParams(array[i]);
|
||||||
|
}
|
||||||
|
return JSON.stringify(array);
|
||||||
|
} catch {
|
||||||
|
const array = str.split(',');
|
||||||
|
for (let i = 0; i < array.length; i++) {
|
||||||
|
array[i] = substituteParams(array[i]);
|
||||||
|
}
|
||||||
|
return array.join(',');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, isContinue, cfgValues, type) {
|
export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, isContinue, cfgValues, type) {
|
||||||
const canMultiSwipe = !isContinue && !isImpersonate && type !== 'quiet';
|
const canMultiSwipe = !isContinue && !isImpersonate && type !== 'quiet';
|
||||||
const dynatemp = isDynamicTemperatureSupported();
|
const dynatemp = isDynamicTemperatureSupported();
|
||||||
@ -1103,7 +1131,7 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
|
|||||||
'dry_allowed_length': settings.dry_allowed_length,
|
'dry_allowed_length': settings.dry_allowed_length,
|
||||||
'dry_multiplier': settings.dry_multiplier,
|
'dry_multiplier': settings.dry_multiplier,
|
||||||
'dry_base': settings.dry_base,
|
'dry_base': settings.dry_base,
|
||||||
'dry_sequence_breakers': settings.dry_sequence_breakers,
|
'dry_sequence_breakers': replaceMacrosInList(settings.dry_sequence_breakers),
|
||||||
'dry_penalty_last_n': settings.dry_penalty_last_n,
|
'dry_penalty_last_n': settings.dry_penalty_last_n,
|
||||||
'max_tokens_second': settings.max_tokens_second,
|
'max_tokens_second': settings.max_tokens_second,
|
||||||
'sampler_priority': settings.type === OOBA ? settings.sampler_priority : undefined,
|
'sampler_priority': settings.type === OOBA ? settings.sampler_priority : undefined,
|
||||||
|
Reference in New Issue
Block a user