@promptbook/pdf 0.92.0-20 β 0.92.0-22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.es.js +60 -45
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +4 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/config.d.ts +8 -0
- package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +8 -1
- package/esm/typings/src/formats/_common/FormatSubvalueParser.d.ts +11 -1
- package/esm/typings/src/formats/json/utils/jsonParse.d.ts +0 -3
- package/esm/typings/src/formfactors/completion/CompletionFormfactorDefinition.d.ts +29 -0
- package/esm/typings/src/formfactors/index.d.ts +28 -3
- package/esm/typings/src/high-level-abstractions/index.d.ts +2 -2
- package/esm/typings/src/migrations/migratePipeline.d.ts +2 -0
- package/package.json +2 -2
- package/umd/index.umd.js +60 -45
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -26,7 +26,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
26
26
|
* @generated
|
|
27
27
|
* @see https://github.com/webgptorg/promptbook
|
|
28
28
|
*/
|
|
29
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-
|
|
29
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-22';
|
|
30
30
|
/**
|
|
31
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
32
|
* Note: [π] Ignore a discrepancy between file name and entity name
|
|
@@ -2384,15 +2384,12 @@ function jsonParse(value) {
|
|
|
2384
2384
|
}
|
|
2385
2385
|
throw new Error(spaceTrim((block) => `
|
|
2386
2386
|
${block(error.message)}
|
|
2387
|
-
|
|
2387
|
+
|
|
2388
2388
|
The JSON text:
|
|
2389
2389
|
${block(value)}
|
|
2390
2390
|
`));
|
|
2391
2391
|
}
|
|
2392
2392
|
}
|
|
2393
|
-
/**
|
|
2394
|
-
* TODO: !!!! Use in Promptbook.studio
|
|
2395
|
-
*/
|
|
2396
2393
|
|
|
2397
2394
|
/**
|
|
2398
2395
|
* Recursively converts JSON strings to JSON objects
|
|
@@ -4154,7 +4151,8 @@ const CsvFormatParser = {
|
|
|
4154
4151
|
subvalueParsers: [
|
|
4155
4152
|
{
|
|
4156
4153
|
subvalueName: 'ROW',
|
|
4157
|
-
async mapValues(
|
|
4154
|
+
async mapValues(options) {
|
|
4155
|
+
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
4158
4156
|
const csv = csvParse(value, settings);
|
|
4159
4157
|
if (csv.errors.length !== 0) {
|
|
4160
4158
|
throw new CsvFormatError(spaceTrim((block) => `
|
|
@@ -4170,21 +4168,29 @@ const CsvFormatParser = {
|
|
|
4170
4168
|
${block(value)}
|
|
4171
4169
|
`));
|
|
4172
4170
|
}
|
|
4173
|
-
const mappedData =
|
|
4171
|
+
const mappedData = [];
|
|
4172
|
+
for (let index = 0; index < csv.data.length; index++) {
|
|
4173
|
+
const row = csv.data[index];
|
|
4174
4174
|
if (row[outputParameterName]) {
|
|
4175
4175
|
throw new CsvFormatError(`Can not overwrite existing column "${outputParameterName}" in CSV row`);
|
|
4176
4176
|
}
|
|
4177
|
-
|
|
4177
|
+
const mappedRow = {
|
|
4178
4178
|
...row,
|
|
4179
4179
|
[outputParameterName]: await mapCallback(row, index),
|
|
4180
4180
|
};
|
|
4181
|
-
|
|
4181
|
+
mappedData.push(mappedRow);
|
|
4182
|
+
if (onProgress) {
|
|
4183
|
+
// Note: Report the CSV with all rows mapped so far
|
|
4184
|
+
await onProgress(unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS }));
|
|
4185
|
+
}
|
|
4186
|
+
}
|
|
4182
4187
|
return unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
|
|
4183
4188
|
},
|
|
4184
4189
|
},
|
|
4185
4190
|
{
|
|
4186
4191
|
subvalueName: 'CELL',
|
|
4187
|
-
async mapValues(
|
|
4192
|
+
async mapValues(options) {
|
|
4193
|
+
const { value, settings, mapCallback, onProgress } = options;
|
|
4188
4194
|
const csv = csvParse(value, settings);
|
|
4189
4195
|
if (csv.errors.length !== 0) {
|
|
4190
4196
|
throw new CsvFormatError(spaceTrim((block) => `
|
|
@@ -4271,7 +4277,8 @@ const TextFormatParser = {
|
|
|
4271
4277
|
subvalueParsers: [
|
|
4272
4278
|
{
|
|
4273
4279
|
subvalueName: 'LINE',
|
|
4274
|
-
async mapValues(
|
|
4280
|
+
async mapValues(options) {
|
|
4281
|
+
const { value, mapCallback, onProgress } = options;
|
|
4275
4282
|
const lines = value.split('\n');
|
|
4276
4283
|
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber) =>
|
|
4277
4284
|
// TODO: [π§ ] Maybe option to skip empty line
|
|
@@ -5092,7 +5099,7 @@ async function executeAttempts(options) {
|
|
|
5092
5099
|
* @private internal utility of `createPipelineExecutor`
|
|
5093
5100
|
*/
|
|
5094
5101
|
async function executeFormatSubvalues(options) {
|
|
5095
|
-
const { task, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification } = options;
|
|
5102
|
+
const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, pipelineIdentification } = options;
|
|
5096
5103
|
if (task.foreach === undefined) {
|
|
5097
5104
|
return /* not await */ executeAttempts(options);
|
|
5098
5105
|
}
|
|
@@ -5146,21 +5153,32 @@ async function executeFormatSubvalues(options) {
|
|
|
5146
5153
|
formatSettings = csvSettings;
|
|
5147
5154
|
// <- TODO: [π€ΉββοΈ] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
|
|
5148
5155
|
}
|
|
5149
|
-
const resultString = await subvalueParser.mapValues(
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5156
|
+
const resultString = await subvalueParser.mapValues({
|
|
5157
|
+
value: parameterValue,
|
|
5158
|
+
outputParameterName: task.foreach.outputSubparameterName,
|
|
5159
|
+
settings: formatSettings,
|
|
5160
|
+
onProgress(partialResultString) {
|
|
5161
|
+
return onProgress(Object.freeze({
|
|
5162
|
+
[task.resultingParameterName]:
|
|
5163
|
+
// <- Note: [π©βπ©βπ§] No need to detect parameter collision here because pipeline checks logic consistency during construction
|
|
5164
|
+
partialResultString,
|
|
5165
|
+
}));
|
|
5166
|
+
},
|
|
5167
|
+
async mapCallback(subparameters, index) {
|
|
5168
|
+
let mappedParameters;
|
|
5169
|
+
// TODO: [π€ΉββοΈ][πͺ] Limit to N concurrent executions
|
|
5170
|
+
// TODO: When done [π] Report progress also for each subvalue here
|
|
5171
|
+
try {
|
|
5172
|
+
mappedParameters = mapAvailableToExpectedParameters({
|
|
5173
|
+
expectedParameters: Object.fromEntries(task.foreach.inputSubparameterNames.map((subparameterName) => [subparameterName, null])),
|
|
5174
|
+
availableParameters: subparameters,
|
|
5175
|
+
});
|
|
5162
5176
|
}
|
|
5163
|
-
|
|
5177
|
+
catch (error) {
|
|
5178
|
+
if (!(error instanceof PipelineExecutionError)) {
|
|
5179
|
+
throw error;
|
|
5180
|
+
}
|
|
5181
|
+
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
5164
5182
|
${error.message}
|
|
5165
5183
|
|
|
5166
5184
|
This is error in FOREACH command
|
|
@@ -5169,23 +5187,24 @@ async function executeFormatSubvalues(options) {
|
|
|
5169
5187
|
${block(pipelineIdentification)}
|
|
5170
5188
|
Subparameter index: ${index}
|
|
5171
5189
|
`));
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5190
|
+
}
|
|
5191
|
+
const allSubparameters = {
|
|
5192
|
+
...parameters,
|
|
5193
|
+
...mappedParameters,
|
|
5194
|
+
};
|
|
5195
|
+
// Note: [π¨βπ¨βπ§] Now we can freeze `subparameters` because we are sure that all and only used parameters are defined and are not going to be changed
|
|
5196
|
+
Object.freeze(allSubparameters);
|
|
5197
|
+
const subresultString = await executeAttempts({
|
|
5198
|
+
...options,
|
|
5199
|
+
priority: priority + index,
|
|
5200
|
+
parameters: allSubparameters,
|
|
5201
|
+
pipelineIdentification: spaceTrim((block) => `
|
|
5184
5202
|
${block(pipelineIdentification)}
|
|
5185
5203
|
Subparameter index: ${index}
|
|
5186
5204
|
`),
|
|
5187
|
-
|
|
5188
|
-
|
|
5205
|
+
});
|
|
5206
|
+
return subresultString;
|
|
5207
|
+
},
|
|
5189
5208
|
});
|
|
5190
5209
|
return resultString;
|
|
5191
5210
|
}
|
|
@@ -5359,11 +5378,6 @@ async function getReservedParametersForTask(options) {
|
|
|
5359
5378
|
async function executeTask(options) {
|
|
5360
5379
|
const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, } = options;
|
|
5361
5380
|
const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
|
|
5362
|
-
await onProgress({
|
|
5363
|
-
outputParameters: {
|
|
5364
|
-
[currentTask.resultingParameterName]: '', // <- TODO: [π§ ] What is the best value here?
|
|
5365
|
-
},
|
|
5366
|
-
});
|
|
5367
5381
|
// Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but itβs good to doublecheck
|
|
5368
5382
|
const usedParameterNames = extractParameterNamesFromTask(currentTask);
|
|
5369
5383
|
const dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
@@ -5438,6 +5452,7 @@ async function executeTask(options) {
|
|
|
5438
5452
|
preparedPipeline,
|
|
5439
5453
|
tools,
|
|
5440
5454
|
$executionReport,
|
|
5455
|
+
onProgress,
|
|
5441
5456
|
pipelineIdentification,
|
|
5442
5457
|
maxExecutionAttempts,
|
|
5443
5458
|
maxParallelCount,
|