@promptbook/cli 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 +144 -69
- 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 +1 -1
- package/umd/index.umd.js +144 -69
- 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-24';
|
|
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,22 @@ 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
|
+
* Threshold value that determines when a dataset is considered "big"
|
|
168
|
+
* and may require special handling or optimizations
|
|
169
|
+
*
|
|
170
|
+
* For example, when error occurs in one item of the big dataset, it will not fail the whole pipeline
|
|
171
|
+
*
|
|
172
|
+
* @public exported from `@promptbook/core`
|
|
173
|
+
*/
|
|
174
|
+
const BIG_DATASET_TRESHOLD = 50;
|
|
175
|
+
/**
|
|
176
|
+
* Placeholder text used to represent a placeholder value of failed operation
|
|
177
|
+
*
|
|
178
|
+
* @public exported from `@promptbook/core`
|
|
179
|
+
*/
|
|
180
|
+
const FAILED_VALUE_PLACEHOLDER = '!?';
|
|
181
|
+
// <- TODO: !!!! Use
|
|
166
182
|
/**
|
|
167
183
|
* Warning message for the generated sections and files files
|
|
168
184
|
*
|
|
@@ -247,6 +263,7 @@ const DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [๐คนโโ๏ธ]
|
|
|
247
263
|
* @public exported from `@promptbook/core`
|
|
248
264
|
*/
|
|
249
265
|
const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [๐คนโโ๏ธ]
|
|
266
|
+
// <- TODO: [๐]
|
|
250
267
|
/**
|
|
251
268
|
* Where to store your books
|
|
252
269
|
* This is kind of a "src" for your books
|
|
@@ -318,7 +335,7 @@ const MOMENT_ARG_THRESHOLDS = {
|
|
|
318
335
|
const DEFAULT_REMOTE_SERVER_URL = REMOTE_SERVER_URLS[0].urls[0];
|
|
319
336
|
// <- TODO: [๐งโโ๏ธ]
|
|
320
337
|
/**
|
|
321
|
-
*
|
|
338
|
+
* Default settings for parsing and generating CSV files in Promptbook.
|
|
322
339
|
*
|
|
323
340
|
* @public exported from `@promptbook/core`
|
|
324
341
|
*/
|
|
@@ -329,13 +346,13 @@ const DEFAULT_CSV_SETTINGS = Object.freeze({
|
|
|
329
346
|
skipEmptyLines: true,
|
|
330
347
|
});
|
|
331
348
|
/**
|
|
332
|
-
*
|
|
349
|
+
* Controls whether verbose logging is enabled by default throughout the application.
|
|
333
350
|
*
|
|
334
351
|
* @public exported from `@promptbook/core`
|
|
335
352
|
*/
|
|
336
353
|
let DEFAULT_IS_VERBOSE = false;
|
|
337
354
|
/**
|
|
338
|
-
*
|
|
355
|
+
* Controls whether auto-installation of dependencies is enabled by default.
|
|
339
356
|
*
|
|
340
357
|
* @public exported from `@promptbook/core`
|
|
341
358
|
*/
|
|
@@ -355,7 +372,7 @@ const DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME = `getPipelineCollection`;
|
|
|
355
372
|
*/
|
|
356
373
|
const DEFAULT_RPM$1 = 60;
|
|
357
374
|
/**
|
|
358
|
-
*
|
|
375
|
+
* Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
|
|
359
376
|
*
|
|
360
377
|
* @private within the repository
|
|
361
378
|
*/
|
|
@@ -695,7 +712,8 @@ class NotYetImplementedError extends Error {
|
|
|
695
712
|
}
|
|
696
713
|
|
|
697
714
|
/**
|
|
698
|
-
*
|
|
715
|
+
* Safely retrieves the global scope object (window in browser, global in Node.js)
|
|
716
|
+
* regardless of the JavaScript environment in which the code is running
|
|
699
717
|
*
|
|
700
718
|
* Note: `$` is used to indicate that this function is not a pure function - it access global scope
|
|
701
719
|
*
|
|
@@ -774,11 +792,11 @@ function normalizeTo_snake_case(text) {
|
|
|
774
792
|
}
|
|
775
793
|
|
|
776
794
|
/**
|
|
777
|
-
*
|
|
795
|
+
* Global registry for storing and managing registered entities of a given type.
|
|
778
796
|
*
|
|
779
797
|
* Note: `$` is used to indicate that this function is not a pure function - it accesses and adds variables in global scope.
|
|
780
798
|
*
|
|
781
|
-
* @private internal utility, exported are only
|
|
799
|
+
* @private internal utility, exported are only singleton instances of this class
|
|
782
800
|
*/
|
|
783
801
|
class $Register {
|
|
784
802
|
constructor(registerName) {
|
|
@@ -1472,8 +1490,12 @@ function checkSerializableAsJson(options) {
|
|
|
1472
1490
|
*/
|
|
1473
1491
|
|
|
1474
1492
|
/**
|
|
1475
|
-
*
|
|
1493
|
+
* Creates a deep clone of the given object
|
|
1476
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.
|
|
1477
1499
|
* @public exported from `@promptbook/utils`
|
|
1478
1500
|
*/
|
|
1479
1501
|
function deepClone(objectValue) {
|
|
@@ -2720,8 +2742,10 @@ function cacheLlmTools(llmTools, options = {}) {
|
|
|
2720
2742
|
sha256(hexEncoder.parse(JSON.stringify({ parameters, content, modelRequirements }))).toString( /* hex */));
|
|
2721
2743
|
const cacheItem = !isCacheReloaded ? await storage.getItem(key) : null;
|
|
2722
2744
|
if (cacheItem) {
|
|
2745
|
+
console.log('!!! Cache hit for key:', key);
|
|
2723
2746
|
return cacheItem.promptResult;
|
|
2724
2747
|
}
|
|
2748
|
+
console.log('!!! Cache miss for key:', key);
|
|
2725
2749
|
let promptResult;
|
|
2726
2750
|
variant: switch (prompt.modelRequirements.modelVariant) {
|
|
2727
2751
|
case 'CHAT':
|
|
@@ -2768,9 +2792,9 @@ function cacheLlmTools(llmTools, options = {}) {
|
|
|
2768
2792
|
/**
|
|
2769
2793
|
* TODO: [๐ง ][๐ธ] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
|
|
2770
2794
|
* TODO: [๐ง ] Is there some meaningfull way how to test this util
|
|
2771
|
-
* TODO: [๐ทโโ๏ธ]
|
|
2772
|
-
*
|
|
2773
|
-
*
|
|
2795
|
+
* TODO: [๐ทโโ๏ธ] Comprehensive manual about construction of llmTools
|
|
2796
|
+
* Detailed explanation about caching strategies and appropriate storage selection for different use cases
|
|
2797
|
+
* Examples of how to combine multiple interceptors for advanced caching, logging, and usage tracking
|
|
2774
2798
|
*/
|
|
2775
2799
|
|
|
2776
2800
|
/**
|
|
@@ -3929,10 +3953,10 @@ async function $provideScrapersForNode(tools, options) {
|
|
|
3929
3953
|
*/
|
|
3930
3954
|
|
|
3931
3955
|
/**
|
|
3932
|
-
*
|
|
3956
|
+
* Global registry for storing metadata about all available scrapers and converters.
|
|
3933
3957
|
*
|
|
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
|
|
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).
|
|
3936
3960
|
* @public exported from `@promptbook/core`
|
|
3937
3961
|
*/
|
|
3938
3962
|
const $scrapersMetadataRegister = new $Register('scrapers_metadata');
|
|
@@ -4512,7 +4536,7 @@ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"
|
|
|
4512
4536
|
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
4513
4537
|
*
|
|
4514
4538
|
* @param value The string to check
|
|
4515
|
-
* @returns
|
|
4539
|
+
* @returns `true` if the string is a valid JSON string, false otherwise
|
|
4516
4540
|
*
|
|
4517
4541
|
* @public exported from `@promptbook/utils`
|
|
4518
4542
|
*/
|
|
@@ -4808,7 +4832,7 @@ class SimplePipelineCollection {
|
|
|
4808
4832
|
/**
|
|
4809
4833
|
* Constructs a pipeline collection from pipelines
|
|
4810
4834
|
*
|
|
4811
|
-
* @param pipelines
|
|
4835
|
+
* @param pipelines Array of pipeline JSON objects to include in the collection
|
|
4812
4836
|
*
|
|
4813
4837
|
* Note: During the construction logic of all pipelines are validated
|
|
4814
4838
|
* Note: It is not recommended to use this constructor directly, use `createCollectionFromJson` *(or other variant)* instead
|
|
@@ -5426,7 +5450,7 @@ function csvParse(value /* <- TODO: string_csv */, settings, schema /* <- TODO:
|
|
|
5426
5450
|
* Function to check if a string is valid CSV
|
|
5427
5451
|
*
|
|
5428
5452
|
* @param value The string to check
|
|
5429
|
-
* @returns
|
|
5453
|
+
* @returns `true` if the string is a valid CSV string, false otherwise
|
|
5430
5454
|
*
|
|
5431
5455
|
* @public exported from `@promptbook/utils`
|
|
5432
5456
|
*/
|
|
@@ -5483,18 +5507,28 @@ const CsvFormatParser = {
|
|
|
5483
5507
|
`));
|
|
5484
5508
|
}
|
|
5485
5509
|
const mappedData = [];
|
|
5486
|
-
|
|
5510
|
+
const length = csv.data.length;
|
|
5511
|
+
for (let index = 0; index < length; index++) {
|
|
5487
5512
|
const row = csv.data[index];
|
|
5488
5513
|
if (row[outputParameterName]) {
|
|
5489
5514
|
throw new CsvFormatError(`Can not overwrite existing column "${outputParameterName}" in CSV row`);
|
|
5490
5515
|
}
|
|
5491
5516
|
const mappedRow = {
|
|
5492
5517
|
...row,
|
|
5493
|
-
[outputParameterName]: await mapCallback(row, index),
|
|
5518
|
+
[outputParameterName]: await mapCallback(row, index, length),
|
|
5494
5519
|
};
|
|
5495
5520
|
mappedData.push(mappedRow);
|
|
5496
5521
|
if (onProgress) {
|
|
5497
5522
|
// Note: Report the CSV with all rows mapped so far
|
|
5523
|
+
/*
|
|
5524
|
+
!!!!
|
|
5525
|
+
// Report progress with updated value
|
|
5526
|
+
const progressData = mappedData.map((row, i) =>
|
|
5527
|
+
i > index ? { ...row, [outputParameterName]: PENDING_VALUE_PLACEHOLDER } : row,
|
|
5528
|
+
);
|
|
5529
|
+
|
|
5530
|
+
|
|
5531
|
+
*/
|
|
5498
5532
|
await onProgress(unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS }));
|
|
5499
5533
|
}
|
|
5500
5534
|
}
|
|
@@ -5521,9 +5555,9 @@ const CsvFormatParser = {
|
|
|
5521
5555
|
`));
|
|
5522
5556
|
}
|
|
5523
5557
|
const mappedData = await Promise.all(csv.data.map(async (row, rowIndex) => {
|
|
5524
|
-
return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex) => {
|
|
5558
|
+
return /* not await */ Promise.all(Object.entries(row).map(async ([key, value], columnIndex, array) => {
|
|
5525
5559
|
const index = rowIndex * Object.keys(row).length + columnIndex;
|
|
5526
|
-
return /* not await */ mapCallback({ [key]: value }, index);
|
|
5560
|
+
return /* not await */ mapCallback({ [key]: value }, index, array.length);
|
|
5527
5561
|
}));
|
|
5528
5562
|
}));
|
|
5529
5563
|
return unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
|
|
@@ -5594,12 +5628,12 @@ const TextFormatParser = {
|
|
|
5594
5628
|
async mapValues(options) {
|
|
5595
5629
|
const { value, mapCallback, onProgress } = options;
|
|
5596
5630
|
const lines = value.split('\n');
|
|
5597
|
-
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber) =>
|
|
5631
|
+
const mappedLines = await Promise.all(lines.map((lineContent, lineNumber, array) =>
|
|
5598
5632
|
// TODO: [๐ง ] Maybe option to skip empty line
|
|
5599
5633
|
/* not await */ mapCallback({
|
|
5600
5634
|
lineContent,
|
|
5601
5635
|
// TODO: [๐ง ] Maybe also put here `lineNumber`
|
|
5602
|
-
}, lineNumber)));
|
|
5636
|
+
}, lineNumber, array.length)));
|
|
5603
5637
|
return mappedLines.join('\n');
|
|
5604
5638
|
},
|
|
5605
5639
|
},
|
|
@@ -5620,7 +5654,7 @@ const TextFormatParser = {
|
|
|
5620
5654
|
* Function to check if a string is valid XML
|
|
5621
5655
|
*
|
|
5622
5656
|
* @param value
|
|
5623
|
-
* @returns
|
|
5657
|
+
* @returns `true` if the string is a valid XML string, false otherwise
|
|
5624
5658
|
*
|
|
5625
5659
|
* @public exported from `@promptbook/utils`
|
|
5626
5660
|
*/
|
|
@@ -5682,13 +5716,13 @@ const FORMAT_DEFINITIONS = [JsonFormatParser, XmlFormatParser, TextFormatParser,
|
|
|
5682
5716
|
*/
|
|
5683
5717
|
|
|
5684
5718
|
/**
|
|
5685
|
-
* Maps available parameters to expected parameters
|
|
5719
|
+
* Maps available parameters to expected parameters for a pipeline task.
|
|
5686
5720
|
*
|
|
5687
5721
|
* The strategy is:
|
|
5688
|
-
* 1)
|
|
5689
|
-
* 2)
|
|
5722
|
+
* 1) First, match parameters by name where both available and expected.
|
|
5723
|
+
* 2) Then, if there are unmatched expected and available parameters, map them by order.
|
|
5690
5724
|
*
|
|
5691
|
-
* @throws {PipelineExecutionError}
|
|
5725
|
+
* @throws {PipelineExecutionError} If the number of unmatched expected and available parameters does not match, or mapping is ambiguous.
|
|
5692
5726
|
* @private within the repository used in `createPipelineExecutor`
|
|
5693
5727
|
*/
|
|
5694
5728
|
function mapAvailableToExpectedParameters(options) {
|
|
@@ -6427,7 +6461,11 @@ async function executeAttempts(options) {
|
|
|
6427
6461
|
*/
|
|
6428
6462
|
|
|
6429
6463
|
/**
|
|
6430
|
-
*
|
|
6464
|
+
* Executes a pipeline task that requires mapping or iterating over subvalues of a parameter (such as rows in a CSV).
|
|
6465
|
+
* Handles format and subformat resolution, error handling, and progress reporting.
|
|
6466
|
+
*
|
|
6467
|
+
* @param options - Options for execution, including task details and progress callback.
|
|
6468
|
+
* @returns The result of the subvalue mapping or execution attempts.
|
|
6431
6469
|
*
|
|
6432
6470
|
* @private internal utility of `createPipelineExecutor`
|
|
6433
6471
|
*/
|
|
@@ -6492,15 +6530,11 @@ async function executeFormatSubvalues(options) {
|
|
|
6492
6530
|
settings: formatSettings,
|
|
6493
6531
|
onProgress(partialResultString) {
|
|
6494
6532
|
return onProgress(Object.freeze({
|
|
6495
|
-
[task.resultingParameterName]:
|
|
6496
|
-
// <- Note: [๐ฉโ๐ฉโ๐ง] No need to detect parameter collision here because pipeline checks logic consistency during construction
|
|
6497
|
-
partialResultString,
|
|
6533
|
+
[task.resultingParameterName]: partialResultString,
|
|
6498
6534
|
}));
|
|
6499
6535
|
},
|
|
6500
|
-
async mapCallback(subparameters, index) {
|
|
6536
|
+
async mapCallback(subparameters, index, length) {
|
|
6501
6537
|
let mappedParameters;
|
|
6502
|
-
// TODO: [๐คนโโ๏ธ][๐ช] Limit to N concurrent executions
|
|
6503
|
-
// TODO: When done [๐] Report progress also for each subvalue here
|
|
6504
6538
|
try {
|
|
6505
6539
|
mappedParameters = mapAvailableToExpectedParameters({
|
|
6506
6540
|
expectedParameters: Object.fromEntries(task.foreach.inputSubparameterNames.map((subparameterName) => [subparameterName, null])),
|
|
@@ -6511,32 +6545,52 @@ async function executeFormatSubvalues(options) {
|
|
|
6511
6545
|
if (!(error instanceof PipelineExecutionError)) {
|
|
6512
6546
|
throw error;
|
|
6513
6547
|
}
|
|
6514
|
-
|
|
6515
|
-
|
|
6548
|
+
const highLevelError = new PipelineExecutionError(spaceTrim((block) => `
|
|
6549
|
+
${error.message}
|
|
6516
6550
|
|
|
6517
|
-
|
|
6518
|
-
|
|
6551
|
+
This is error in FOREACH command when mapping data
|
|
6552
|
+
You have probbably passed wrong data to pipeline or wrong data was generated which are processed by FOREACH command
|
|
6519
6553
|
|
|
6520
|
-
|
|
6521
|
-
|
|
6522
|
-
|
|
6554
|
+
${block(pipelineIdentification)}
|
|
6555
|
+
Subparameter index: ${index}
|
|
6556
|
+
`));
|
|
6557
|
+
if (length > BIG_DATASET_TRESHOLD) {
|
|
6558
|
+
console.error(highLevelError);
|
|
6559
|
+
return FAILED_VALUE_PLACEHOLDER;
|
|
6560
|
+
}
|
|
6561
|
+
throw highLevelError;
|
|
6523
6562
|
}
|
|
6524
6563
|
const allSubparameters = {
|
|
6525
6564
|
...parameters,
|
|
6526
6565
|
...mappedParameters,
|
|
6527
6566
|
};
|
|
6528
|
-
// 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
|
|
6529
6567
|
Object.freeze(allSubparameters);
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
6568
|
+
try {
|
|
6569
|
+
const subresultString = await executeAttempts({
|
|
6570
|
+
...options,
|
|
6571
|
+
priority: priority + index,
|
|
6572
|
+
parameters: allSubparameters,
|
|
6573
|
+
pipelineIdentification: spaceTrim((block) => `
|
|
6574
|
+
${block(pipelineIdentification)}
|
|
6575
|
+
Subparameter index: ${index}
|
|
6576
|
+
`),
|
|
6577
|
+
});
|
|
6578
|
+
return subresultString;
|
|
6579
|
+
}
|
|
6580
|
+
catch (error) {
|
|
6581
|
+
if (length > BIG_DATASET_TRESHOLD) {
|
|
6582
|
+
console.error(spaceTrim((block) => `
|
|
6583
|
+
Error in FOREACH command:
|
|
6584
|
+
|
|
6585
|
+
${block(pipelineIdentification)}
|
|
6586
|
+
|
|
6587
|
+
${block(pipelineIdentification)}
|
|
6588
|
+
Subparameter index: ${index}
|
|
6589
|
+
`));
|
|
6590
|
+
return FAILED_VALUE_PLACEHOLDER;
|
|
6591
|
+
}
|
|
6592
|
+
throw error;
|
|
6593
|
+
}
|
|
6540
6594
|
},
|
|
6541
6595
|
});
|
|
6542
6596
|
return resultString;
|
|
@@ -6671,7 +6725,11 @@ async function getKnowledgeForTask(options) {
|
|
|
6671
6725
|
*/
|
|
6672
6726
|
|
|
6673
6727
|
/**
|
|
6674
|
-
*
|
|
6728
|
+
* Retrieves all reserved parameters for a given pipeline task, including context, knowledge, examples, and metadata.
|
|
6729
|
+
* Ensures all reserved parameters are defined and throws if any are missing.
|
|
6730
|
+
*
|
|
6731
|
+
* @param options - Options including tools, pipeline, task, and context.
|
|
6732
|
+
* @returns An object containing all reserved parameters for the task.
|
|
6675
6733
|
*
|
|
6676
6734
|
* @private internal utility of `createPipelineExecutor`
|
|
6677
6735
|
*/
|
|
@@ -6704,7 +6762,10 @@ async function getReservedParametersForTask(options) {
|
|
|
6704
6762
|
}
|
|
6705
6763
|
|
|
6706
6764
|
/**
|
|
6707
|
-
*
|
|
6765
|
+
* Executes a single task within a pipeline, handling parameter validation, error checking, and progress reporting.
|
|
6766
|
+
*
|
|
6767
|
+
* @param options - Options for execution, including the task, pipeline, parameters, and callbacks.
|
|
6768
|
+
* @returns The output parameters produced by the task.
|
|
6708
6769
|
*
|
|
6709
6770
|
* @private internal utility of `createPipelineExecutor`
|
|
6710
6771
|
*/
|
|
@@ -6838,9 +6899,12 @@ function filterJustOutputParameters(options) {
|
|
|
6838
6899
|
}
|
|
6839
6900
|
|
|
6840
6901
|
/**
|
|
6841
|
-
*
|
|
6902
|
+
* Executes an entire pipeline, resolving tasks in dependency order, handling errors, and reporting progress.
|
|
6842
6903
|
*
|
|
6843
|
-
* Note: This is not a `PipelineExecutor` (which is
|
|
6904
|
+
* Note: This is not a `PipelineExecutor` (which is bound to a single pipeline), but a utility function used by `createPipelineExecutor` to create a `PipelineExecutor`.
|
|
6905
|
+
*
|
|
6906
|
+
* @param options - Options for execution, including input parameters, pipeline, and callbacks.
|
|
6907
|
+
* @returns The result of the pipeline execution, including output parameters, errors, and usage statistics.
|
|
6844
6908
|
*
|
|
6845
6909
|
* @private internal utility of `createPipelineExecutor`
|
|
6846
6910
|
*/
|
|
@@ -8566,11 +8630,12 @@ function removeQuotes(text) {
|
|
|
8566
8630
|
}
|
|
8567
8631
|
|
|
8568
8632
|
/**
|
|
8569
|
-
* Function `validateParameterName` will
|
|
8633
|
+
* Function `validateParameterName` will normalize and validate a parameter name for use in pipelines.
|
|
8634
|
+
* It removes diacritics, emojis, and quotes, normalizes to camelCase, and checks for reserved names and invalid characters.
|
|
8570
8635
|
*
|
|
8571
|
-
* @param parameterName
|
|
8572
|
-
* @returns
|
|
8573
|
-
* @throws {ParseError}
|
|
8636
|
+
* @param parameterName The parameter name to validate and normalize.
|
|
8637
|
+
* @returns The validated and normalized parameter name.
|
|
8638
|
+
* @throws {ParseError} If the parameter name is empty, reserved, or contains invalid characters.
|
|
8574
8639
|
* @private within the repository
|
|
8575
8640
|
*/
|
|
8576
8641
|
function validateParameterName(parameterName) {
|
|
@@ -9063,14 +9128,15 @@ const MatcherFormfactorDefinition = {
|
|
|
9063
9128
|
};
|
|
9064
9129
|
|
|
9065
9130
|
/**
|
|
9066
|
-
* Sheets is form of app that
|
|
9131
|
+
* Sheets is form of app that processes tabular data in CSV format, allowing transformation
|
|
9132
|
+
* and analysis of structured data through AI-powered operations
|
|
9067
9133
|
*
|
|
9068
9134
|
* @public exported from `@promptbook/core`
|
|
9069
9135
|
*/
|
|
9070
9136
|
const SheetsFormfactorDefinition = {
|
|
9071
9137
|
name: 'SHEETS',
|
|
9072
9138
|
aliasNames: ['SHEETS', 'SHEET'],
|
|
9073
|
-
description:
|
|
9139
|
+
description: `A formfactor for processing spreadsheet-like data in CSV format, enabling AI transformations on tabular data`,
|
|
9074
9140
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/176`,
|
|
9075
9141
|
pipelineInterface: {
|
|
9076
9142
|
inputParameters: [
|
|
@@ -9146,7 +9212,7 @@ const FORMFACTOR_DEFINITIONS = [
|
|
|
9146
9212
|
/**
|
|
9147
9213
|
* Parses the formfactor command
|
|
9148
9214
|
*
|
|
9149
|
-
* Note:
|
|
9215
|
+
* 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
|
|
9150
9216
|
*
|
|
9151
9217
|
* @see `documentationUrl` for more details
|
|
9152
9218
|
* @public exported from `@promptbook/editable`
|
|
@@ -9168,7 +9234,7 @@ const formfactorCommandParser = {
|
|
|
9168
9234
|
/**
|
|
9169
9235
|
* Description of the FORMFACTOR command
|
|
9170
9236
|
*/
|
|
9171
|
-
description:
|
|
9237
|
+
description: `Specifies the application type and interface requirements that this promptbook should conform to`,
|
|
9172
9238
|
/**
|
|
9173
9239
|
* Link to documentation
|
|
9174
9240
|
*/
|
|
@@ -9744,10 +9810,10 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
|
9744
9810
|
}
|
|
9745
9811
|
|
|
9746
9812
|
/**
|
|
9747
|
-
*
|
|
9813
|
+
* Checks if the given value is a valid JavaScript identifier name.
|
|
9748
9814
|
*
|
|
9749
|
-
* @param javascriptName
|
|
9750
|
-
* @returns
|
|
9815
|
+
* @param javascriptName The value to check for JavaScript identifier validity.
|
|
9816
|
+
* @returns `true` if the value is a valid JavaScript name, false otherwise.
|
|
9751
9817
|
* @public exported from `@promptbook/utils`
|
|
9752
9818
|
*/
|
|
9753
9819
|
function isValidJavascriptName(javascriptName) {
|
|
@@ -16900,14 +16966,23 @@ function computeOpenAiUsage(promptContent, // <- Note: Intentionally using [] to
|
|
|
16900
16966
|
resultContent, rawResponse) {
|
|
16901
16967
|
var _a, _b;
|
|
16902
16968
|
if (rawResponse.usage === undefined) {
|
|
16969
|
+
console.log('!!! computeOpenAiUsage', 'The usage is not defined in the response from OpenAI');
|
|
16903
16970
|
throw new PipelineExecutionError('The usage is not defined in the response from OpenAI');
|
|
16904
16971
|
}
|
|
16905
16972
|
if (((_a = rawResponse.usage) === null || _a === void 0 ? void 0 : _a.prompt_tokens) === undefined) {
|
|
16973
|
+
console.log('!!! computeOpenAiUsage', 'In OpenAI response `usage.prompt_tokens` not defined');
|
|
16906
16974
|
throw new PipelineExecutionError('In OpenAI response `usage.prompt_tokens` not defined');
|
|
16907
16975
|
}
|
|
16908
16976
|
const inputTokens = rawResponse.usage.prompt_tokens;
|
|
16909
16977
|
const outputTokens = ((_b = rawResponse.usage) === null || _b === void 0 ? void 0 : _b.completion_tokens) || 0;
|
|
16910
16978
|
const modelInfo = OPENAI_MODELS.find((model) => model.modelName === rawResponse.model);
|
|
16979
|
+
console.log('!!! computeOpenAiUsage', {
|
|
16980
|
+
inputTokens,
|
|
16981
|
+
outputTokens,
|
|
16982
|
+
rawResponse,
|
|
16983
|
+
resultContent,
|
|
16984
|
+
modelInfo,
|
|
16985
|
+
});
|
|
16911
16986
|
let price;
|
|
16912
16987
|
if (modelInfo === undefined || modelInfo.pricing === undefined) {
|
|
16913
16988
|
price = uncertainNumber();
|