| 1064 | 1064 | return 10; |
| 1065 | 1065 | } |
| 1066 | 1066 | |
| 1067 | +/** |
| 1068 | + * Replaces {{macro}} in a comma-separated or serialized JSON array string. |
| 1069 | + * @param {string} str Input string |
| 1070 | + * @returns {string} Output string |
| 1071 | + */ |
| 1072 | +function replaceMacrosInList(str) { |
| 1073 | + if (!str || typeof str !== 'string') { |
| 1074 | + return str; |
| 1075 | + } |
| 1076 | + |
| 1077 | + try { |
| 1078 | + const array = JSON.parse(str); |
| 1079 | + if (!Array.isArray(array)) { |
| 1080 | + throw new Error('Not an array'); |
| 1081 | + } |
| 1082 | + for (let i = 0; i < array.length; i++) { |
| 1083 | + array[i] = substituteParams(array[i]); |
| 1084 | + } |
| 1085 | + return JSON.stringify(array); |
| 1086 | + } catch { |
| 1087 | + const array = str.split(','); |
| 1088 | + for (let i = 0; i < array.length; i++) { |
| 1089 | + array[i] = substituteParams(array[i]); |
| 1090 | + } |
| 1091 | + return array.join(','); |
| 1092 | + } |
| 1093 | +} |
| 1094 | + |
| 1067 | 1095 | export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, isContinue, cfgValues, type) { |
| 1068 | 1096 | const canMultiSwipe = !isContinue && !isImpersonate && type !== 'quiet'; |
| 1069 | 1097 | const dynatemp = isDynamicTemperatureSupported(); |