@promptbook/core 0.81.0-8 → 0.81.0-9
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 +93 -77
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/execution/PipelineExecutor.d.ts +2 -2
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +2 -2
- package/esm/typings/src/types/typeAliases.d.ts +8 -0
- package/esm/typings/src/wizzard/wizzard.d.ts +2 -2
- package/package.json +1 -1
- package/umd/index.umd.js +93 -77
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -25,7 +25,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
25
25
|
* @generated
|
|
26
26
|
* @see https://github.com/webgptorg/promptbook
|
|
27
27
|
*/
|
|
28
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-
|
|
28
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-8';
|
|
29
29
|
/**
|
|
30
30
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
31
31
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2764,6 +2764,81 @@ function isPipelinePrepared(pipeline) {
|
|
|
2764
2764
|
* - [♨] Are tasks prepared
|
|
2765
2765
|
*/
|
|
2766
2766
|
|
|
2767
|
+
/**
|
|
2768
|
+
* Format either small or big number
|
|
2769
|
+
*
|
|
2770
|
+
* @public exported from `@promptbook/utils`
|
|
2771
|
+
*/
|
|
2772
|
+
function numberToString(value) {
|
|
2773
|
+
if (value === 0) {
|
|
2774
|
+
return '0';
|
|
2775
|
+
}
|
|
2776
|
+
else if (Number.isNaN(value)) {
|
|
2777
|
+
return VALUE_STRINGS.nan;
|
|
2778
|
+
}
|
|
2779
|
+
else if (value === Infinity) {
|
|
2780
|
+
return VALUE_STRINGS.infinity;
|
|
2781
|
+
}
|
|
2782
|
+
else if (value === -Infinity) {
|
|
2783
|
+
return VALUE_STRINGS.negativeInfinity;
|
|
2784
|
+
}
|
|
2785
|
+
for (var exponent = 0; exponent < 15; exponent++) {
|
|
2786
|
+
var factor = Math.pow(10, exponent);
|
|
2787
|
+
var valueRounded = Math.round(value * factor) / factor;
|
|
2788
|
+
if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
|
|
2789
|
+
return valueRounded.toFixed(exponent);
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2792
|
+
return value.toString();
|
|
2793
|
+
}
|
|
2794
|
+
|
|
2795
|
+
/**
|
|
2796
|
+
* Function `valueToString` will convert the given value to string
|
|
2797
|
+
* This is useful and used in the `templateParameters` function
|
|
2798
|
+
*
|
|
2799
|
+
* Note: This function is not just calling `toString` method
|
|
2800
|
+
* It's more complex and can handle this conversion specifically for LLM models
|
|
2801
|
+
* See `VALUE_STRINGS`
|
|
2802
|
+
*
|
|
2803
|
+
* Note: There are 2 similar functions
|
|
2804
|
+
* - `valueToString` converts value to string for LLM models as human-readable string
|
|
2805
|
+
* - `asSerializable` converts value to string to preserve full information to be able to convert it back
|
|
2806
|
+
*
|
|
2807
|
+
* @public exported from `@promptbook/utils`
|
|
2808
|
+
*/
|
|
2809
|
+
function valueToString(value) {
|
|
2810
|
+
try {
|
|
2811
|
+
if (value === '') {
|
|
2812
|
+
return VALUE_STRINGS.empty;
|
|
2813
|
+
}
|
|
2814
|
+
else if (value === null) {
|
|
2815
|
+
return VALUE_STRINGS.null;
|
|
2816
|
+
}
|
|
2817
|
+
else if (value === undefined) {
|
|
2818
|
+
return VALUE_STRINGS.undefined;
|
|
2819
|
+
}
|
|
2820
|
+
else if (typeof value === 'string') {
|
|
2821
|
+
return value;
|
|
2822
|
+
}
|
|
2823
|
+
else if (typeof value === 'number') {
|
|
2824
|
+
return numberToString(value);
|
|
2825
|
+
}
|
|
2826
|
+
else if (value instanceof Date) {
|
|
2827
|
+
return value.toISOString();
|
|
2828
|
+
}
|
|
2829
|
+
else {
|
|
2830
|
+
return JSON.stringify(value);
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
catch (error) {
|
|
2834
|
+
if (!(error instanceof Error)) {
|
|
2835
|
+
throw error;
|
|
2836
|
+
}
|
|
2837
|
+
console.error(error);
|
|
2838
|
+
return VALUE_STRINGS.unserializable;
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2841
|
+
|
|
2767
2842
|
/**
|
|
2768
2843
|
* Serializes an error into a [🚉] JSON-serializable object
|
|
2769
2844
|
*
|
|
@@ -3473,81 +3548,6 @@ function arrayableToArray(input) {
|
|
|
3473
3548
|
return [input];
|
|
3474
3549
|
}
|
|
3475
3550
|
|
|
3476
|
-
/**
|
|
3477
|
-
* Format either small or big number
|
|
3478
|
-
*
|
|
3479
|
-
* @public exported from `@promptbook/utils`
|
|
3480
|
-
*/
|
|
3481
|
-
function numberToString(value) {
|
|
3482
|
-
if (value === 0) {
|
|
3483
|
-
return '0';
|
|
3484
|
-
}
|
|
3485
|
-
else if (Number.isNaN(value)) {
|
|
3486
|
-
return VALUE_STRINGS.nan;
|
|
3487
|
-
}
|
|
3488
|
-
else if (value === Infinity) {
|
|
3489
|
-
return VALUE_STRINGS.infinity;
|
|
3490
|
-
}
|
|
3491
|
-
else if (value === -Infinity) {
|
|
3492
|
-
return VALUE_STRINGS.negativeInfinity;
|
|
3493
|
-
}
|
|
3494
|
-
for (var exponent = 0; exponent < 15; exponent++) {
|
|
3495
|
-
var factor = Math.pow(10, exponent);
|
|
3496
|
-
var valueRounded = Math.round(value * factor) / factor;
|
|
3497
|
-
if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
|
|
3498
|
-
return valueRounded.toFixed(exponent);
|
|
3499
|
-
}
|
|
3500
|
-
}
|
|
3501
|
-
return value.toString();
|
|
3502
|
-
}
|
|
3503
|
-
|
|
3504
|
-
/**
|
|
3505
|
-
* Function `valueToString` will convert the given value to string
|
|
3506
|
-
* This is useful and used in the `templateParameters` function
|
|
3507
|
-
*
|
|
3508
|
-
* Note: This function is not just calling `toString` method
|
|
3509
|
-
* It's more complex and can handle this conversion specifically for LLM models
|
|
3510
|
-
* See `VALUE_STRINGS`
|
|
3511
|
-
*
|
|
3512
|
-
* Note: There are 2 similar functions
|
|
3513
|
-
* - `valueToString` converts value to string for LLM models as human-readable string
|
|
3514
|
-
* - `asSerializable` converts value to string to preserve full information to be able to convert it back
|
|
3515
|
-
*
|
|
3516
|
-
* @public exported from `@promptbook/utils`
|
|
3517
|
-
*/
|
|
3518
|
-
function valueToString(value) {
|
|
3519
|
-
try {
|
|
3520
|
-
if (value === '') {
|
|
3521
|
-
return VALUE_STRINGS.empty;
|
|
3522
|
-
}
|
|
3523
|
-
else if (value === null) {
|
|
3524
|
-
return VALUE_STRINGS.null;
|
|
3525
|
-
}
|
|
3526
|
-
else if (value === undefined) {
|
|
3527
|
-
return VALUE_STRINGS.undefined;
|
|
3528
|
-
}
|
|
3529
|
-
else if (typeof value === 'string') {
|
|
3530
|
-
return value;
|
|
3531
|
-
}
|
|
3532
|
-
else if (typeof value === 'number') {
|
|
3533
|
-
return numberToString(value);
|
|
3534
|
-
}
|
|
3535
|
-
else if (value instanceof Date) {
|
|
3536
|
-
return value.toISOString();
|
|
3537
|
-
}
|
|
3538
|
-
else {
|
|
3539
|
-
return JSON.stringify(value);
|
|
3540
|
-
}
|
|
3541
|
-
}
|
|
3542
|
-
catch (error) {
|
|
3543
|
-
if (!(error instanceof Error)) {
|
|
3544
|
-
throw error;
|
|
3545
|
-
}
|
|
3546
|
-
console.error(error);
|
|
3547
|
-
return VALUE_STRINGS.unserializable;
|
|
3548
|
-
}
|
|
3549
|
-
}
|
|
3550
|
-
|
|
3551
3551
|
/**
|
|
3552
3552
|
* Replaces parameters in template with values from parameters object
|
|
3553
3553
|
*
|
|
@@ -4946,7 +4946,10 @@ function executePipeline(options) {
|
|
|
4946
4946
|
finally { if (e_2) throw e_2.error; }
|
|
4947
4947
|
return [7 /*endfinally*/];
|
|
4948
4948
|
case 19:
|
|
4949
|
-
parametersToPass = inputParameters
|
|
4949
|
+
parametersToPass = Object.fromEntries(Object.entries(inputParameters).map(function (_a) {
|
|
4950
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
4951
|
+
return [key, valueToString(value)];
|
|
4952
|
+
}));
|
|
4950
4953
|
_g.label = 20;
|
|
4951
4954
|
case 20:
|
|
4952
4955
|
_g.trys.push([20, 25, , 28]);
|
|
@@ -9131,6 +9134,8 @@ function precompilePipeline(pipelineString) {
|
|
|
9131
9134
|
}
|
|
9132
9135
|
// =============================================================
|
|
9133
9136
|
// Note: 1️⃣ Parsing of the markdown into object
|
|
9137
|
+
// ==============
|
|
9138
|
+
// Note: 1️⃣◽1️⃣ Remove #!shebang and comments
|
|
9134
9139
|
if (pipelineString.startsWith('#!')) {
|
|
9135
9140
|
var _g = __read(pipelineString.split('\n')), shebangLine_1 = _g[0], restLines = _g.slice(1);
|
|
9136
9141
|
if (!(shebangLine_1 || '').includes('ptbk')) {
|
|
@@ -9139,10 +9144,21 @@ function precompilePipeline(pipelineString) {
|
|
|
9139
9144
|
pipelineString = restLines.join('\n');
|
|
9140
9145
|
}
|
|
9141
9146
|
pipelineString = removeContentComments(pipelineString);
|
|
9147
|
+
// ==============
|
|
9148
|
+
// Note: 1️⃣◽2️⃣ Process flat pipeline
|
|
9149
|
+
// TODO: !!!!!!
|
|
9150
|
+
// const isMarkdownBeginningWithHeadline =
|
|
9151
|
+
// const isMarkdown
|
|
9152
|
+
// const isMarkdown
|
|
9153
|
+
// const isMarkdown
|
|
9154
|
+
// ==============
|
|
9155
|
+
// Note: 1️⃣◽3️⃣ Parse the markdown
|
|
9142
9156
|
pipelineString = flattenMarkdown(pipelineString) /* <- Note: [🥞] */;
|
|
9143
9157
|
pipelineString = pipelineString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
|
|
9144
9158
|
pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
9145
9159
|
var _h = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _h[0], pipelineSections = _h.slice(1); /* <- Note: [🥞] */
|
|
9160
|
+
// ==============
|
|
9161
|
+
// Note: 1️⃣◽4️⃣ Check markdown structure
|
|
9146
9162
|
if (pipelineHead === undefined) {
|
|
9147
9163
|
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
9148
9164
|
}
|