@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
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { string_parameter_name } from '../../../types/typeAliases';
|
|
2
2
|
/**
|
|
3
|
-
* Function `validateParameterName` will
|
|
3
|
+
* Function `validateParameterName` will normalize and validate a parameter name for use in pipelines.
|
|
4
|
+
* It removes diacritics, emojis, and quotes, normalizes to camelCase, and checks for reserved names and invalid characters.
|
|
4
5
|
*
|
|
5
|
-
* @param parameterName
|
|
6
|
-
* @returns
|
|
7
|
-
* @throws {ParseError}
|
|
6
|
+
* @param parameterName The parameter name to validate and normalize.
|
|
7
|
+
* @returns The validated and normalized parameter name.
|
|
8
|
+
* @throws {ParseError} If the parameter name is empty, reserved, or contains invalid characters.
|
|
8
9
|
* @private within the repository
|
|
9
10
|
*/
|
|
10
11
|
export declare function validateParameterName(parameterName: string): string_parameter_name;
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
* @generated
|
|
58
58
|
* @see https://github.com/webgptorg/promptbook
|
|
59
59
|
*/
|
|
60
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-
|
|
60
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-23';
|
|
61
61
|
/**
|
|
62
62
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
63
63
|
* Note: [π] Ignore a discrepancy between file name and entity name
|
|
@@ -173,6 +173,13 @@
|
|
|
173
173
|
* @public exported from `@promptbook/core`
|
|
174
174
|
*/
|
|
175
175
|
const DEFAULT_MAX_FILE_SIZE = 100 * 1024 * 1024; // 100MB
|
|
176
|
+
/**
|
|
177
|
+
* @@@
|
|
178
|
+
*
|
|
179
|
+
* @public exported from `@promptbook/core`
|
|
180
|
+
*/
|
|
181
|
+
const BIG_DATASET_TRESHOLD = 50;
|
|
182
|
+
// <- TODO: !!!! Use
|
|
176
183
|
/**
|
|
177
184
|
* Warning message for the generated sections and files files
|
|
178
185
|
*
|
|
@@ -257,6 +264,7 @@
|
|
|
257
264
|
* @public exported from `@promptbook/core`
|
|
258
265
|
*/
|
|
259
266
|
const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [π€ΉββοΈ]
|
|
267
|
+
// <- TODO: [π]
|
|
260
268
|
/**
|
|
261
269
|
* Where to store your books
|
|
262
270
|
* This is kind of a "src" for your books
|
|
@@ -328,7 +336,7 @@
|
|
|
328
336
|
const DEFAULT_REMOTE_SERVER_URL = REMOTE_SERVER_URLS[0].urls[0];
|
|
329
337
|
// <- TODO: [π§ββοΈ]
|
|
330
338
|
/**
|
|
331
|
-
*
|
|
339
|
+
* Default settings for parsing and generating CSV files in Promptbook.
|
|
332
340
|
*
|
|
333
341
|
* @public exported from `@promptbook/core`
|
|
334
342
|
*/
|
|
@@ -339,13 +347,13 @@
|
|
|
339
347
|
skipEmptyLines: true,
|
|
340
348
|
});
|
|
341
349
|
/**
|
|
342
|
-
*
|
|
350
|
+
* Controls whether verbose logging is enabled by default throughout the application.
|
|
343
351
|
*
|
|
344
352
|
* @public exported from `@promptbook/core`
|
|
345
353
|
*/
|
|
346
354
|
let DEFAULT_IS_VERBOSE = false;
|
|
347
355
|
/**
|
|
348
|
-
*
|
|
356
|
+
* Controls whether auto-installation of dependencies is enabled by default.
|
|
349
357
|
*
|
|
350
358
|
* @public exported from `@promptbook/core`
|
|
351
359
|
*/
|
|
@@ -365,7 +373,7 @@
|
|
|
365
373
|
*/
|
|
366
374
|
const DEFAULT_RPM$1 = 60;
|
|
367
375
|
/**
|
|
368
|
-
*
|
|
376
|
+
* Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
|
|
369
377
|
*
|
|
370
378
|
* @private within the repository
|
|
371
379
|
*/
|
|
@@ -784,11 +792,11 @@
|
|
|
784
792
|
}
|
|
785
793
|
|
|
786
794
|
/**
|
|
787
|
-
*
|
|
795
|
+
* Global registry for storing and managing registered entities of a given type.
|
|
788
796
|
*
|
|
789
797
|
* Note: `$` is used to indicate that this function is not a pure function - it accesses and adds variables in global scope.
|
|
790
798
|
*
|
|
791
|
-
* @private internal utility, exported are only
|
|
799
|
+
* @private internal utility, exported are only singleton instances of this class
|
|
792
800
|
*/
|
|
793
801
|
class $Register {
|
|
794
802
|
constructor(registerName) {
|
|
@@ -1482,8 +1490,12 @@
|
|
|
1482
1490
|
*/
|
|
1483
1491
|
|
|
1484
1492
|
/**
|
|
1485
|
-
*
|
|
1493
|
+
* Creates a deep clone of the given object
|
|
1486
1494
|
*
|
|
1495
|
+
* Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
|
|
1496
|
+
*
|
|
1497
|
+
* @param objectValue The object to clone.
|
|
1498
|
+
* @returns A deep, writable clone of the input object.
|
|
1487
1499
|
* @public exported from `@promptbook/utils`
|
|
1488
1500
|
*/
|
|
1489
1501
|
function deepClone(objectValue) {
|
|
@@ -2730,8 +2742,10 @@
|
|
|
2730
2742
|
sha256__default["default"](hexEncoder__default["default"].parse(JSON.stringify({ parameters, content, modelRequirements }))).toString( /* hex */));
|
|
2731
2743
|
const cacheItem = !isCacheReloaded ? await storage.getItem(key) : null;
|
|
2732
2744
|
if (cacheItem) {
|
|
2745
|
+
console.log('!!! Cache hit for key:', key);
|
|
2733
2746
|
return cacheItem.promptResult;
|
|
2734
2747
|
}
|
|
2748
|
+
console.log('!!! Cache miss for key:', key);
|
|
2735
2749
|
let promptResult;
|
|
2736
2750
|
variant: switch (prompt.modelRequirements.modelVariant) {
|
|
2737
2751
|
case 'CHAT':
|
|
@@ -3939,10 +3953,10 @@
|
|
|
3939
3953
|
*/
|
|
3940
3954
|
|
|
3941
3955
|
/**
|
|
3942
|
-
*
|
|
3956
|
+
* Global registry for storing metadata about all available scrapers and converters.
|
|
3943
3957
|
*
|
|
3944
|
-
* Note: `$` is used to indicate that this interacts with the global scope
|
|
3945
|
-
* @singleton Only one instance of each register is created per build, but
|
|
3958
|
+
* Note: `$` is used to indicate that this interacts with the global scope.
|
|
3959
|
+
* @singleton Only one instance of each register is created per build, but there can be more in different contexts (e.g., tests).
|
|
3946
3960
|
* @public exported from `@promptbook/core`
|
|
3947
3961
|
*/
|
|
3948
3962
|
const $scrapersMetadataRegister = new $Register('scrapers_metadata');
|
|
@@ -4522,7 +4536,7 @@
|
|
|
4522
4536
|
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
4523
4537
|
*
|
|
4524
4538
|
* @param value The string to check
|
|
4525
|
-
* @returns
|
|
4539
|
+
* @returns `true` if the string is a valid JSON string, false otherwise
|
|
4526
4540
|
*
|
|
4527
4541
|
* @public exported from `@promptbook/utils`
|
|
4528
4542
|
*/
|
|
@@ -5436,7 +5450,7 @@
|
|
|
5436
5450
|
* Function to check if a string is valid CSV
|
|
5437
5451
|
*
|
|
5438
5452
|
* @param value The string to check
|
|
5439
|
-
* @returns
|
|
5453
|
+
* @returns `true` if the string is a valid CSV string, false otherwise
|
|
5440
5454
|
*
|
|
5441
5455
|
* @public exported from `@promptbook/utils`
|
|
5442
5456
|
*/
|
|
@@ -5475,7 +5489,8 @@
|
|
|
5475
5489
|
subvalueParsers: [
|
|
5476
5490
|
{
|
|
5477
5491
|
subvalueName: 'ROW',
|
|
5478
|
-
async mapValues(
|
|
5492
|
+
async mapValues(options) {
|
|
5493
|
+
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
5479
5494
|
const csv = csvParse(value, settings);
|
|
5480
5495
|
if (csv.errors.length !== 0) {
|
|
5481
5496
|
throw new CsvFormatError(spaceTrim__default["default"]((block) => `
|
|
@@ -5491,21 +5506,30 @@
|
|
|
5491
5506
|
${block(value)}
|
|
5492
5507
|
`));
|
|
5493
5508
|
}
|
|
5494
|
-
const mappedData =
|
|
5509
|
+
const mappedData = [];
|
|
5510
|
+
const length = csv.data.length;
|
|
5511
|
+
for (let index = 0; index < length; index++) {
|
|
5512
|
+
const row = csv.data[index];
|
|
5495
5513
|
if (row[outputParameterName]) {
|
|
5496
5514
|
throw new CsvFormatError(`Can not overwrite existing column "${outputParameterName}" in CSV row`);
|
|
5497
5515
|
}
|
|
5498
|
-
|
|
5516
|
+
const mappedRow = {
|
|
5499
5517
|
...row,
|
|
5500
|
-
[outputParameterName]: await mapCallback(row, index),
|
|
5518
|
+
[outputParameterName]: await mapCallback(row, index, length),
|
|
5501
5519
|
};
|
|
5502
|
-
|
|
5520
|
+
mappedData.push(mappedRow);
|
|
5521
|
+
if (onProgress) {
|
|
5522
|
+
// Note: Report the CSV with all rows mapped so far
|
|
5523
|
+
await onProgress(papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS }));
|
|
5524
|
+
}
|
|
5525
|
+
}
|
|
5503
5526
|
return papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
|
|
5504
5527
|
},
|
|
5505
5528
|
},
|
|
5506
5529
|
{
|
|
5507
5530
|
subvalueName: 'CELL',
|
|
5508
|
-
async mapValues(
|
|
5531
|
+
async mapValues(options) {
|
|
5532
|
+
const { value, settings, mapCallback, onProgress } = options;
|
|
5509
5533
|
const csv = csvParse(value, settings);
|
|
5510
5534
|
if (csv.errors.length !== 0) {
|
|
5511
5535
|
throw new CsvFormatError(spaceTrim__default["default"]((block) => `
|
|
@@ -5522,9 +5546,9 @@
|
|
|
5522
5546
|
`));
|
|
5523
5547
|
}
|
|
5524
5548
|
const mappedData = await Promise.all(csv.data.map(async (row, rowIndex) => {
|
|
5525
|
-
return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex) => {
|
|
5549
|
+
return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex, array) => {
|
|
5526
5550
|
const index = rowIndex * Object.keys(row).length + columnIndex;
|
|
5527
|
-
return /* not await */ mapCallback({ [key]: value }, index);
|
|
5551
|
+
return /* not await */ mapCallback({ [key]: value }, index, array.length);
|
|
5528
5552
|
}));
|
|
5529
5553
|
}));
|
|
5530
5554
|
return papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
|
|
@@ -5592,14 +5616,15 @@
|
|
|
5592
5616
|
subvalueParsers: [
|
|
5593
5617
|
{
|
|
5594
5618
|
subvalueName: 'LINE',
|
|
5595
|
-
async mapValues(
|
|
5619
|
+
async mapValues(options) {
|
|
5620
|
+
const { value, mapCallback, onProgress } = options;
|
|
5596
5621
|
const lines = value.split('\n');
|
|
5597
|
-
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber) =>
|
|
5622
|
+
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber, array) =>
|
|
5598
5623
|
// TODO: [π§ ] Maybe option to skip empty line
|
|
5599
5624
|
/* not await */ mapCallback({
|
|
5600
5625
|
lineContent,
|
|
5601
5626
|
// TODO: [π§ ] Maybe also put here `lineNumber`
|
|
5602
|
-
}, lineNumber)));
|
|
5627
|
+
}, lineNumber, array.length)));
|
|
5603
5628
|
return mappedLines.join('\n');
|
|
5604
5629
|
},
|
|
5605
5630
|
},
|
|
@@ -5620,7 +5645,7 @@
|
|
|
5620
5645
|
* Function to check if a string is valid XML
|
|
5621
5646
|
*
|
|
5622
5647
|
* @param value
|
|
5623
|
-
* @returns
|
|
5648
|
+
* @returns `true` if the string is a valid XML string, false otherwise
|
|
5624
5649
|
*
|
|
5625
5650
|
* @public exported from `@promptbook/utils`
|
|
5626
5651
|
*/
|
|
@@ -5682,13 +5707,13 @@
|
|
|
5682
5707
|
*/
|
|
5683
5708
|
|
|
5684
5709
|
/**
|
|
5685
|
-
* Maps available parameters to expected parameters
|
|
5710
|
+
* Maps available parameters to expected parameters for a pipeline task.
|
|
5686
5711
|
*
|
|
5687
5712
|
* The strategy is:
|
|
5688
|
-
* 1)
|
|
5689
|
-
* 2)
|
|
5713
|
+
* 1) First, match parameters by name where both available and expected.
|
|
5714
|
+
* 2) Then, if there are unmatched expected and available parameters, map them by order.
|
|
5690
5715
|
*
|
|
5691
|
-
* @throws {PipelineExecutionError}
|
|
5716
|
+
* @throws {PipelineExecutionError} If the number of unmatched expected and available parameters does not match, or mapping is ambiguous.
|
|
5692
5717
|
* @private within the repository used in `createPipelineExecutor`
|
|
5693
5718
|
*/
|
|
5694
5719
|
function mapAvailableToExpectedParameters(options) {
|
|
@@ -6427,12 +6452,16 @@
|
|
|
6427
6452
|
*/
|
|
6428
6453
|
|
|
6429
6454
|
/**
|
|
6430
|
-
*
|
|
6455
|
+
* Executes a pipeline task that requires mapping or iterating over subvalues of a parameter (such as rows in a CSV).
|
|
6456
|
+
* Handles format and subformat resolution, error handling, and progress reporting.
|
|
6457
|
+
*
|
|
6458
|
+
* @param options - Options for execution, including task details and progress callback.
|
|
6459
|
+
* @returns The result of the subvalue mapping or execution attempts.
|
|
6431
6460
|
*
|
|
6432
6461
|
* @private internal utility of `createPipelineExecutor`
|
|
6433
6462
|
*/
|
|
6434
6463
|
async function executeFormatSubvalues(options) {
|
|
6435
|
-
const { task, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification } = options;
|
|
6464
|
+
const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, pipelineIdentification } = options;
|
|
6436
6465
|
if (task.foreach === undefined) {
|
|
6437
6466
|
return /* not await */ executeAttempts(options);
|
|
6438
6467
|
}
|
|
@@ -6486,46 +6515,74 @@
|
|
|
6486
6515
|
formatSettings = csvSettings;
|
|
6487
6516
|
// <- TODO: [π€ΉββοΈ] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
|
|
6488
6517
|
}
|
|
6489
|
-
const resultString = await subvalueParser.mapValues(
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6518
|
+
const resultString = await subvalueParser.mapValues({
|
|
6519
|
+
value: parameterValue,
|
|
6520
|
+
outputParameterName: task.foreach.outputSubparameterName,
|
|
6521
|
+
settings: formatSettings,
|
|
6522
|
+
onProgress(partialResultString) {
|
|
6523
|
+
return onProgress(Object.freeze({
|
|
6524
|
+
[task.resultingParameterName]: partialResultString,
|
|
6525
|
+
}));
|
|
6526
|
+
},
|
|
6527
|
+
async mapCallback(subparameters, index, length) {
|
|
6528
|
+
let mappedParameters;
|
|
6529
|
+
try {
|
|
6530
|
+
mappedParameters = mapAvailableToExpectedParameters({
|
|
6531
|
+
expectedParameters: Object.fromEntries(task.foreach.inputSubparameterNames.map((subparameterName) => [subparameterName, null])),
|
|
6532
|
+
availableParameters: subparameters,
|
|
6533
|
+
});
|
|
6502
6534
|
}
|
|
6503
|
-
|
|
6504
|
-
|
|
6535
|
+
catch (error) {
|
|
6536
|
+
if (!(error instanceof PipelineExecutionError)) {
|
|
6537
|
+
throw error;
|
|
6538
|
+
}
|
|
6539
|
+
const highLevelError = new PipelineExecutionError(spaceTrim__default["default"]((block) => `
|
|
6540
|
+
${error.message}
|
|
6505
6541
|
|
|
6506
|
-
|
|
6507
|
-
|
|
6542
|
+
This is error in FOREACH command when mapping data
|
|
6543
|
+
You have probbably passed wrong data to pipeline or wrong data was generated which are processed by FOREACH command
|
|
6508
6544
|
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
|
|
6522
|
-
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6545
|
+
${block(pipelineIdentification)}
|
|
6546
|
+
Subparameter index: ${index}
|
|
6547
|
+
`));
|
|
6548
|
+
if (length > BIG_DATASET_TRESHOLD) {
|
|
6549
|
+
console.error(highLevelError);
|
|
6550
|
+
return '~';
|
|
6551
|
+
}
|
|
6552
|
+
throw highLevelError;
|
|
6553
|
+
}
|
|
6554
|
+
const allSubparameters = {
|
|
6555
|
+
...parameters,
|
|
6556
|
+
...mappedParameters,
|
|
6557
|
+
};
|
|
6558
|
+
Object.freeze(allSubparameters);
|
|
6559
|
+
try {
|
|
6560
|
+
const subresultString = await executeAttempts({
|
|
6561
|
+
...options,
|
|
6562
|
+
priority: priority + index,
|
|
6563
|
+
parameters: allSubparameters,
|
|
6564
|
+
pipelineIdentification: spaceTrim__default["default"]((block) => `
|
|
6565
|
+
${block(pipelineIdentification)}
|
|
6566
|
+
Subparameter index: ${index}
|
|
6567
|
+
`),
|
|
6568
|
+
});
|
|
6569
|
+
return subresultString;
|
|
6570
|
+
}
|
|
6571
|
+
catch (error) {
|
|
6572
|
+
if (length > BIG_DATASET_TRESHOLD) {
|
|
6573
|
+
console.error(spaceTrim__default["default"]((block) => `
|
|
6574
|
+
Error in FOREACH command:
|
|
6575
|
+
|
|
6576
|
+
${block(pipelineIdentification)}
|
|
6577
|
+
|
|
6578
|
+
${block(pipelineIdentification)}
|
|
6579
|
+
Subparameter index: ${index}
|
|
6580
|
+
`));
|
|
6581
|
+
return '~';
|
|
6582
|
+
}
|
|
6583
|
+
throw error;
|
|
6584
|
+
}
|
|
6585
|
+
},
|
|
6529
6586
|
});
|
|
6530
6587
|
return resultString;
|
|
6531
6588
|
}
|
|
@@ -6659,7 +6716,11 @@
|
|
|
6659
6716
|
*/
|
|
6660
6717
|
|
|
6661
6718
|
/**
|
|
6662
|
-
*
|
|
6719
|
+
* Retrieves all reserved parameters for a given pipeline task, including context, knowledge, examples, and metadata.
|
|
6720
|
+
* Ensures all reserved parameters are defined and throws if any are missing.
|
|
6721
|
+
*
|
|
6722
|
+
* @param options - Options including tools, pipeline, task, and context.
|
|
6723
|
+
* @returns An object containing all reserved parameters for the task.
|
|
6663
6724
|
*
|
|
6664
6725
|
* @private internal utility of `createPipelineExecutor`
|
|
6665
6726
|
*/
|
|
@@ -6692,18 +6753,16 @@
|
|
|
6692
6753
|
}
|
|
6693
6754
|
|
|
6694
6755
|
/**
|
|
6695
|
-
*
|
|
6756
|
+
* Executes a single task within a pipeline, handling parameter validation, error checking, and progress reporting.
|
|
6757
|
+
*
|
|
6758
|
+
* @param options - Options for execution, including the task, pipeline, parameters, and callbacks.
|
|
6759
|
+
* @returns The output parameters produced by the task.
|
|
6696
6760
|
*
|
|
6697
6761
|
* @private internal utility of `createPipelineExecutor`
|
|
6698
6762
|
*/
|
|
6699
6763
|
async function executeTask(options) {
|
|
6700
6764
|
const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, } = options;
|
|
6701
6765
|
const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
|
|
6702
|
-
await onProgress({
|
|
6703
|
-
outputParameters: {
|
|
6704
|
-
[currentTask.resultingParameterName]: '', // <- TODO: [π§ ] What is the best value here?
|
|
6705
|
-
},
|
|
6706
|
-
});
|
|
6707
6766
|
// Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but itβs good to doublecheck
|
|
6708
6767
|
const usedParameterNames = extractParameterNamesFromTask(currentTask);
|
|
6709
6768
|
const dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
@@ -6778,6 +6837,7 @@
|
|
|
6778
6837
|
preparedPipeline,
|
|
6779
6838
|
tools,
|
|
6780
6839
|
$executionReport,
|
|
6840
|
+
onProgress,
|
|
6781
6841
|
pipelineIdentification,
|
|
6782
6842
|
maxExecutionAttempts,
|
|
6783
6843
|
maxParallelCount,
|
|
@@ -6830,9 +6890,12 @@
|
|
|
6830
6890
|
}
|
|
6831
6891
|
|
|
6832
6892
|
/**
|
|
6833
|
-
*
|
|
6893
|
+
* Executes an entire pipeline, resolving tasks in dependency order, handling errors, and reporting progress.
|
|
6834
6894
|
*
|
|
6835
|
-
* Note: This is not a `PipelineExecutor` (which is
|
|
6895
|
+
* Note: This is not a `PipelineExecutor` (which is bound to a single pipeline), but a utility function used by `createPipelineExecutor` to create a `PipelineExecutor`.
|
|
6896
|
+
*
|
|
6897
|
+
* @param options - Options for execution, including input parameters, pipeline, and callbacks.
|
|
6898
|
+
* @returns The result of the pipeline execution, including output parameters, errors, and usage statistics.
|
|
6836
6899
|
*
|
|
6837
6900
|
* @private internal utility of `createPipelineExecutor`
|
|
6838
6901
|
*/
|
|
@@ -8558,11 +8621,12 @@
|
|
|
8558
8621
|
}
|
|
8559
8622
|
|
|
8560
8623
|
/**
|
|
8561
|
-
* Function `validateParameterName` will
|
|
8624
|
+
* Function `validateParameterName` will normalize and validate a parameter name for use in pipelines.
|
|
8625
|
+
* It removes diacritics, emojis, and quotes, normalizes to camelCase, and checks for reserved names and invalid characters.
|
|
8562
8626
|
*
|
|
8563
|
-
* @param parameterName
|
|
8564
|
-
* @returns
|
|
8565
|
-
* @throws {ParseError}
|
|
8627
|
+
* @param parameterName The parameter name to validate and normalize.
|
|
8628
|
+
* @returns The validated and normalized parameter name.
|
|
8629
|
+
* @throws {ParseError} If the parameter name is empty, reserved, or contains invalid characters.
|
|
8566
8630
|
* @private within the repository
|
|
8567
8631
|
*/
|
|
8568
8632
|
function validateParameterName(parameterName) {
|
|
@@ -9736,10 +9800,10 @@
|
|
|
9736
9800
|
}
|
|
9737
9801
|
|
|
9738
9802
|
/**
|
|
9739
|
-
*
|
|
9803
|
+
* Checks if the given value is a valid JavaScript identifier name.
|
|
9740
9804
|
*
|
|
9741
|
-
* @param javascriptName
|
|
9742
|
-
* @returns
|
|
9805
|
+
* @param javascriptName The value to check for JavaScript identifier validity.
|
|
9806
|
+
* @returns `true` if the value is a valid JavaScript name, false otherwise.
|
|
9743
9807
|
* @public exported from `@promptbook/utils`
|
|
9744
9808
|
*/
|
|
9745
9809
|
function isValidJavascriptName(javascriptName) {
|