@promptbook/remote-server 0.92.0-21 β 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 +59 -41
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +2 -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/package.json +2 -2
- package/umd/index.umd.js +59 -41
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -33,7 +33,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
33
33
|
* @generated
|
|
34
34
|
* @see https://github.com/webgptorg/promptbook
|
|
35
35
|
*/
|
|
36
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-
|
|
36
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-22';
|
|
37
37
|
/**
|
|
38
38
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
39
39
|
* Note: [π] Ignore a discrepancy between file name and entity name
|
|
@@ -4469,7 +4469,8 @@ const CsvFormatParser = {
|
|
|
4469
4469
|
subvalueParsers: [
|
|
4470
4470
|
{
|
|
4471
4471
|
subvalueName: 'ROW',
|
|
4472
|
-
async mapValues(
|
|
4472
|
+
async mapValues(options) {
|
|
4473
|
+
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
4473
4474
|
const csv = csvParse(value, settings);
|
|
4474
4475
|
if (csv.errors.length !== 0) {
|
|
4475
4476
|
throw new CsvFormatError(spaceTrim((block) => `
|
|
@@ -4485,21 +4486,29 @@ const CsvFormatParser = {
|
|
|
4485
4486
|
${block(value)}
|
|
4486
4487
|
`));
|
|
4487
4488
|
}
|
|
4488
|
-
const mappedData =
|
|
4489
|
+
const mappedData = [];
|
|
4490
|
+
for (let index = 0; index < csv.data.length; index++) {
|
|
4491
|
+
const row = csv.data[index];
|
|
4489
4492
|
if (row[outputParameterName]) {
|
|
4490
4493
|
throw new CsvFormatError(`Can not overwrite existing column "${outputParameterName}" in CSV row`);
|
|
4491
4494
|
}
|
|
4492
|
-
|
|
4495
|
+
const mappedRow = {
|
|
4493
4496
|
...row,
|
|
4494
4497
|
[outputParameterName]: await mapCallback(row, index),
|
|
4495
4498
|
};
|
|
4496
|
-
|
|
4499
|
+
mappedData.push(mappedRow);
|
|
4500
|
+
if (onProgress) {
|
|
4501
|
+
// Note: Report the CSV with all rows mapped so far
|
|
4502
|
+
await onProgress(unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS }));
|
|
4503
|
+
}
|
|
4504
|
+
}
|
|
4497
4505
|
return unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
|
|
4498
4506
|
},
|
|
4499
4507
|
},
|
|
4500
4508
|
{
|
|
4501
4509
|
subvalueName: 'CELL',
|
|
4502
|
-
async mapValues(
|
|
4510
|
+
async mapValues(options) {
|
|
4511
|
+
const { value, settings, mapCallback, onProgress } = options;
|
|
4503
4512
|
const csv = csvParse(value, settings);
|
|
4504
4513
|
if (csv.errors.length !== 0) {
|
|
4505
4514
|
throw new CsvFormatError(spaceTrim((block) => `
|
|
@@ -4586,7 +4595,8 @@ const TextFormatParser = {
|
|
|
4586
4595
|
subvalueParsers: [
|
|
4587
4596
|
{
|
|
4588
4597
|
subvalueName: 'LINE',
|
|
4589
|
-
async mapValues(
|
|
4598
|
+
async mapValues(options) {
|
|
4599
|
+
const { value, mapCallback, onProgress } = options;
|
|
4590
4600
|
const lines = value.split('\n');
|
|
4591
4601
|
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber) =>
|
|
4592
4602
|
// TODO: [π§ ] Maybe option to skip empty line
|
|
@@ -5424,7 +5434,7 @@ async function executeAttempts(options) {
|
|
|
5424
5434
|
* @private internal utility of `createPipelineExecutor`
|
|
5425
5435
|
*/
|
|
5426
5436
|
async function executeFormatSubvalues(options) {
|
|
5427
|
-
const { task, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification } = options;
|
|
5437
|
+
const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, pipelineIdentification } = options;
|
|
5428
5438
|
if (task.foreach === undefined) {
|
|
5429
5439
|
return /* not await */ executeAttempts(options);
|
|
5430
5440
|
}
|
|
@@ -5478,21 +5488,32 @@ async function executeFormatSubvalues(options) {
|
|
|
5478
5488
|
formatSettings = csvSettings;
|
|
5479
5489
|
// <- TODO: [π€ΉββοΈ] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
|
|
5480
5490
|
}
|
|
5481
|
-
const resultString = await subvalueParser.mapValues(
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5491
|
+
const resultString = await subvalueParser.mapValues({
|
|
5492
|
+
value: parameterValue,
|
|
5493
|
+
outputParameterName: task.foreach.outputSubparameterName,
|
|
5494
|
+
settings: formatSettings,
|
|
5495
|
+
onProgress(partialResultString) {
|
|
5496
|
+
return onProgress(Object.freeze({
|
|
5497
|
+
[task.resultingParameterName]:
|
|
5498
|
+
// <- Note: [π©βπ©βπ§] No need to detect parameter collision here because pipeline checks logic consistency during construction
|
|
5499
|
+
partialResultString,
|
|
5500
|
+
}));
|
|
5501
|
+
},
|
|
5502
|
+
async mapCallback(subparameters, index) {
|
|
5503
|
+
let mappedParameters;
|
|
5504
|
+
// TODO: [π€ΉββοΈ][πͺ] Limit to N concurrent executions
|
|
5505
|
+
// TODO: When done [π] Report progress also for each subvalue here
|
|
5506
|
+
try {
|
|
5507
|
+
mappedParameters = mapAvailableToExpectedParameters({
|
|
5508
|
+
expectedParameters: Object.fromEntries(task.foreach.inputSubparameterNames.map((subparameterName) => [subparameterName, null])),
|
|
5509
|
+
availableParameters: subparameters,
|
|
5510
|
+
});
|
|
5494
5511
|
}
|
|
5495
|
-
|
|
5512
|
+
catch (error) {
|
|
5513
|
+
if (!(error instanceof PipelineExecutionError)) {
|
|
5514
|
+
throw error;
|
|
5515
|
+
}
|
|
5516
|
+
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
5496
5517
|
${error.message}
|
|
5497
5518
|
|
|
5498
5519
|
This is error in FOREACH command
|
|
@@ -5501,23 +5522,24 @@ async function executeFormatSubvalues(options) {
|
|
|
5501
5522
|
${block(pipelineIdentification)}
|
|
5502
5523
|
Subparameter index: ${index}
|
|
5503
5524
|
`));
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
|
|
5525
|
+
}
|
|
5526
|
+
const allSubparameters = {
|
|
5527
|
+
...parameters,
|
|
5528
|
+
...mappedParameters,
|
|
5529
|
+
};
|
|
5530
|
+
// 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
|
|
5531
|
+
Object.freeze(allSubparameters);
|
|
5532
|
+
const subresultString = await executeAttempts({
|
|
5533
|
+
...options,
|
|
5534
|
+
priority: priority + index,
|
|
5535
|
+
parameters: allSubparameters,
|
|
5536
|
+
pipelineIdentification: spaceTrim((block) => `
|
|
5516
5537
|
${block(pipelineIdentification)}
|
|
5517
5538
|
Subparameter index: ${index}
|
|
5518
5539
|
`),
|
|
5519
|
-
|
|
5520
|
-
|
|
5540
|
+
});
|
|
5541
|
+
return subresultString;
|
|
5542
|
+
},
|
|
5521
5543
|
});
|
|
5522
5544
|
return resultString;
|
|
5523
5545
|
}
|
|
@@ -5691,11 +5713,6 @@ async function getReservedParametersForTask(options) {
|
|
|
5691
5713
|
async function executeTask(options) {
|
|
5692
5714
|
const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, } = options;
|
|
5693
5715
|
const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
|
|
5694
|
-
await onProgress({
|
|
5695
|
-
outputParameters: {
|
|
5696
|
-
[currentTask.resultingParameterName]: '', // <- TODO: [π§ ] What is the best value here?
|
|
5697
|
-
},
|
|
5698
|
-
});
|
|
5699
5716
|
// Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but itβs good to doublecheck
|
|
5700
5717
|
const usedParameterNames = extractParameterNamesFromTask(currentTask);
|
|
5701
5718
|
const dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
@@ -5770,6 +5787,7 @@ async function executeTask(options) {
|
|
|
5770
5787
|
preparedPipeline,
|
|
5771
5788
|
tools,
|
|
5772
5789
|
$executionReport,
|
|
5790
|
+
onProgress,
|
|
5773
5791
|
pipelineIdentification,
|
|
5774
5792
|
maxExecutionAttempts,
|
|
5775
5793
|
maxParallelCount,
|