@promptbook/cli 0.92.0-21 β 0.92.0-23
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 +148 -84
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +6 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/commands/FOREACH/ForeachJson.d.ts +6 -6
- package/esm/typings/src/config.d.ts +29 -11
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +12 -9
- package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +11 -8
- package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +15 -3
- package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTask.d.ts +10 -8
- package/esm/typings/src/formats/_common/FormatParser.d.ts +5 -3
- package/esm/typings/src/formats/_common/FormatSubvalueParser.d.ts +40 -5
- package/esm/typings/src/formats/csv/utils/isValidCsvString.d.ts +1 -1
- package/esm/typings/src/formats/json/utils/isValidJsonString.d.ts +1 -1
- package/esm/typings/src/formats/xml/utils/isValidXmlString.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/LlmToolsOptions.d.ts +4 -1
- package/esm/typings/src/scrapers/_common/register/$scrapersMetadataRegister.d.ts +3 -3
- package/esm/typings/src/types/typeAliases.d.ts +9 -7
- package/esm/typings/src/utils/$Register.d.ts +8 -7
- package/esm/typings/src/utils/parameters/mapAvailableToExpectedParameters.d.ts +7 -7
- package/esm/typings/src/utils/serialization/clonePipeline.d.ts +4 -3
- package/esm/typings/src/utils/serialization/deepClone.d.ts +5 -1
- package/esm/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +3 -3
- package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +5 -4
- package/package.json +1 -1
- package/umd/index.umd.js +148 -84
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -47,7 +47,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
47
47
|
* @generated
|
|
48
48
|
* @see https://github.com/webgptorg/promptbook
|
|
49
49
|
*/
|
|
50
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-
|
|
50
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-23';
|
|
51
51
|
/**
|
|
52
52
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
53
53
|
* Note: [π] Ignore a discrepancy between file name and entity name
|
|
@@ -163,6 +163,13 @@ const DEFAULT_BOOK_OUTPUT_PARAMETER_NAME = 'result';
|
|
|
163
163
|
* @public exported from `@promptbook/core`
|
|
164
164
|
*/
|
|
165
165
|
const DEFAULT_MAX_FILE_SIZE = 100 * 1024 * 1024; // 100MB
|
|
166
|
+
/**
|
|
167
|
+
* @@@
|
|
168
|
+
*
|
|
169
|
+
* @public exported from `@promptbook/core`
|
|
170
|
+
*/
|
|
171
|
+
const BIG_DATASET_TRESHOLD = 50;
|
|
172
|
+
// <- TODO: !!!! Use
|
|
166
173
|
/**
|
|
167
174
|
* Warning message for the generated sections and files files
|
|
168
175
|
*
|
|
@@ -247,6 +254,7 @@ const DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [π€ΉββοΈ]
|
|
|
247
254
|
* @public exported from `@promptbook/core`
|
|
248
255
|
*/
|
|
249
256
|
const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [π€ΉββοΈ]
|
|
257
|
+
// <- TODO: [π]
|
|
250
258
|
/**
|
|
251
259
|
* Where to store your books
|
|
252
260
|
* This is kind of a "src" for your books
|
|
@@ -318,7 +326,7 @@ const MOMENT_ARG_THRESHOLDS = {
|
|
|
318
326
|
const DEFAULT_REMOTE_SERVER_URL = REMOTE_SERVER_URLS[0].urls[0];
|
|
319
327
|
// <- TODO: [π§ββοΈ]
|
|
320
328
|
/**
|
|
321
|
-
*
|
|
329
|
+
* Default settings for parsing and generating CSV files in Promptbook.
|
|
322
330
|
*
|
|
323
331
|
* @public exported from `@promptbook/core`
|
|
324
332
|
*/
|
|
@@ -329,13 +337,13 @@ const DEFAULT_CSV_SETTINGS = Object.freeze({
|
|
|
329
337
|
skipEmptyLines: true,
|
|
330
338
|
});
|
|
331
339
|
/**
|
|
332
|
-
*
|
|
340
|
+
* Controls whether verbose logging is enabled by default throughout the application.
|
|
333
341
|
*
|
|
334
342
|
* @public exported from `@promptbook/core`
|
|
335
343
|
*/
|
|
336
344
|
let DEFAULT_IS_VERBOSE = false;
|
|
337
345
|
/**
|
|
338
|
-
*
|
|
346
|
+
* Controls whether auto-installation of dependencies is enabled by default.
|
|
339
347
|
*
|
|
340
348
|
* @public exported from `@promptbook/core`
|
|
341
349
|
*/
|
|
@@ -355,7 +363,7 @@ const DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME = `getPipelineCollection`;
|
|
|
355
363
|
*/
|
|
356
364
|
const DEFAULT_RPM$1 = 60;
|
|
357
365
|
/**
|
|
358
|
-
*
|
|
366
|
+
* Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
|
|
359
367
|
*
|
|
360
368
|
* @private within the repository
|
|
361
369
|
*/
|
|
@@ -774,11 +782,11 @@ function normalizeTo_snake_case(text) {
|
|
|
774
782
|
}
|
|
775
783
|
|
|
776
784
|
/**
|
|
777
|
-
*
|
|
785
|
+
* Global registry for storing and managing registered entities of a given type.
|
|
778
786
|
*
|
|
779
787
|
* Note: `$` is used to indicate that this function is not a pure function - it accesses and adds variables in global scope.
|
|
780
788
|
*
|
|
781
|
-
* @private internal utility, exported are only
|
|
789
|
+
* @private internal utility, exported are only singleton instances of this class
|
|
782
790
|
*/
|
|
783
791
|
class $Register {
|
|
784
792
|
constructor(registerName) {
|
|
@@ -1472,8 +1480,12 @@ function checkSerializableAsJson(options) {
|
|
|
1472
1480
|
*/
|
|
1473
1481
|
|
|
1474
1482
|
/**
|
|
1475
|
-
*
|
|
1483
|
+
* Creates a deep clone of the given object
|
|
1476
1484
|
*
|
|
1485
|
+
* Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
|
|
1486
|
+
*
|
|
1487
|
+
* @param objectValue The object to clone.
|
|
1488
|
+
* @returns A deep, writable clone of the input object.
|
|
1477
1489
|
* @public exported from `@promptbook/utils`
|
|
1478
1490
|
*/
|
|
1479
1491
|
function deepClone(objectValue) {
|
|
@@ -2720,8 +2732,10 @@ function cacheLlmTools(llmTools, options = {}) {
|
|
|
2720
2732
|
sha256(hexEncoder.parse(JSON.stringify({ parameters, content, modelRequirements }))).toString( /* hex */));
|
|
2721
2733
|
const cacheItem = !isCacheReloaded ? await storage.getItem(key) : null;
|
|
2722
2734
|
if (cacheItem) {
|
|
2735
|
+
console.log('!!! Cache hit for key:', key);
|
|
2723
2736
|
return cacheItem.promptResult;
|
|
2724
2737
|
}
|
|
2738
|
+
console.log('!!! Cache miss for key:', key);
|
|
2725
2739
|
let promptResult;
|
|
2726
2740
|
variant: switch (prompt.modelRequirements.modelVariant) {
|
|
2727
2741
|
case 'CHAT':
|
|
@@ -3929,10 +3943,10 @@ async function $provideScrapersForNode(tools, options) {
|
|
|
3929
3943
|
*/
|
|
3930
3944
|
|
|
3931
3945
|
/**
|
|
3932
|
-
*
|
|
3946
|
+
* Global registry for storing metadata about all available scrapers and converters.
|
|
3933
3947
|
*
|
|
3934
|
-
* Note: `$` is used to indicate that this interacts with the global scope
|
|
3935
|
-
* @singleton Only one instance of each register is created per build, but
|
|
3948
|
+
* Note: `$` is used to indicate that this interacts with the global scope.
|
|
3949
|
+
* @singleton Only one instance of each register is created per build, but there can be more in different contexts (e.g., tests).
|
|
3936
3950
|
* @public exported from `@promptbook/core`
|
|
3937
3951
|
*/
|
|
3938
3952
|
const $scrapersMetadataRegister = new $Register('scrapers_metadata');
|
|
@@ -4512,7 +4526,7 @@ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"
|
|
|
4512
4526
|
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
4513
4527
|
*
|
|
4514
4528
|
* @param value The string to check
|
|
4515
|
-
* @returns
|
|
4529
|
+
* @returns `true` if the string is a valid JSON string, false otherwise
|
|
4516
4530
|
*
|
|
4517
4531
|
* @public exported from `@promptbook/utils`
|
|
4518
4532
|
*/
|
|
@@ -5426,7 +5440,7 @@ function csvParse(value /* <- TODO: string_csv */, settings, schema /* <- TODO:
|
|
|
5426
5440
|
* Function to check if a string is valid CSV
|
|
5427
5441
|
*
|
|
5428
5442
|
* @param value The string to check
|
|
5429
|
-
* @returns
|
|
5443
|
+
* @returns `true` if the string is a valid CSV string, false otherwise
|
|
5430
5444
|
*
|
|
5431
5445
|
* @public exported from `@promptbook/utils`
|
|
5432
5446
|
*/
|
|
@@ -5465,7 +5479,8 @@ const CsvFormatParser = {
|
|
|
5465
5479
|
subvalueParsers: [
|
|
5466
5480
|
{
|
|
5467
5481
|
subvalueName: 'ROW',
|
|
5468
|
-
async mapValues(
|
|
5482
|
+
async mapValues(options) {
|
|
5483
|
+
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
5469
5484
|
const csv = csvParse(value, settings);
|
|
5470
5485
|
if (csv.errors.length !== 0) {
|
|
5471
5486
|
throw new CsvFormatError(spaceTrim((block) => `
|
|
@@ -5481,21 +5496,30 @@ const CsvFormatParser = {
|
|
|
5481
5496
|
${block(value)}
|
|
5482
5497
|
`));
|
|
5483
5498
|
}
|
|
5484
|
-
const mappedData =
|
|
5499
|
+
const mappedData = [];
|
|
5500
|
+
const length = csv.data.length;
|
|
5501
|
+
for (let index = 0; index < length; index++) {
|
|
5502
|
+
const row = csv.data[index];
|
|
5485
5503
|
if (row[outputParameterName]) {
|
|
5486
5504
|
throw new CsvFormatError(`Can not overwrite existing column "${outputParameterName}" in CSV row`);
|
|
5487
5505
|
}
|
|
5488
|
-
|
|
5506
|
+
const mappedRow = {
|
|
5489
5507
|
...row,
|
|
5490
|
-
[outputParameterName]: await mapCallback(row, index),
|
|
5508
|
+
[outputParameterName]: await mapCallback(row, index, length),
|
|
5491
5509
|
};
|
|
5492
|
-
|
|
5510
|
+
mappedData.push(mappedRow);
|
|
5511
|
+
if (onProgress) {
|
|
5512
|
+
// Note: Report the CSV with all rows mapped so far
|
|
5513
|
+
await onProgress(unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS }));
|
|
5514
|
+
}
|
|
5515
|
+
}
|
|
5493
5516
|
return unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
|
|
5494
5517
|
},
|
|
5495
5518
|
},
|
|
5496
5519
|
{
|
|
5497
5520
|
subvalueName: 'CELL',
|
|
5498
|
-
async mapValues(
|
|
5521
|
+
async mapValues(options) {
|
|
5522
|
+
const { value, settings, mapCallback, onProgress } = options;
|
|
5499
5523
|
const csv = csvParse(value, settings);
|
|
5500
5524
|
if (csv.errors.length !== 0) {
|
|
5501
5525
|
throw new CsvFormatError(spaceTrim((block) => `
|
|
@@ -5512,9 +5536,9 @@ const CsvFormatParser = {
|
|
|
5512
5536
|
`));
|
|
5513
5537
|
}
|
|
5514
5538
|
const mappedData = await Promise.all(csv.data.map(async (row, rowIndex) => {
|
|
5515
|
-
return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex) => {
|
|
5539
|
+
return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex, array) => {
|
|
5516
5540
|
const index = rowIndex * Object.keys(row).length + columnIndex;
|
|
5517
|
-
return /* not await */ mapCallback({ [key]: value }, index);
|
|
5541
|
+
return /* not await */ mapCallback({ [key]: value }, index, array.length);
|
|
5518
5542
|
}));
|
|
5519
5543
|
}));
|
|
5520
5544
|
return unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
|
|
@@ -5582,14 +5606,15 @@ const TextFormatParser = {
|
|
|
5582
5606
|
subvalueParsers: [
|
|
5583
5607
|
{
|
|
5584
5608
|
subvalueName: 'LINE',
|
|
5585
|
-
async mapValues(
|
|
5609
|
+
async mapValues(options) {
|
|
5610
|
+
const { value, mapCallback, onProgress } = options;
|
|
5586
5611
|
const lines = value.split('\n');
|
|
5587
|
-
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber) =>
|
|
5612
|
+
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber, array) =>
|
|
5588
5613
|
// TODO: [π§ ] Maybe option to skip empty line
|
|
5589
5614
|
/* not await */ mapCallback({
|
|
5590
5615
|
lineContent,
|
|
5591
5616
|
// TODO: [π§ ] Maybe also put here `lineNumber`
|
|
5592
|
-
}, lineNumber)));
|
|
5617
|
+
}, lineNumber, array.length)));
|
|
5593
5618
|
return mappedLines.join('\n');
|
|
5594
5619
|
},
|
|
5595
5620
|
},
|
|
@@ -5610,7 +5635,7 @@ const TextFormatParser = {
|
|
|
5610
5635
|
* Function to check if a string is valid XML
|
|
5611
5636
|
*
|
|
5612
5637
|
* @param value
|
|
5613
|
-
* @returns
|
|
5638
|
+
* @returns `true` if the string is a valid XML string, false otherwise
|
|
5614
5639
|
*
|
|
5615
5640
|
* @public exported from `@promptbook/utils`
|
|
5616
5641
|
*/
|
|
@@ -5672,13 +5697,13 @@ const FORMAT_DEFINITIONS = [JsonFormatParser, XmlFormatParser, TextFormatParser,
|
|
|
5672
5697
|
*/
|
|
5673
5698
|
|
|
5674
5699
|
/**
|
|
5675
|
-
* Maps available parameters to expected parameters
|
|
5700
|
+
* Maps available parameters to expected parameters for a pipeline task.
|
|
5676
5701
|
*
|
|
5677
5702
|
* The strategy is:
|
|
5678
|
-
* 1)
|
|
5679
|
-
* 2)
|
|
5703
|
+
* 1) First, match parameters by name where both available and expected.
|
|
5704
|
+
* 2) Then, if there are unmatched expected and available parameters, map them by order.
|
|
5680
5705
|
*
|
|
5681
|
-
* @throws {PipelineExecutionError}
|
|
5706
|
+
* @throws {PipelineExecutionError} If the number of unmatched expected and available parameters does not match, or mapping is ambiguous.
|
|
5682
5707
|
* @private within the repository used in `createPipelineExecutor`
|
|
5683
5708
|
*/
|
|
5684
5709
|
function mapAvailableToExpectedParameters(options) {
|
|
@@ -6417,12 +6442,16 @@ async function executeAttempts(options) {
|
|
|
6417
6442
|
*/
|
|
6418
6443
|
|
|
6419
6444
|
/**
|
|
6420
|
-
*
|
|
6445
|
+
* Executes a pipeline task that requires mapping or iterating over subvalues of a parameter (such as rows in a CSV).
|
|
6446
|
+
* Handles format and subformat resolution, error handling, and progress reporting.
|
|
6447
|
+
*
|
|
6448
|
+
* @param options - Options for execution, including task details and progress callback.
|
|
6449
|
+
* @returns The result of the subvalue mapping or execution attempts.
|
|
6421
6450
|
*
|
|
6422
6451
|
* @private internal utility of `createPipelineExecutor`
|
|
6423
6452
|
*/
|
|
6424
6453
|
async function executeFormatSubvalues(options) {
|
|
6425
|
-
const { task, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification } = options;
|
|
6454
|
+
const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, pipelineIdentification } = options;
|
|
6426
6455
|
if (task.foreach === undefined) {
|
|
6427
6456
|
return /* not await */ executeAttempts(options);
|
|
6428
6457
|
}
|
|
@@ -6476,46 +6505,74 @@ async function executeFormatSubvalues(options) {
|
|
|
6476
6505
|
formatSettings = csvSettings;
|
|
6477
6506
|
// <- TODO: [π€ΉββοΈ] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
|
|
6478
6507
|
}
|
|
6479
|
-
const resultString = await subvalueParser.mapValues(
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6508
|
+
const resultString = await subvalueParser.mapValues({
|
|
6509
|
+
value: parameterValue,
|
|
6510
|
+
outputParameterName: task.foreach.outputSubparameterName,
|
|
6511
|
+
settings: formatSettings,
|
|
6512
|
+
onProgress(partialResultString) {
|
|
6513
|
+
return onProgress(Object.freeze({
|
|
6514
|
+
[task.resultingParameterName]: partialResultString,
|
|
6515
|
+
}));
|
|
6516
|
+
},
|
|
6517
|
+
async mapCallback(subparameters, index, length) {
|
|
6518
|
+
let mappedParameters;
|
|
6519
|
+
try {
|
|
6520
|
+
mappedParameters = mapAvailableToExpectedParameters({
|
|
6521
|
+
expectedParameters: Object.fromEntries(task.foreach.inputSubparameterNames.map((subparameterName) => [subparameterName, null])),
|
|
6522
|
+
availableParameters: subparameters,
|
|
6523
|
+
});
|
|
6492
6524
|
}
|
|
6493
|
-
|
|
6494
|
-
|
|
6525
|
+
catch (error) {
|
|
6526
|
+
if (!(error instanceof PipelineExecutionError)) {
|
|
6527
|
+
throw error;
|
|
6528
|
+
}
|
|
6529
|
+
const highLevelError = new PipelineExecutionError(spaceTrim((block) => `
|
|
6530
|
+
${error.message}
|
|
6495
6531
|
|
|
6496
|
-
|
|
6497
|
-
|
|
6532
|
+
This is error in FOREACH command when mapping data
|
|
6533
|
+
You have probbably passed wrong data to pipeline or wrong data was generated which are processed by FOREACH command
|
|
6498
6534
|
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6535
|
+
${block(pipelineIdentification)}
|
|
6536
|
+
Subparameter index: ${index}
|
|
6537
|
+
`));
|
|
6538
|
+
if (length > BIG_DATASET_TRESHOLD) {
|
|
6539
|
+
console.error(highLevelError);
|
|
6540
|
+
return '~';
|
|
6541
|
+
}
|
|
6542
|
+
throw highLevelError;
|
|
6543
|
+
}
|
|
6544
|
+
const allSubparameters = {
|
|
6545
|
+
...parameters,
|
|
6546
|
+
...mappedParameters,
|
|
6547
|
+
};
|
|
6548
|
+
Object.freeze(allSubparameters);
|
|
6549
|
+
try {
|
|
6550
|
+
const subresultString = await executeAttempts({
|
|
6551
|
+
...options,
|
|
6552
|
+
priority: priority + index,
|
|
6553
|
+
parameters: allSubparameters,
|
|
6554
|
+
pipelineIdentification: spaceTrim((block) => `
|
|
6555
|
+
${block(pipelineIdentification)}
|
|
6556
|
+
Subparameter index: ${index}
|
|
6557
|
+
`),
|
|
6558
|
+
});
|
|
6559
|
+
return subresultString;
|
|
6560
|
+
}
|
|
6561
|
+
catch (error) {
|
|
6562
|
+
if (length > BIG_DATASET_TRESHOLD) {
|
|
6563
|
+
console.error(spaceTrim((block) => `
|
|
6564
|
+
Error in FOREACH command:
|
|
6565
|
+
|
|
6566
|
+
${block(pipelineIdentification)}
|
|
6567
|
+
|
|
6568
|
+
${block(pipelineIdentification)}
|
|
6569
|
+
Subparameter index: ${index}
|
|
6570
|
+
`));
|
|
6571
|
+
return '~';
|
|
6572
|
+
}
|
|
6573
|
+
throw error;
|
|
6574
|
+
}
|
|
6575
|
+
},
|
|
6519
6576
|
});
|
|
6520
6577
|
return resultString;
|
|
6521
6578
|
}
|
|
@@ -6649,7 +6706,11 @@ async function getKnowledgeForTask(options) {
|
|
|
6649
6706
|
*/
|
|
6650
6707
|
|
|
6651
6708
|
/**
|
|
6652
|
-
*
|
|
6709
|
+
* Retrieves all reserved parameters for a given pipeline task, including context, knowledge, examples, and metadata.
|
|
6710
|
+
* Ensures all reserved parameters are defined and throws if any are missing.
|
|
6711
|
+
*
|
|
6712
|
+
* @param options - Options including tools, pipeline, task, and context.
|
|
6713
|
+
* @returns An object containing all reserved parameters for the task.
|
|
6653
6714
|
*
|
|
6654
6715
|
* @private internal utility of `createPipelineExecutor`
|
|
6655
6716
|
*/
|
|
@@ -6682,18 +6743,16 @@ async function getReservedParametersForTask(options) {
|
|
|
6682
6743
|
}
|
|
6683
6744
|
|
|
6684
6745
|
/**
|
|
6685
|
-
*
|
|
6746
|
+
* Executes a single task within a pipeline, handling parameter validation, error checking, and progress reporting.
|
|
6747
|
+
*
|
|
6748
|
+
* @param options - Options for execution, including the task, pipeline, parameters, and callbacks.
|
|
6749
|
+
* @returns The output parameters produced by the task.
|
|
6686
6750
|
*
|
|
6687
6751
|
* @private internal utility of `createPipelineExecutor`
|
|
6688
6752
|
*/
|
|
6689
6753
|
async function executeTask(options) {
|
|
6690
6754
|
const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, } = options;
|
|
6691
6755
|
const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
|
|
6692
|
-
await onProgress({
|
|
6693
|
-
outputParameters: {
|
|
6694
|
-
[currentTask.resultingParameterName]: '', // <- TODO: [π§ ] What is the best value here?
|
|
6695
|
-
},
|
|
6696
|
-
});
|
|
6697
6756
|
// Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but itβs good to doublecheck
|
|
6698
6757
|
const usedParameterNames = extractParameterNamesFromTask(currentTask);
|
|
6699
6758
|
const dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
@@ -6768,6 +6827,7 @@ async function executeTask(options) {
|
|
|
6768
6827
|
preparedPipeline,
|
|
6769
6828
|
tools,
|
|
6770
6829
|
$executionReport,
|
|
6830
|
+
onProgress,
|
|
6771
6831
|
pipelineIdentification,
|
|
6772
6832
|
maxExecutionAttempts,
|
|
6773
6833
|
maxParallelCount,
|
|
@@ -6820,9 +6880,12 @@ function filterJustOutputParameters(options) {
|
|
|
6820
6880
|
}
|
|
6821
6881
|
|
|
6822
6882
|
/**
|
|
6823
|
-
*
|
|
6883
|
+
* Executes an entire pipeline, resolving tasks in dependency order, handling errors, and reporting progress.
|
|
6824
6884
|
*
|
|
6825
|
-
* Note: This is not a `PipelineExecutor` (which is
|
|
6885
|
+
* Note: This is not a `PipelineExecutor` (which is bound to a single pipeline), but a utility function used by `createPipelineExecutor` to create a `PipelineExecutor`.
|
|
6886
|
+
*
|
|
6887
|
+
* @param options - Options for execution, including input parameters, pipeline, and callbacks.
|
|
6888
|
+
* @returns The result of the pipeline execution, including output parameters, errors, and usage statistics.
|
|
6826
6889
|
*
|
|
6827
6890
|
* @private internal utility of `createPipelineExecutor`
|
|
6828
6891
|
*/
|
|
@@ -8548,11 +8611,12 @@ function removeQuotes(text) {
|
|
|
8548
8611
|
}
|
|
8549
8612
|
|
|
8550
8613
|
/**
|
|
8551
|
-
* Function `validateParameterName` will
|
|
8614
|
+
* Function `validateParameterName` will normalize and validate a parameter name for use in pipelines.
|
|
8615
|
+
* It removes diacritics, emojis, and quotes, normalizes to camelCase, and checks for reserved names and invalid characters.
|
|
8552
8616
|
*
|
|
8553
|
-
* @param parameterName
|
|
8554
|
-
* @returns
|
|
8555
|
-
* @throws {ParseError}
|
|
8617
|
+
* @param parameterName The parameter name to validate and normalize.
|
|
8618
|
+
* @returns The validated and normalized parameter name.
|
|
8619
|
+
* @throws {ParseError} If the parameter name is empty, reserved, or contains invalid characters.
|
|
8556
8620
|
* @private within the repository
|
|
8557
8621
|
*/
|
|
8558
8622
|
function validateParameterName(parameterName) {
|
|
@@ -9726,10 +9790,10 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
|
9726
9790
|
}
|
|
9727
9791
|
|
|
9728
9792
|
/**
|
|
9729
|
-
*
|
|
9793
|
+
* Checks if the given value is a valid JavaScript identifier name.
|
|
9730
9794
|
*
|
|
9731
|
-
* @param javascriptName
|
|
9732
|
-
* @returns
|
|
9795
|
+
* @param javascriptName The value to check for JavaScript identifier validity.
|
|
9796
|
+
* @returns `true` if the value is a valid JavaScript name, false otherwise.
|
|
9733
9797
|
* @public exported from `@promptbook/utils`
|
|
9734
9798
|
*/
|
|
9735
9799
|
function isValidJavascriptName(javascriptName) {
|