@promptbook/cli 0.81.0-7 → 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/node.index.d.ts +2 -0
- 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/other/templates/getBookTemplate.d.ts +10 -1
- package/esm/typings/src/types/typeAliases.d.ts +8 -0
- package/esm/typings/src/wizzard/wizzard.d.ts +19 -0
- 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
|
@@ -39,7 +39,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
39
39
|
* @generated
|
|
40
40
|
* @see https://github.com/webgptorg/promptbook
|
|
41
41
|
*/
|
|
42
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-
|
|
42
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-8';
|
|
43
43
|
/**
|
|
44
44
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
45
45
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -3902,6 +3902,81 @@ function isPipelinePrepared(pipeline) {
|
|
|
3902
3902
|
* - [♨] Are tasks prepared
|
|
3903
3903
|
*/
|
|
3904
3904
|
|
|
3905
|
+
/**
|
|
3906
|
+
* Format either small or big number
|
|
3907
|
+
*
|
|
3908
|
+
* @public exported from `@promptbook/utils`
|
|
3909
|
+
*/
|
|
3910
|
+
function numberToString(value) {
|
|
3911
|
+
if (value === 0) {
|
|
3912
|
+
return '0';
|
|
3913
|
+
}
|
|
3914
|
+
else if (Number.isNaN(value)) {
|
|
3915
|
+
return VALUE_STRINGS.nan;
|
|
3916
|
+
}
|
|
3917
|
+
else if (value === Infinity) {
|
|
3918
|
+
return VALUE_STRINGS.infinity;
|
|
3919
|
+
}
|
|
3920
|
+
else if (value === -Infinity) {
|
|
3921
|
+
return VALUE_STRINGS.negativeInfinity;
|
|
3922
|
+
}
|
|
3923
|
+
for (var exponent = 0; exponent < 15; exponent++) {
|
|
3924
|
+
var factor = Math.pow(10, exponent);
|
|
3925
|
+
var valueRounded = Math.round(value * factor) / factor;
|
|
3926
|
+
if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
|
|
3927
|
+
return valueRounded.toFixed(exponent);
|
|
3928
|
+
}
|
|
3929
|
+
}
|
|
3930
|
+
return value.toString();
|
|
3931
|
+
}
|
|
3932
|
+
|
|
3933
|
+
/**
|
|
3934
|
+
* Function `valueToString` will convert the given value to string
|
|
3935
|
+
* This is useful and used in the `templateParameters` function
|
|
3936
|
+
*
|
|
3937
|
+
* Note: This function is not just calling `toString` method
|
|
3938
|
+
* It's more complex and can handle this conversion specifically for LLM models
|
|
3939
|
+
* See `VALUE_STRINGS`
|
|
3940
|
+
*
|
|
3941
|
+
* Note: There are 2 similar functions
|
|
3942
|
+
* - `valueToString` converts value to string for LLM models as human-readable string
|
|
3943
|
+
* - `asSerializable` converts value to string to preserve full information to be able to convert it back
|
|
3944
|
+
*
|
|
3945
|
+
* @public exported from `@promptbook/utils`
|
|
3946
|
+
*/
|
|
3947
|
+
function valueToString(value) {
|
|
3948
|
+
try {
|
|
3949
|
+
if (value === '') {
|
|
3950
|
+
return VALUE_STRINGS.empty;
|
|
3951
|
+
}
|
|
3952
|
+
else if (value === null) {
|
|
3953
|
+
return VALUE_STRINGS.null;
|
|
3954
|
+
}
|
|
3955
|
+
else if (value === undefined) {
|
|
3956
|
+
return VALUE_STRINGS.undefined;
|
|
3957
|
+
}
|
|
3958
|
+
else if (typeof value === 'string') {
|
|
3959
|
+
return value;
|
|
3960
|
+
}
|
|
3961
|
+
else if (typeof value === 'number') {
|
|
3962
|
+
return numberToString(value);
|
|
3963
|
+
}
|
|
3964
|
+
else if (value instanceof Date) {
|
|
3965
|
+
return value.toISOString();
|
|
3966
|
+
}
|
|
3967
|
+
else {
|
|
3968
|
+
return JSON.stringify(value);
|
|
3969
|
+
}
|
|
3970
|
+
}
|
|
3971
|
+
catch (error) {
|
|
3972
|
+
if (!(error instanceof Error)) {
|
|
3973
|
+
throw error;
|
|
3974
|
+
}
|
|
3975
|
+
console.error(error);
|
|
3976
|
+
return VALUE_STRINGS.unserializable;
|
|
3977
|
+
}
|
|
3978
|
+
}
|
|
3979
|
+
|
|
3905
3980
|
/**
|
|
3906
3981
|
* Serializes an error into a [🚉] JSON-serializable object
|
|
3907
3982
|
*
|
|
@@ -4611,81 +4686,6 @@ function arrayableToArray(input) {
|
|
|
4611
4686
|
return [input];
|
|
4612
4687
|
}
|
|
4613
4688
|
|
|
4614
|
-
/**
|
|
4615
|
-
* Format either small or big number
|
|
4616
|
-
*
|
|
4617
|
-
* @public exported from `@promptbook/utils`
|
|
4618
|
-
*/
|
|
4619
|
-
function numberToString(value) {
|
|
4620
|
-
if (value === 0) {
|
|
4621
|
-
return '0';
|
|
4622
|
-
}
|
|
4623
|
-
else if (Number.isNaN(value)) {
|
|
4624
|
-
return VALUE_STRINGS.nan;
|
|
4625
|
-
}
|
|
4626
|
-
else if (value === Infinity) {
|
|
4627
|
-
return VALUE_STRINGS.infinity;
|
|
4628
|
-
}
|
|
4629
|
-
else if (value === -Infinity) {
|
|
4630
|
-
return VALUE_STRINGS.negativeInfinity;
|
|
4631
|
-
}
|
|
4632
|
-
for (var exponent = 0; exponent < 15; exponent++) {
|
|
4633
|
-
var factor = Math.pow(10, exponent);
|
|
4634
|
-
var valueRounded = Math.round(value * factor) / factor;
|
|
4635
|
-
if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
|
|
4636
|
-
return valueRounded.toFixed(exponent);
|
|
4637
|
-
}
|
|
4638
|
-
}
|
|
4639
|
-
return value.toString();
|
|
4640
|
-
}
|
|
4641
|
-
|
|
4642
|
-
/**
|
|
4643
|
-
* Function `valueToString` will convert the given value to string
|
|
4644
|
-
* This is useful and used in the `templateParameters` function
|
|
4645
|
-
*
|
|
4646
|
-
* Note: This function is not just calling `toString` method
|
|
4647
|
-
* It's more complex and can handle this conversion specifically for LLM models
|
|
4648
|
-
* See `VALUE_STRINGS`
|
|
4649
|
-
*
|
|
4650
|
-
* Note: There are 2 similar functions
|
|
4651
|
-
* - `valueToString` converts value to string for LLM models as human-readable string
|
|
4652
|
-
* - `asSerializable` converts value to string to preserve full information to be able to convert it back
|
|
4653
|
-
*
|
|
4654
|
-
* @public exported from `@promptbook/utils`
|
|
4655
|
-
*/
|
|
4656
|
-
function valueToString(value) {
|
|
4657
|
-
try {
|
|
4658
|
-
if (value === '') {
|
|
4659
|
-
return VALUE_STRINGS.empty;
|
|
4660
|
-
}
|
|
4661
|
-
else if (value === null) {
|
|
4662
|
-
return VALUE_STRINGS.null;
|
|
4663
|
-
}
|
|
4664
|
-
else if (value === undefined) {
|
|
4665
|
-
return VALUE_STRINGS.undefined;
|
|
4666
|
-
}
|
|
4667
|
-
else if (typeof value === 'string') {
|
|
4668
|
-
return value;
|
|
4669
|
-
}
|
|
4670
|
-
else if (typeof value === 'number') {
|
|
4671
|
-
return numberToString(value);
|
|
4672
|
-
}
|
|
4673
|
-
else if (value instanceof Date) {
|
|
4674
|
-
return value.toISOString();
|
|
4675
|
-
}
|
|
4676
|
-
else {
|
|
4677
|
-
return JSON.stringify(value);
|
|
4678
|
-
}
|
|
4679
|
-
}
|
|
4680
|
-
catch (error) {
|
|
4681
|
-
if (!(error instanceof Error)) {
|
|
4682
|
-
throw error;
|
|
4683
|
-
}
|
|
4684
|
-
console.error(error);
|
|
4685
|
-
return VALUE_STRINGS.unserializable;
|
|
4686
|
-
}
|
|
4687
|
-
}
|
|
4688
|
-
|
|
4689
4689
|
/**
|
|
4690
4690
|
* Replaces parameters in template with values from parameters object
|
|
4691
4691
|
*
|
|
@@ -5801,7 +5801,10 @@ function executePipeline(options) {
|
|
|
5801
5801
|
finally { if (e_2) throw e_2.error; }
|
|
5802
5802
|
return [7 /*endfinally*/];
|
|
5803
5803
|
case 19:
|
|
5804
|
-
parametersToPass = inputParameters
|
|
5804
|
+
parametersToPass = Object.fromEntries(Object.entries(inputParameters).map(function (_a) {
|
|
5805
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
5806
|
+
return [key, valueToString(value)];
|
|
5807
|
+
}));
|
|
5805
5808
|
_g.label = 20;
|
|
5806
5809
|
case 20:
|
|
5807
5810
|
_g.trys.push([20, 25, , 28]);
|
|
@@ -9677,6 +9680,8 @@ function precompilePipeline(pipelineString) {
|
|
|
9677
9680
|
}
|
|
9678
9681
|
// =============================================================
|
|
9679
9682
|
// Note: 1️⃣ Parsing of the markdown into object
|
|
9683
|
+
// ==============
|
|
9684
|
+
// Note: 1️⃣◽1️⃣ Remove #!shebang and comments
|
|
9680
9685
|
if (pipelineString.startsWith('#!')) {
|
|
9681
9686
|
var _g = __read(pipelineString.split('\n')), shebangLine_1 = _g[0], restLines = _g.slice(1);
|
|
9682
9687
|
if (!(shebangLine_1 || '').includes('ptbk')) {
|
|
@@ -9685,10 +9690,21 @@ function precompilePipeline(pipelineString) {
|
|
|
9685
9690
|
pipelineString = restLines.join('\n');
|
|
9686
9691
|
}
|
|
9687
9692
|
pipelineString = removeContentComments(pipelineString);
|
|
9693
|
+
// ==============
|
|
9694
|
+
// Note: 1️⃣◽2️⃣ Process flat pipeline
|
|
9695
|
+
// TODO: !!!!!!
|
|
9696
|
+
// const isMarkdownBeginningWithHeadline =
|
|
9697
|
+
// const isMarkdown
|
|
9698
|
+
// const isMarkdown
|
|
9699
|
+
// const isMarkdown
|
|
9700
|
+
// ==============
|
|
9701
|
+
// Note: 1️⃣◽3️⃣ Parse the markdown
|
|
9688
9702
|
pipelineString = flattenMarkdown(pipelineString) /* <- Note: [🥞] */;
|
|
9689
9703
|
pipelineString = pipelineString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
|
|
9690
9704
|
pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
9691
9705
|
var _h = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _h[0], pipelineSections = _h.slice(1); /* <- Note: [🥞] */
|
|
9706
|
+
// ==============
|
|
9707
|
+
// Note: 1️⃣◽4️⃣ Check markdown structure
|
|
9692
9708
|
if (pipelineHead === undefined) {
|
|
9693
9709
|
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 "); }));
|
|
9694
9710
|
}
|