@promptbook/remote-server 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
|
@@ -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
|
|
@@ -1868,15 +1868,12 @@ function jsonParse(value) {
|
|
|
1868
1868
|
}
|
|
1869
1869
|
throw new Error(spaceTrim((block) => `
|
|
1870
1870
|
${block(error.message)}
|
|
1871
|
-
|
|
1871
|
+
|
|
1872
1872
|
The JSON text:
|
|
1873
1873
|
${block(value)}
|
|
1874
1874
|
`));
|
|
1875
1875
|
}
|
|
1876
1876
|
}
|
|
1877
|
-
/**
|
|
1878
|
-
* TODO: !!!! Use in Promptbook.studio
|
|
1879
|
-
*/
|
|
1880
1877
|
|
|
1881
1878
|
/**
|
|
1882
1879
|
* Recursively converts JSON strings to JSON objects
|
|
@@ -4472,7 +4469,8 @@ const CsvFormatParser = {
|
|
|
4472
4469
|
subvalueParsers: [
|
|
4473
4470
|
{
|
|
4474
4471
|
subvalueName: 'ROW',
|
|
4475
|
-
async mapValues(
|
|
4472
|
+
async mapValues(options) {
|
|
4473
|
+
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
4476
4474
|
const csv = csvParse(value, settings);
|
|
4477
4475
|
if (csv.errors.length !== 0) {
|
|
4478
4476
|
throw new CsvFormatError(spaceTrim((block) => `
|
|
@@ -4488,21 +4486,29 @@ const CsvFormatParser = {
|
|
|
4488
4486
|
${block(value)}
|
|
4489
4487
|
`));
|
|
4490
4488
|
}
|
|
4491
|
-
const mappedData =
|
|
4489
|
+
const mappedData = [];
|
|
4490
|
+
for (let index = 0; index < csv.data.length; index++) {
|
|
4491
|
+
const row = csv.data[index];
|
|
4492
4492
|
if (row[outputParameterName]) {
|
|
4493
4493
|
throw new CsvFormatError(`Can not overwrite existing column "${outputParameterName}" in CSV row`);
|
|
4494
4494
|
}
|
|
4495
|
-
|
|
4495
|
+
const mappedRow = {
|
|
4496
4496
|
...row,
|
|
4497
4497
|
[outputParameterName]: await mapCallback(row, index),
|
|
4498
4498
|
};
|
|
4499
|
-
|
|
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
|
+
}
|
|
4500
4505
|
return unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
|
|
4501
4506
|
},
|
|
4502
4507
|
},
|
|
4503
4508
|
{
|
|
4504
4509
|
subvalueName: 'CELL',
|
|
4505
|
-
async mapValues(
|
|
4510
|
+
async mapValues(options) {
|
|
4511
|
+
const { value, settings, mapCallback, onProgress } = options;
|
|
4506
4512
|
const csv = csvParse(value, settings);
|
|
4507
4513
|
if (csv.errors.length !== 0) {
|
|
4508
4514
|
throw new CsvFormatError(spaceTrim((block) => `
|
|
@@ -4589,7 +4595,8 @@ const TextFormatParser = {
|
|
|
4589
4595
|
subvalueParsers: [
|
|
4590
4596
|
{
|
|
4591
4597
|
subvalueName: 'LINE',
|
|
4592
|
-
async mapValues(
|
|
4598
|
+
async mapValues(options) {
|
|
4599
|
+
const { value, mapCallback, onProgress } = options;
|
|
4593
4600
|
const lines = value.split('\n');
|
|
4594
4601
|
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber) =>
|
|
4595
4602
|
// TODO: [π§ ] Maybe option to skip empty line
|
|
@@ -5427,7 +5434,7 @@ async function executeAttempts(options) {
|
|
|
5427
5434
|
* @private internal utility of `createPipelineExecutor`
|
|
5428
5435
|
*/
|
|
5429
5436
|
async function executeFormatSubvalues(options) {
|
|
5430
|
-
const { task, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification } = options;
|
|
5437
|
+
const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, pipelineIdentification } = options;
|
|
5431
5438
|
if (task.foreach === undefined) {
|
|
5432
5439
|
return /* not await */ executeAttempts(options);
|
|
5433
5440
|
}
|
|
@@ -5481,21 +5488,32 @@ async function executeFormatSubvalues(options) {
|
|
|
5481
5488
|
formatSettings = csvSettings;
|
|
5482
5489
|
// <- TODO: [π€ΉββοΈ] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
|
|
5483
5490
|
}
|
|
5484
|
-
const resultString = await subvalueParser.mapValues(
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
|
|
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
|
+
});
|
|
5497
5511
|
}
|
|
5498
|
-
|
|
5512
|
+
catch (error) {
|
|
5513
|
+
if (!(error instanceof PipelineExecutionError)) {
|
|
5514
|
+
throw error;
|
|
5515
|
+
}
|
|
5516
|
+
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
5499
5517
|
${error.message}
|
|
5500
5518
|
|
|
5501
5519
|
This is error in FOREACH command
|
|
@@ -5504,23 +5522,24 @@ async function executeFormatSubvalues(options) {
|
|
|
5504
5522
|
${block(pipelineIdentification)}
|
|
5505
5523
|
Subparameter index: ${index}
|
|
5506
5524
|
`));
|
|
5507
|
-
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
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) => `
|
|
5519
5537
|
${block(pipelineIdentification)}
|
|
5520
5538
|
Subparameter index: ${index}
|
|
5521
5539
|
`),
|
|
5522
|
-
|
|
5523
|
-
|
|
5540
|
+
});
|
|
5541
|
+
return subresultString;
|
|
5542
|
+
},
|
|
5524
5543
|
});
|
|
5525
5544
|
return resultString;
|
|
5526
5545
|
}
|
|
@@ -5694,11 +5713,6 @@ async function getReservedParametersForTask(options) {
|
|
|
5694
5713
|
async function executeTask(options) {
|
|
5695
5714
|
const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, } = options;
|
|
5696
5715
|
const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
|
|
5697
|
-
await onProgress({
|
|
5698
|
-
outputParameters: {
|
|
5699
|
-
[currentTask.resultingParameterName]: '', // <- TODO: [π§ ] What is the best value here?
|
|
5700
|
-
},
|
|
5701
|
-
});
|
|
5702
5716
|
// Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but itβs good to doublecheck
|
|
5703
5717
|
const usedParameterNames = extractParameterNamesFromTask(currentTask);
|
|
5704
5718
|
const dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
@@ -5773,6 +5787,7 @@ async function executeTask(options) {
|
|
|
5773
5787
|
preparedPipeline,
|
|
5774
5788
|
tools,
|
|
5775
5789
|
$executionReport,
|
|
5790
|
+
onProgress,
|
|
5776
5791
|
pipelineIdentification,
|
|
5777
5792
|
maxExecutionAttempts,
|
|
5778
5793
|
maxParallelCount,
|