@promptbook/node 0.92.0-22 → 0.92.0-24
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 +128 -66
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +6 -0
- package/esm/typings/src/collection/PipelineCollection.d.ts +0 -2
- package/esm/typings/src/collection/SimplePipelineCollection.d.ts +1 -1
- package/esm/typings/src/commands/FOREACH/ForeachJson.d.ts +6 -6
- package/esm/typings/src/commands/FORMFACTOR/formfactorCommandParser.d.ts +1 -1
- package/esm/typings/src/config.d.ts +33 -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 +8 -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 +31 -6
- 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/formfactors/_boilerplate/BoilerplateFormfactorDefinition.d.ts +3 -2
- package/esm/typings/src/formfactors/_common/string_formfactor_name.d.ts +2 -1
- package/esm/typings/src/formfactors/index.d.ts +1 -1
- package/esm/typings/src/formfactors/sheets/SheetsFormfactorDefinition.d.ts +3 -2
- package/esm/typings/src/llm-providers/_common/register/LlmToolsOptions.d.ts +4 -1
- package/esm/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +3 -3
- 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/environment/$getGlobalScope.d.ts +2 -1
- 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 +2 -2
- package/umd/index.umd.js +128 -66
- package/umd/index.umd.js.map +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { really_any } from '../organization/really_any';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Safely retrieves the global scope object (window in browser, global in Node.js)
|
|
4
|
+
* regardless of the JavaScript environment in which the code is running
|
|
4
5
|
*
|
|
5
6
|
* Note: `$` is used to indicate that this function is not a pure function - it access global scope
|
|
6
7
|
*
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import type { string_parameter_name } from '../../types/typeAliases';
|
|
2
2
|
import type { string_parameter_value } from '../../types/typeAliases';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Options for mapping available parameters to expected parameters in a pipeline task.
|
|
5
5
|
*/
|
|
6
6
|
type MakeapAvailableToExpectedParametersOptions = {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* The set of expected parameter names (keys) for the task, all values are null.
|
|
9
9
|
*/
|
|
10
10
|
readonly expectedParameters: Readonly<Record<string_parameter_name, null>>;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* The set of available parameters (name-value pairs) to map to the expected parameters.
|
|
13
13
|
*/
|
|
14
14
|
readonly availableParameters: Readonly<Record<string_parameter_name, string_parameter_value>>;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
|
-
* Maps available parameters to expected parameters
|
|
17
|
+
* Maps available parameters to expected parameters for a pipeline task.
|
|
18
18
|
*
|
|
19
19
|
* The strategy is:
|
|
20
|
-
* 1)
|
|
21
|
-
* 2)
|
|
20
|
+
* 1) First, match parameters by name where both available and expected.
|
|
21
|
+
* 2) Then, if there are unmatched expected and available parameters, map them by order.
|
|
22
22
|
*
|
|
23
|
-
* @throws {PipelineExecutionError}
|
|
23
|
+
* @throws {PipelineExecutionError} If the number of unmatched expected and available parameters does not match, or mapping is ambiguous.
|
|
24
24
|
* @private within the repository used in `createPipelineExecutor`
|
|
25
25
|
*/
|
|
26
26
|
export declare function mapAvailableToExpectedParameters(options: MakeapAvailableToExpectedParametersOptions): Readonly<Record<string_parameter_name, string_parameter_value>>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Creates a deep clone of a PipelineJson object, copying all properties explicitly.
|
|
4
4
|
*
|
|
5
|
-
* Note: It is
|
|
5
|
+
* Note: It is useful for ensuring that modifications to the returned pipeline do not affect the original.
|
|
6
6
|
*
|
|
7
|
-
* @param pipeline
|
|
7
|
+
* @param pipeline The pipeline to clone.
|
|
8
|
+
* @returns A new PipelineJson object with the same properties as the input.
|
|
8
9
|
* @public exported from `@promptbook/utils`
|
|
9
10
|
*/
|
|
10
11
|
export declare function clonePipeline(pipeline: PipelineJson): PipelineJson;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { WritableDeep } from 'type-fest';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Creates a deep clone of the given object
|
|
4
4
|
*
|
|
5
|
+
* Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
|
|
6
|
+
*
|
|
7
|
+
* @param objectValue The object to clone.
|
|
8
|
+
* @returns A deep, writable clone of the input object.
|
|
5
9
|
* @public exported from `@promptbook/utils`
|
|
6
10
|
*/
|
|
7
11
|
export declare function deepClone<TObject>(objectValue: TObject): WritableDeep<TObject>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { string_javascript_name } from '../../../types/typeAliases';
|
|
2
2
|
import type { really_unknown } from '../../organization/really_unknown';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Checks if the given value is a valid JavaScript identifier name.
|
|
5
5
|
*
|
|
6
|
-
* @param javascriptName
|
|
7
|
-
* @returns
|
|
6
|
+
* @param javascriptName The value to check for JavaScript identifier validity.
|
|
7
|
+
* @returns `true` if the value is a valid JavaScript name, false otherwise.
|
|
8
8
|
* @public exported from `@promptbook/utils`
|
|
9
9
|
*/
|
|
10
10
|
export declare function isValidJavascriptName(javascriptName: really_unknown): javascriptName is string_javascript_name;
|
|
@@ -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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/node",
|
|
3
|
-
"version": "0.92.0-
|
|
3
|
+
"version": "0.92.0-24",
|
|
4
4
|
"description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"module": "./esm/index.es.js",
|
|
52
52
|
"typings": "./esm/typings/src/_packages/node.index.d.ts",
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@promptbook/core": "0.92.0-
|
|
54
|
+
"@promptbook/core": "0.92.0-24"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
* @generated
|
|
47
47
|
* @see https://github.com/webgptorg/promptbook
|
|
48
48
|
*/
|
|
49
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-
|
|
49
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-24';
|
|
50
50
|
/**
|
|
51
51
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
52
52
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -117,6 +117,21 @@
|
|
|
117
117
|
* @public exported from `@promptbook/core`
|
|
118
118
|
*/
|
|
119
119
|
const DEFAULT_MAX_FILE_SIZE = 100 * 1024 * 1024; // 100MB
|
|
120
|
+
/**
|
|
121
|
+
* Threshold value that determines when a dataset is considered "big"
|
|
122
|
+
* and may require special handling or optimizations
|
|
123
|
+
*
|
|
124
|
+
* For example, when error occurs in one item of the big dataset, it will not fail the whole pipeline
|
|
125
|
+
*
|
|
126
|
+
* @public exported from `@promptbook/core`
|
|
127
|
+
*/
|
|
128
|
+
const BIG_DATASET_TRESHOLD = 50;
|
|
129
|
+
/**
|
|
130
|
+
* Placeholder text used to represent a placeholder value of failed operation
|
|
131
|
+
*
|
|
132
|
+
* @public exported from `@promptbook/core`
|
|
133
|
+
*/
|
|
134
|
+
const FAILED_VALUE_PLACEHOLDER = '!?';
|
|
120
135
|
// <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
|
|
121
136
|
/**
|
|
122
137
|
* The maximum number of iterations for a loops
|
|
@@ -211,7 +226,7 @@
|
|
|
211
226
|
const DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME = `index`;
|
|
212
227
|
// <- TODO: [🧜♂️]
|
|
213
228
|
/**
|
|
214
|
-
*
|
|
229
|
+
* Default settings for parsing and generating CSV files in Promptbook.
|
|
215
230
|
*
|
|
216
231
|
* @public exported from `@promptbook/core`
|
|
217
232
|
*/
|
|
@@ -222,19 +237,19 @@
|
|
|
222
237
|
skipEmptyLines: true,
|
|
223
238
|
});
|
|
224
239
|
/**
|
|
225
|
-
*
|
|
240
|
+
* Controls whether verbose logging is enabled by default throughout the application.
|
|
226
241
|
*
|
|
227
242
|
* @public exported from `@promptbook/core`
|
|
228
243
|
*/
|
|
229
244
|
let DEFAULT_IS_VERBOSE = false;
|
|
230
245
|
/**
|
|
231
|
-
*
|
|
246
|
+
* Controls whether auto-installation of dependencies is enabled by default.
|
|
232
247
|
*
|
|
233
248
|
* @public exported from `@promptbook/core`
|
|
234
249
|
*/
|
|
235
250
|
const DEFAULT_IS_AUTO_INSTALLED = false;
|
|
236
251
|
/**
|
|
237
|
-
*
|
|
252
|
+
* Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
|
|
238
253
|
*
|
|
239
254
|
* @private within the repository
|
|
240
255
|
*/
|
|
@@ -580,8 +595,12 @@
|
|
|
580
595
|
*/
|
|
581
596
|
|
|
582
597
|
/**
|
|
583
|
-
*
|
|
598
|
+
* Creates a deep clone of the given object
|
|
599
|
+
*
|
|
600
|
+
* Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
|
|
584
601
|
*
|
|
602
|
+
* @param objectValue The object to clone.
|
|
603
|
+
* @returns A deep, writable clone of the input object.
|
|
585
604
|
* @public exported from `@promptbook/utils`
|
|
586
605
|
*/
|
|
587
606
|
function deepClone(objectValue) {
|
|
@@ -1220,7 +1239,7 @@
|
|
|
1220
1239
|
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
1221
1240
|
*
|
|
1222
1241
|
* @param value The string to check
|
|
1223
|
-
* @returns
|
|
1242
|
+
* @returns `true` if the string is a valid JSON string, false otherwise
|
|
1224
1243
|
*
|
|
1225
1244
|
* @public exported from `@promptbook/utils`
|
|
1226
1245
|
*/
|
|
@@ -1542,7 +1561,7 @@
|
|
|
1542
1561
|
/**
|
|
1543
1562
|
* Constructs a pipeline collection from pipelines
|
|
1544
1563
|
*
|
|
1545
|
-
* @param pipelines
|
|
1564
|
+
* @param pipelines Array of pipeline JSON objects to include in the collection
|
|
1546
1565
|
*
|
|
1547
1566
|
* Note: During the construction logic of all pipelines are validated
|
|
1548
1567
|
* Note: It is not recommended to use this constructor directly, use `createCollectionFromJson` *(or other variant)* instead
|
|
@@ -2562,7 +2581,7 @@
|
|
|
2562
2581
|
* Function to check if a string is valid CSV
|
|
2563
2582
|
*
|
|
2564
2583
|
* @param value The string to check
|
|
2565
|
-
* @returns
|
|
2584
|
+
* @returns `true` if the string is a valid CSV string, false otherwise
|
|
2566
2585
|
*
|
|
2567
2586
|
* @public exported from `@promptbook/utils`
|
|
2568
2587
|
*/
|
|
@@ -2619,18 +2638,28 @@
|
|
|
2619
2638
|
`));
|
|
2620
2639
|
}
|
|
2621
2640
|
const mappedData = [];
|
|
2622
|
-
|
|
2641
|
+
const length = csv.data.length;
|
|
2642
|
+
for (let index = 0; index < length; index++) {
|
|
2623
2643
|
const row = csv.data[index];
|
|
2624
2644
|
if (row[outputParameterName]) {
|
|
2625
2645
|
throw new CsvFormatError(`Can not overwrite existing column "${outputParameterName}" in CSV row`);
|
|
2626
2646
|
}
|
|
2627
2647
|
const mappedRow = {
|
|
2628
2648
|
...row,
|
|
2629
|
-
[outputParameterName]: await mapCallback(row, index),
|
|
2649
|
+
[outputParameterName]: await mapCallback(row, index, length),
|
|
2630
2650
|
};
|
|
2631
2651
|
mappedData.push(mappedRow);
|
|
2632
2652
|
if (onProgress) {
|
|
2633
2653
|
// Note: Report the CSV with all rows mapped so far
|
|
2654
|
+
/*
|
|
2655
|
+
!!!!
|
|
2656
|
+
// Report progress with updated value
|
|
2657
|
+
const progressData = mappedData.map((row, i) =>
|
|
2658
|
+
i > index ? { ...row, [outputParameterName]: PENDING_VALUE_PLACEHOLDER } : row,
|
|
2659
|
+
);
|
|
2660
|
+
|
|
2661
|
+
|
|
2662
|
+
*/
|
|
2634
2663
|
await onProgress(papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS }));
|
|
2635
2664
|
}
|
|
2636
2665
|
}
|
|
@@ -2657,9 +2686,9 @@
|
|
|
2657
2686
|
`));
|
|
2658
2687
|
}
|
|
2659
2688
|
const mappedData = await Promise.all(csv.data.map(async (row, rowIndex) => {
|
|
2660
|
-
return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex) => {
|
|
2689
|
+
return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex, array) => {
|
|
2661
2690
|
const index = rowIndex * Object.keys(row).length + columnIndex;
|
|
2662
|
-
return /* not await */ mapCallback({ [key]: value }, index);
|
|
2691
|
+
return /* not await */ mapCallback({ [key]: value }, index, array.length);
|
|
2663
2692
|
}));
|
|
2664
2693
|
}));
|
|
2665
2694
|
return papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
|
|
@@ -2730,12 +2759,12 @@
|
|
|
2730
2759
|
async mapValues(options) {
|
|
2731
2760
|
const { value, mapCallback, onProgress } = options;
|
|
2732
2761
|
const lines = value.split('\n');
|
|
2733
|
-
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber) =>
|
|
2762
|
+
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber, array) =>
|
|
2734
2763
|
// TODO: [🧠] Maybe option to skip empty line
|
|
2735
2764
|
/* not await */ mapCallback({
|
|
2736
2765
|
lineContent,
|
|
2737
2766
|
// TODO: [🧠] Maybe also put here `lineNumber`
|
|
2738
|
-
}, lineNumber)));
|
|
2767
|
+
}, lineNumber, array.length)));
|
|
2739
2768
|
return mappedLines.join('\n');
|
|
2740
2769
|
},
|
|
2741
2770
|
},
|
|
@@ -2756,7 +2785,7 @@
|
|
|
2756
2785
|
* Function to check if a string is valid XML
|
|
2757
2786
|
*
|
|
2758
2787
|
* @param value
|
|
2759
|
-
* @returns
|
|
2788
|
+
* @returns `true` if the string is a valid XML string, false otherwise
|
|
2760
2789
|
*
|
|
2761
2790
|
* @public exported from `@promptbook/utils`
|
|
2762
2791
|
*/
|
|
@@ -2818,13 +2847,13 @@
|
|
|
2818
2847
|
*/
|
|
2819
2848
|
|
|
2820
2849
|
/**
|
|
2821
|
-
* Maps available parameters to expected parameters
|
|
2850
|
+
* Maps available parameters to expected parameters for a pipeline task.
|
|
2822
2851
|
*
|
|
2823
2852
|
* The strategy is:
|
|
2824
|
-
* 1)
|
|
2825
|
-
* 2)
|
|
2853
|
+
* 1) First, match parameters by name where both available and expected.
|
|
2854
|
+
* 2) Then, if there are unmatched expected and available parameters, map them by order.
|
|
2826
2855
|
*
|
|
2827
|
-
* @throws {PipelineExecutionError}
|
|
2856
|
+
* @throws {PipelineExecutionError} If the number of unmatched expected and available parameters does not match, or mapping is ambiguous.
|
|
2828
2857
|
* @private within the repository used in `createPipelineExecutor`
|
|
2829
2858
|
*/
|
|
2830
2859
|
function mapAvailableToExpectedParameters(options) {
|
|
@@ -4033,7 +4062,11 @@
|
|
|
4033
4062
|
*/
|
|
4034
4063
|
|
|
4035
4064
|
/**
|
|
4036
|
-
*
|
|
4065
|
+
* Executes a pipeline task that requires mapping or iterating over subvalues of a parameter (such as rows in a CSV).
|
|
4066
|
+
* Handles format and subformat resolution, error handling, and progress reporting.
|
|
4067
|
+
*
|
|
4068
|
+
* @param options - Options for execution, including task details and progress callback.
|
|
4069
|
+
* @returns The result of the subvalue mapping or execution attempts.
|
|
4037
4070
|
*
|
|
4038
4071
|
* @private internal utility of `createPipelineExecutor`
|
|
4039
4072
|
*/
|
|
@@ -4098,15 +4131,11 @@
|
|
|
4098
4131
|
settings: formatSettings,
|
|
4099
4132
|
onProgress(partialResultString) {
|
|
4100
4133
|
return onProgress(Object.freeze({
|
|
4101
|
-
[task.resultingParameterName]:
|
|
4102
|
-
// <- Note: [👩👩👧] No need to detect parameter collision here because pipeline checks logic consistency during construction
|
|
4103
|
-
partialResultString,
|
|
4134
|
+
[task.resultingParameterName]: partialResultString,
|
|
4104
4135
|
}));
|
|
4105
4136
|
},
|
|
4106
|
-
async mapCallback(subparameters, index) {
|
|
4137
|
+
async mapCallback(subparameters, index, length) {
|
|
4107
4138
|
let mappedParameters;
|
|
4108
|
-
// TODO: [🤹♂️][🪂] Limit to N concurrent executions
|
|
4109
|
-
// TODO: When done [🐚] Report progress also for each subvalue here
|
|
4110
4139
|
try {
|
|
4111
4140
|
mappedParameters = mapAvailableToExpectedParameters({
|
|
4112
4141
|
expectedParameters: Object.fromEntries(task.foreach.inputSubparameterNames.map((subparameterName) => [subparameterName, null])),
|
|
@@ -4117,32 +4146,52 @@
|
|
|
4117
4146
|
if (!(error instanceof PipelineExecutionError)) {
|
|
4118
4147
|
throw error;
|
|
4119
4148
|
}
|
|
4120
|
-
|
|
4121
|
-
|
|
4149
|
+
const highLevelError = new PipelineExecutionError(spaceTrim__default["default"]((block) => `
|
|
4150
|
+
${error.message}
|
|
4122
4151
|
|
|
4123
|
-
|
|
4124
|
-
|
|
4152
|
+
This is error in FOREACH command when mapping data
|
|
4153
|
+
You have probbably passed wrong data to pipeline or wrong data was generated which are processed by FOREACH command
|
|
4125
4154
|
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4155
|
+
${block(pipelineIdentification)}
|
|
4156
|
+
Subparameter index: ${index}
|
|
4157
|
+
`));
|
|
4158
|
+
if (length > BIG_DATASET_TRESHOLD) {
|
|
4159
|
+
console.error(highLevelError);
|
|
4160
|
+
return FAILED_VALUE_PLACEHOLDER;
|
|
4161
|
+
}
|
|
4162
|
+
throw highLevelError;
|
|
4129
4163
|
}
|
|
4130
4164
|
const allSubparameters = {
|
|
4131
4165
|
...parameters,
|
|
4132
4166
|
...mappedParameters,
|
|
4133
4167
|
};
|
|
4134
|
-
// 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
|
|
4135
4168
|
Object.freeze(allSubparameters);
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4169
|
+
try {
|
|
4170
|
+
const subresultString = await executeAttempts({
|
|
4171
|
+
...options,
|
|
4172
|
+
priority: priority + index,
|
|
4173
|
+
parameters: allSubparameters,
|
|
4174
|
+
pipelineIdentification: spaceTrim__default["default"]((block) => `
|
|
4175
|
+
${block(pipelineIdentification)}
|
|
4176
|
+
Subparameter index: ${index}
|
|
4177
|
+
`),
|
|
4178
|
+
});
|
|
4179
|
+
return subresultString;
|
|
4180
|
+
}
|
|
4181
|
+
catch (error) {
|
|
4182
|
+
if (length > BIG_DATASET_TRESHOLD) {
|
|
4183
|
+
console.error(spaceTrim__default["default"]((block) => `
|
|
4184
|
+
Error in FOREACH command:
|
|
4185
|
+
|
|
4186
|
+
${block(pipelineIdentification)}
|
|
4187
|
+
|
|
4188
|
+
${block(pipelineIdentification)}
|
|
4189
|
+
Subparameter index: ${index}
|
|
4190
|
+
`));
|
|
4191
|
+
return FAILED_VALUE_PLACEHOLDER;
|
|
4192
|
+
}
|
|
4193
|
+
throw error;
|
|
4194
|
+
}
|
|
4146
4195
|
},
|
|
4147
4196
|
});
|
|
4148
4197
|
return resultString;
|
|
@@ -4277,7 +4326,11 @@
|
|
|
4277
4326
|
*/
|
|
4278
4327
|
|
|
4279
4328
|
/**
|
|
4280
|
-
*
|
|
4329
|
+
* Retrieves all reserved parameters for a given pipeline task, including context, knowledge, examples, and metadata.
|
|
4330
|
+
* Ensures all reserved parameters are defined and throws if any are missing.
|
|
4331
|
+
*
|
|
4332
|
+
* @param options - Options including tools, pipeline, task, and context.
|
|
4333
|
+
* @returns An object containing all reserved parameters for the task.
|
|
4281
4334
|
*
|
|
4282
4335
|
* @private internal utility of `createPipelineExecutor`
|
|
4283
4336
|
*/
|
|
@@ -4310,7 +4363,10 @@
|
|
|
4310
4363
|
}
|
|
4311
4364
|
|
|
4312
4365
|
/**
|
|
4313
|
-
*
|
|
4366
|
+
* Executes a single task within a pipeline, handling parameter validation, error checking, and progress reporting.
|
|
4367
|
+
*
|
|
4368
|
+
* @param options - Options for execution, including the task, pipeline, parameters, and callbacks.
|
|
4369
|
+
* @returns The output parameters produced by the task.
|
|
4314
4370
|
*
|
|
4315
4371
|
* @private internal utility of `createPipelineExecutor`
|
|
4316
4372
|
*/
|
|
@@ -4444,9 +4500,12 @@
|
|
|
4444
4500
|
}
|
|
4445
4501
|
|
|
4446
4502
|
/**
|
|
4447
|
-
*
|
|
4503
|
+
* Executes an entire pipeline, resolving tasks in dependency order, handling errors, and reporting progress.
|
|
4448
4504
|
*
|
|
4449
|
-
* Note: This is not a `PipelineExecutor` (which is
|
|
4505
|
+
* Note: This is not a `PipelineExecutor` (which is bound to a single pipeline), but a utility function used by `createPipelineExecutor` to create a `PipelineExecutor`.
|
|
4506
|
+
*
|
|
4507
|
+
* @param options - Options for execution, including input parameters, pipeline, and callbacks.
|
|
4508
|
+
* @returns The result of the pipeline execution, including output parameters, errors, and usage statistics.
|
|
4450
4509
|
*
|
|
4451
4510
|
* @private internal utility of `createPipelineExecutor`
|
|
4452
4511
|
*/
|
|
@@ -4968,7 +5027,8 @@
|
|
|
4968
5027
|
*/
|
|
4969
5028
|
|
|
4970
5029
|
/**
|
|
4971
|
-
*
|
|
5030
|
+
* Safely retrieves the global scope object (window in browser, global in Node.js)
|
|
5031
|
+
* regardless of the JavaScript environment in which the code is running
|
|
4972
5032
|
*
|
|
4973
5033
|
* Note: `$` is used to indicate that this function is not a pure function - it access global scope
|
|
4974
5034
|
*
|
|
@@ -5047,11 +5107,11 @@
|
|
|
5047
5107
|
}
|
|
5048
5108
|
|
|
5049
5109
|
/**
|
|
5050
|
-
*
|
|
5110
|
+
* Global registry for storing and managing registered entities of a given type.
|
|
5051
5111
|
*
|
|
5052
5112
|
* Note: `$` is used to indicate that this function is not a pure function - it accesses and adds variables in global scope.
|
|
5053
5113
|
*
|
|
5054
|
-
* @private internal utility, exported are only
|
|
5114
|
+
* @private internal utility, exported are only singleton instances of this class
|
|
5055
5115
|
*/
|
|
5056
5116
|
class $Register {
|
|
5057
5117
|
constructor(registerName) {
|
|
@@ -5095,10 +5155,10 @@
|
|
|
5095
5155
|
}
|
|
5096
5156
|
|
|
5097
5157
|
/**
|
|
5098
|
-
*
|
|
5158
|
+
* Global registry for storing metadata about all available scrapers and converters.
|
|
5099
5159
|
*
|
|
5100
|
-
* Note: `$` is used to indicate that this interacts with the global scope
|
|
5101
|
-
* @singleton Only one instance of each register is created per build, but
|
|
5160
|
+
* Note: `$` is used to indicate that this interacts with the global scope.
|
|
5161
|
+
* @singleton Only one instance of each register is created per build, but there can be more in different contexts (e.g., tests).
|
|
5102
5162
|
* @public exported from `@promptbook/core`
|
|
5103
5163
|
*/
|
|
5104
5164
|
const $scrapersMetadataRegister = new $Register('scrapers_metadata');
|
|
@@ -6637,11 +6697,12 @@
|
|
|
6637
6697
|
}
|
|
6638
6698
|
|
|
6639
6699
|
/**
|
|
6640
|
-
* Function `validateParameterName` will
|
|
6700
|
+
* Function `validateParameterName` will normalize and validate a parameter name for use in pipelines.
|
|
6701
|
+
* It removes diacritics, emojis, and quotes, normalizes to camelCase, and checks for reserved names and invalid characters.
|
|
6641
6702
|
*
|
|
6642
|
-
* @param parameterName
|
|
6643
|
-
* @returns
|
|
6644
|
-
* @throws {ParseError}
|
|
6703
|
+
* @param parameterName The parameter name to validate and normalize.
|
|
6704
|
+
* @returns The validated and normalized parameter name.
|
|
6705
|
+
* @throws {ParseError} If the parameter name is empty, reserved, or contains invalid characters.
|
|
6645
6706
|
* @private within the repository
|
|
6646
6707
|
*/
|
|
6647
6708
|
function validateParameterName(parameterName) {
|
|
@@ -7134,14 +7195,15 @@
|
|
|
7134
7195
|
};
|
|
7135
7196
|
|
|
7136
7197
|
/**
|
|
7137
|
-
* Sheets is form of app that
|
|
7198
|
+
* Sheets is form of app that processes tabular data in CSV format, allowing transformation
|
|
7199
|
+
* and analysis of structured data through AI-powered operations
|
|
7138
7200
|
*
|
|
7139
7201
|
* @public exported from `@promptbook/core`
|
|
7140
7202
|
*/
|
|
7141
7203
|
const SheetsFormfactorDefinition = {
|
|
7142
7204
|
name: 'SHEETS',
|
|
7143
7205
|
aliasNames: ['SHEETS', 'SHEET'],
|
|
7144
|
-
description:
|
|
7206
|
+
description: `A formfactor for processing spreadsheet-like data in CSV format, enabling AI transformations on tabular data`,
|
|
7145
7207
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/176`,
|
|
7146
7208
|
pipelineInterface: {
|
|
7147
7209
|
inputParameters: [
|
|
@@ -7217,7 +7279,7 @@
|
|
|
7217
7279
|
/**
|
|
7218
7280
|
* Parses the formfactor command
|
|
7219
7281
|
*
|
|
7220
|
-
* Note:
|
|
7282
|
+
* Note: This command is used as a formfactor for new commands and defines the app type format - it should NOT be used in any `.book` file
|
|
7221
7283
|
*
|
|
7222
7284
|
* @see `documentationUrl` for more details
|
|
7223
7285
|
* @public exported from `@promptbook/editable`
|
|
@@ -7239,7 +7301,7 @@
|
|
|
7239
7301
|
/**
|
|
7240
7302
|
* Description of the FORMFACTOR command
|
|
7241
7303
|
*/
|
|
7242
|
-
description:
|
|
7304
|
+
description: `Specifies the application type and interface requirements that this promptbook should conform to`,
|
|
7243
7305
|
/**
|
|
7244
7306
|
* Link to documentation
|
|
7245
7307
|
*/
|
|
@@ -7815,10 +7877,10 @@
|
|
|
7815
7877
|
}
|
|
7816
7878
|
|
|
7817
7879
|
/**
|
|
7818
|
-
*
|
|
7880
|
+
* Checks if the given value is a valid JavaScript identifier name.
|
|
7819
7881
|
*
|
|
7820
|
-
* @param javascriptName
|
|
7821
|
-
* @returns
|
|
7882
|
+
* @param javascriptName The value to check for JavaScript identifier validity.
|
|
7883
|
+
* @returns `true` if the value is a valid JavaScript name, false otherwise.
|
|
7822
7884
|
* @public exported from `@promptbook/utils`
|
|
7823
7885
|
*/
|
|
7824
7886
|
function isValidJavascriptName(javascriptName) {
|