@promptbook/legacy-documents 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
|
@@ -28,7 +28,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
28
28
|
* @generated
|
|
29
29
|
* @see https://github.com/webgptorg/promptbook
|
|
30
30
|
*/
|
|
31
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-
|
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-22';
|
|
32
32
|
/**
|
|
33
33
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
34
34
|
* Note: [π] Ignore a discrepancy between file name and entity name
|
|
@@ -2545,15 +2545,12 @@ function jsonParse(value) {
|
|
|
2545
2545
|
}
|
|
2546
2546
|
throw new Error(spaceTrim$1((block) => `
|
|
2547
2547
|
${block(error.message)}
|
|
2548
|
-
|
|
2548
|
+
|
|
2549
2549
|
The JSON text:
|
|
2550
2550
|
${block(value)}
|
|
2551
2551
|
`));
|
|
2552
2552
|
}
|
|
2553
2553
|
}
|
|
2554
|
-
/**
|
|
2555
|
-
* TODO: !!!! Use in Promptbook.studio
|
|
2556
|
-
*/
|
|
2557
2554
|
|
|
2558
2555
|
/**
|
|
2559
2556
|
* Recursively converts JSON strings to JSON objects
|
|
@@ -4305,7 +4302,8 @@ const CsvFormatParser = {
|
|
|
4305
4302
|
subvalueParsers: [
|
|
4306
4303
|
{
|
|
4307
4304
|
subvalueName: 'ROW',
|
|
4308
|
-
async mapValues(
|
|
4305
|
+
async mapValues(options) {
|
|
4306
|
+
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
4309
4307
|
const csv = csvParse(value, settings);
|
|
4310
4308
|
if (csv.errors.length !== 0) {
|
|
4311
4309
|
throw new CsvFormatError(spaceTrim$1((block) => `
|
|
@@ -4321,21 +4319,29 @@ const CsvFormatParser = {
|
|
|
4321
4319
|
${block(value)}
|
|
4322
4320
|
`));
|
|
4323
4321
|
}
|
|
4324
|
-
const mappedData =
|
|
4322
|
+
const mappedData = [];
|
|
4323
|
+
for (let index = 0; index < csv.data.length; index++) {
|
|
4324
|
+
const row = csv.data[index];
|
|
4325
4325
|
if (row[outputParameterName]) {
|
|
4326
4326
|
throw new CsvFormatError(`Can not overwrite existing column "${outputParameterName}" in CSV row`);
|
|
4327
4327
|
}
|
|
4328
|
-
|
|
4328
|
+
const mappedRow = {
|
|
4329
4329
|
...row,
|
|
4330
4330
|
[outputParameterName]: await mapCallback(row, index),
|
|
4331
4331
|
};
|
|
4332
|
-
|
|
4332
|
+
mappedData.push(mappedRow);
|
|
4333
|
+
if (onProgress) {
|
|
4334
|
+
// Note: Report the CSV with all rows mapped so far
|
|
4335
|
+
await onProgress(unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS }));
|
|
4336
|
+
}
|
|
4337
|
+
}
|
|
4333
4338
|
return unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
|
|
4334
4339
|
},
|
|
4335
4340
|
},
|
|
4336
4341
|
{
|
|
4337
4342
|
subvalueName: 'CELL',
|
|
4338
|
-
async mapValues(
|
|
4343
|
+
async mapValues(options) {
|
|
4344
|
+
const { value, settings, mapCallback, onProgress } = options;
|
|
4339
4345
|
const csv = csvParse(value, settings);
|
|
4340
4346
|
if (csv.errors.length !== 0) {
|
|
4341
4347
|
throw new CsvFormatError(spaceTrim$1((block) => `
|
|
@@ -4422,7 +4428,8 @@ const TextFormatParser = {
|
|
|
4422
4428
|
subvalueParsers: [
|
|
4423
4429
|
{
|
|
4424
4430
|
subvalueName: 'LINE',
|
|
4425
|
-
async mapValues(
|
|
4431
|
+
async mapValues(options) {
|
|
4432
|
+
const { value, mapCallback, onProgress } = options;
|
|
4426
4433
|
const lines = value.split('\n');
|
|
4427
4434
|
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber) =>
|
|
4428
4435
|
// TODO: [π§ ] Maybe option to skip empty line
|
|
@@ -5243,7 +5250,7 @@ async function executeAttempts(options) {
|
|
|
5243
5250
|
* @private internal utility of `createPipelineExecutor`
|
|
5244
5251
|
*/
|
|
5245
5252
|
async function executeFormatSubvalues(options) {
|
|
5246
|
-
const { task, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification } = options;
|
|
5253
|
+
const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, pipelineIdentification } = options;
|
|
5247
5254
|
if (task.foreach === undefined) {
|
|
5248
5255
|
return /* not await */ executeAttempts(options);
|
|
5249
5256
|
}
|
|
@@ -5297,21 +5304,32 @@ async function executeFormatSubvalues(options) {
|
|
|
5297
5304
|
formatSettings = csvSettings;
|
|
5298
5305
|
// <- TODO: [π€ΉββοΈ] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
|
|
5299
5306
|
}
|
|
5300
|
-
const resultString = await subvalueParser.mapValues(
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5307
|
+
const resultString = await subvalueParser.mapValues({
|
|
5308
|
+
value: parameterValue,
|
|
5309
|
+
outputParameterName: task.foreach.outputSubparameterName,
|
|
5310
|
+
settings: formatSettings,
|
|
5311
|
+
onProgress(partialResultString) {
|
|
5312
|
+
return onProgress(Object.freeze({
|
|
5313
|
+
[task.resultingParameterName]:
|
|
5314
|
+
// <- Note: [π©βπ©βπ§] No need to detect parameter collision here because pipeline checks logic consistency during construction
|
|
5315
|
+
partialResultString,
|
|
5316
|
+
}));
|
|
5317
|
+
},
|
|
5318
|
+
async mapCallback(subparameters, index) {
|
|
5319
|
+
let mappedParameters;
|
|
5320
|
+
// TODO: [π€ΉββοΈ][πͺ] Limit to N concurrent executions
|
|
5321
|
+
// TODO: When done [π] Report progress also for each subvalue here
|
|
5322
|
+
try {
|
|
5323
|
+
mappedParameters = mapAvailableToExpectedParameters({
|
|
5324
|
+
expectedParameters: Object.fromEntries(task.foreach.inputSubparameterNames.map((subparameterName) => [subparameterName, null])),
|
|
5325
|
+
availableParameters: subparameters,
|
|
5326
|
+
});
|
|
5313
5327
|
}
|
|
5314
|
-
|
|
5328
|
+
catch (error) {
|
|
5329
|
+
if (!(error instanceof PipelineExecutionError)) {
|
|
5330
|
+
throw error;
|
|
5331
|
+
}
|
|
5332
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
5315
5333
|
${error.message}
|
|
5316
5334
|
|
|
5317
5335
|
This is error in FOREACH command
|
|
@@ -5320,23 +5338,24 @@ async function executeFormatSubvalues(options) {
|
|
|
5320
5338
|
${block(pipelineIdentification)}
|
|
5321
5339
|
Subparameter index: ${index}
|
|
5322
5340
|
`));
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5341
|
+
}
|
|
5342
|
+
const allSubparameters = {
|
|
5343
|
+
...parameters,
|
|
5344
|
+
...mappedParameters,
|
|
5345
|
+
};
|
|
5346
|
+
// 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
|
|
5347
|
+
Object.freeze(allSubparameters);
|
|
5348
|
+
const subresultString = await executeAttempts({
|
|
5349
|
+
...options,
|
|
5350
|
+
priority: priority + index,
|
|
5351
|
+
parameters: allSubparameters,
|
|
5352
|
+
pipelineIdentification: spaceTrim$1((block) => `
|
|
5335
5353
|
${block(pipelineIdentification)}
|
|
5336
5354
|
Subparameter index: ${index}
|
|
5337
5355
|
`),
|
|
5338
|
-
|
|
5339
|
-
|
|
5356
|
+
});
|
|
5357
|
+
return subresultString;
|
|
5358
|
+
},
|
|
5340
5359
|
});
|
|
5341
5360
|
return resultString;
|
|
5342
5361
|
}
|
|
@@ -5510,11 +5529,6 @@ async function getReservedParametersForTask(options) {
|
|
|
5510
5529
|
async function executeTask(options) {
|
|
5511
5530
|
const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, } = options;
|
|
5512
5531
|
const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
|
|
5513
|
-
await onProgress({
|
|
5514
|
-
outputParameters: {
|
|
5515
|
-
[currentTask.resultingParameterName]: '', // <- TODO: [π§ ] What is the best value here?
|
|
5516
|
-
},
|
|
5517
|
-
});
|
|
5518
5532
|
// Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but itβs good to doublecheck
|
|
5519
5533
|
const usedParameterNames = extractParameterNamesFromTask(currentTask);
|
|
5520
5534
|
const dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
@@ -5589,6 +5603,7 @@ async function executeTask(options) {
|
|
|
5589
5603
|
preparedPipeline,
|
|
5590
5604
|
tools,
|
|
5591
5605
|
$executionReport,
|
|
5606
|
+
onProgress,
|
|
5592
5607
|
pipelineIdentification,
|
|
5593
5608
|
maxExecutionAttempts,
|
|
5594
5609
|
maxParallelCount,
|