@promptbook/core 0.77.0 → 0.77.1
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 +121 -61
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +2 -2
- package/esm/typings/src/cli/test/ptbk.d.ts +1 -1
- package/esm/typings/src/errors/0-index.d.ts +46 -1
- package/esm/typings/src/errors/utils/ErrorJson.d.ts +2 -2
- package/esm/typings/src/llm-providers/_common/register/createLlmToolsFromConfiguration.test.d.ts +1 -0
- package/package.json +1 -1
- package/umd/index.umd.js +121 -61
- package/umd/index.umd.js.map +1 -1
|
@@ -35,7 +35,7 @@ import { validatePipeline } from '../conversion/validation/validatePipeline';
|
|
|
35
35
|
import { CallbackInterfaceTools } from '../dialogs/callback/CallbackInterfaceTools';
|
|
36
36
|
import type { CallbackInterfaceToolsOptions } from '../dialogs/callback/CallbackInterfaceToolsOptions';
|
|
37
37
|
import { BoilerplateError } from '../errors/0-BoilerplateError';
|
|
38
|
-
import {
|
|
38
|
+
import { PROMPTBOOK_ERRORS } from '../errors/0-index';
|
|
39
39
|
import { AbstractFormatError } from '../errors/AbstractFormatError';
|
|
40
40
|
import { CollectionError } from '../errors/CollectionError';
|
|
41
41
|
import { EnvironmentMismatchError } from '../errors/EnvironmentMismatchError';
|
|
@@ -150,7 +150,7 @@ export { validatePipeline };
|
|
|
150
150
|
export { CallbackInterfaceTools };
|
|
151
151
|
export type { CallbackInterfaceToolsOptions };
|
|
152
152
|
export { BoilerplateError };
|
|
153
|
-
export {
|
|
153
|
+
export { PROMPTBOOK_ERRORS };
|
|
154
154
|
export { AbstractFormatError };
|
|
155
155
|
export { CollectionError };
|
|
156
156
|
export { EnvironmentMismatchError };
|
|
@@ -18,7 +18,52 @@ import { UnexpectedError } from './UnexpectedError';
|
|
|
18
18
|
*
|
|
19
19
|
* @public exported from `@promptbook/core`
|
|
20
20
|
*/
|
|
21
|
-
export declare const
|
|
21
|
+
export declare const PROMPTBOOK_ERRORS: {
|
|
22
|
+
readonly AbstractFormatError: typeof AbstractFormatError;
|
|
23
|
+
readonly CsvFormatError: typeof CsvFormatError;
|
|
24
|
+
readonly CollectionError: typeof CollectionError;
|
|
25
|
+
readonly EnvironmentMismatchError: typeof EnvironmentMismatchError;
|
|
26
|
+
readonly ExpectError: typeof ExpectError;
|
|
27
|
+
readonly KnowledgeScrapeError: typeof KnowledgeScrapeError;
|
|
28
|
+
readonly LimitReachedError: typeof LimitReachedError;
|
|
29
|
+
readonly MissingToolsError: typeof MissingToolsError;
|
|
30
|
+
readonly NotFoundError: typeof NotFoundError;
|
|
31
|
+
readonly NotYetImplementedError: typeof NotYetImplementedError;
|
|
32
|
+
readonly ParseError: typeof ParseError;
|
|
33
|
+
readonly PipelineExecutionError: typeof PipelineExecutionError;
|
|
34
|
+
readonly PipelineLogicError: typeof PipelineLogicError;
|
|
35
|
+
readonly PipelineUrlError: typeof PipelineUrlError;
|
|
36
|
+
readonly UnexpectedError: typeof UnexpectedError;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Index of all javascript errors
|
|
40
|
+
*
|
|
41
|
+
* @private for internal usage
|
|
42
|
+
*/
|
|
43
|
+
export declare const COMMON_JAVASCRIPT_ERRORS: {
|
|
44
|
+
readonly Error: ErrorConstructor;
|
|
45
|
+
readonly EvalError: EvalErrorConstructor;
|
|
46
|
+
readonly RangeError: RangeErrorConstructor;
|
|
47
|
+
readonly ReferenceError: ReferenceErrorConstructor;
|
|
48
|
+
readonly SyntaxError: SyntaxErrorConstructor;
|
|
49
|
+
readonly TypeError: TypeErrorConstructor;
|
|
50
|
+
readonly URIError: URIErrorConstructor;
|
|
51
|
+
readonly AggregateError: AggregateErrorConstructor;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Index of all errors
|
|
55
|
+
*
|
|
56
|
+
* @private for internal usage
|
|
57
|
+
*/
|
|
58
|
+
export declare const ALL_ERRORS: {
|
|
59
|
+
readonly Error: ErrorConstructor;
|
|
60
|
+
readonly EvalError: EvalErrorConstructor;
|
|
61
|
+
readonly RangeError: RangeErrorConstructor;
|
|
62
|
+
readonly ReferenceError: ReferenceErrorConstructor;
|
|
63
|
+
readonly SyntaxError: SyntaxErrorConstructor;
|
|
64
|
+
readonly TypeError: TypeErrorConstructor;
|
|
65
|
+
readonly URIError: URIErrorConstructor;
|
|
66
|
+
readonly AggregateError: AggregateErrorConstructor;
|
|
22
67
|
readonly AbstractFormatError: typeof AbstractFormatError;
|
|
23
68
|
readonly CsvFormatError: typeof CsvFormatError;
|
|
24
69
|
readonly CollectionError: typeof CollectionError;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ALL_ERRORS } from '../0-index';
|
|
2
2
|
/**
|
|
3
3
|
* Represents a serialized error or custom Promptbook error
|
|
4
4
|
*
|
|
@@ -8,7 +8,7 @@ export type ErrorJson = {
|
|
|
8
8
|
/**
|
|
9
9
|
* The type of the error
|
|
10
10
|
*/
|
|
11
|
-
readonly name: keyof typeof
|
|
11
|
+
readonly name: keyof typeof ALL_ERRORS;
|
|
12
12
|
/**
|
|
13
13
|
* The message of the error
|
|
14
14
|
*/
|
package/esm/typings/src/llm-providers/_common/register/createLlmToolsFromConfiguration.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
*
|
|
26
26
|
* @see https://github.com/webgptorg/promptbook
|
|
27
27
|
*/
|
|
28
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.77.0
|
|
28
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.77.0';
|
|
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
|
|
@@ -2496,7 +2496,7 @@
|
|
|
2496
2496
|
*
|
|
2497
2497
|
* @public exported from `@promptbook/core`
|
|
2498
2498
|
*/
|
|
2499
|
-
var
|
|
2499
|
+
var PROMPTBOOK_ERRORS = {
|
|
2500
2500
|
AbstractFormatError: AbstractFormatError,
|
|
2501
2501
|
CsvFormatError: CsvFormatError,
|
|
2502
2502
|
CollectionError: CollectionError,
|
|
@@ -2514,6 +2514,35 @@
|
|
|
2514
2514
|
UnexpectedError: UnexpectedError,
|
|
2515
2515
|
// TODO: [🪑]> VersionMismatchError,
|
|
2516
2516
|
};
|
|
2517
|
+
/**
|
|
2518
|
+
* Index of all javascript errors
|
|
2519
|
+
*
|
|
2520
|
+
* @private for internal usage
|
|
2521
|
+
*/
|
|
2522
|
+
var COMMON_JAVASCRIPT_ERRORS = {
|
|
2523
|
+
Error: Error,
|
|
2524
|
+
EvalError: EvalError,
|
|
2525
|
+
RangeError: RangeError,
|
|
2526
|
+
ReferenceError: ReferenceError,
|
|
2527
|
+
SyntaxError: SyntaxError,
|
|
2528
|
+
TypeError: TypeError,
|
|
2529
|
+
URIError: URIError,
|
|
2530
|
+
AggregateError: AggregateError,
|
|
2531
|
+
/*
|
|
2532
|
+
Note: Not widely supported
|
|
2533
|
+
> InternalError,
|
|
2534
|
+
> ModuleError,
|
|
2535
|
+
> HeapError,
|
|
2536
|
+
> WebAssemblyCompileError,
|
|
2537
|
+
> WebAssemblyRuntimeError,
|
|
2538
|
+
*/
|
|
2539
|
+
};
|
|
2540
|
+
/**
|
|
2541
|
+
* Index of all errors
|
|
2542
|
+
*
|
|
2543
|
+
* @private for internal usage
|
|
2544
|
+
*/
|
|
2545
|
+
var ALL_ERRORS = __assign(__assign({}, PROMPTBOOK_ERRORS), COMMON_JAVASCRIPT_ERRORS);
|
|
2517
2546
|
/**
|
|
2518
2547
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2519
2548
|
*/
|
|
@@ -2524,11 +2553,11 @@
|
|
|
2524
2553
|
* @public exported from `@promptbook/utils`
|
|
2525
2554
|
*/
|
|
2526
2555
|
function deserializeError(error) {
|
|
2527
|
-
|
|
2528
|
-
|
|
2556
|
+
var ErrorClass = ALL_ERRORS[error.name];
|
|
2557
|
+
if (ErrorClass === undefined) {
|
|
2558
|
+
return new Error("".concat(error.name, ": ").concat(error.message));
|
|
2529
2559
|
}
|
|
2530
|
-
|
|
2531
|
-
return new CustomError(error.message);
|
|
2560
|
+
return new ErrorClass(error.message);
|
|
2532
2561
|
}
|
|
2533
2562
|
|
|
2534
2563
|
/**
|
|
@@ -2602,8 +2631,8 @@
|
|
|
2602
2631
|
*/
|
|
2603
2632
|
function serializeError(error) {
|
|
2604
2633
|
var name = error.name, message = error.message, stack = error.stack;
|
|
2605
|
-
if (!
|
|
2606
|
-
|
|
2634
|
+
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
2635
|
+
console.error(spaceTrim__default["default"](function (block) { return "\n \n Cannot serialize error with name \"".concat(name, "\"\n\n ").concat(block(stack || message), "\n \n "); }));
|
|
2607
2636
|
}
|
|
2608
2637
|
return {
|
|
2609
2638
|
name: name,
|
|
@@ -8508,7 +8537,7 @@
|
|
|
8508
8537
|
* @public exported from `@promptbook/core`
|
|
8509
8538
|
*/
|
|
8510
8539
|
function pipelineStringToJsonSync(pipelineString) {
|
|
8511
|
-
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
8540
|
+
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e;
|
|
8512
8541
|
var $pipelineJson = {
|
|
8513
8542
|
title: undefined /* <- Note: [🍙] Putting here placeholder to keep `title` on top at final JSON */,
|
|
8514
8543
|
pipelineUrl: undefined /* <- Note: Putting here placeholder to keep `pipelineUrl` on top at final JSON */,
|
|
@@ -8537,7 +8566,7 @@
|
|
|
8537
8566
|
// =============================================================
|
|
8538
8567
|
// Note: 1️⃣ Parsing of the markdown into object
|
|
8539
8568
|
if (pipelineString.startsWith('#!')) {
|
|
8540
|
-
var
|
|
8569
|
+
var _f = __read(pipelineString.split('\n')), shebangLine_1 = _f[0], restLines = _f.slice(1);
|
|
8541
8570
|
if (!(shebangLine_1 || '').includes('ptbk')) {
|
|
8542
8571
|
throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n It seems that you try to parse a book file which has non-standard shebang line for book files:\n Shebang line must contain 'ptbk'\n\n You have:\n ".concat(block(shebangLine_1 || '(empty line)'), "\n\n It should look like this:\n #!/usr/bin/env ptbk\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
8543
8572
|
}
|
|
@@ -8547,7 +8576,7 @@
|
|
|
8547
8576
|
pipelineString = flattenMarkdown(pipelineString) /* <- Note: [🥞] */;
|
|
8548
8577
|
pipelineString = pipelineString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
|
|
8549
8578
|
pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
8550
|
-
var
|
|
8579
|
+
var _g = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _g[0], pipelineSections = _g.slice(1); /* <- Note: [🥞] */
|
|
8551
8580
|
if (pipelineHead === undefined) {
|
|
8552
8581
|
throw new UnexpectedError(spaceTrim.spaceTrim(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 "); }));
|
|
8553
8582
|
}
|
|
@@ -8638,11 +8667,41 @@
|
|
|
8638
8667
|
}
|
|
8639
8668
|
finally { if (e_1) throw e_1.error; }
|
|
8640
8669
|
}
|
|
8670
|
+
// =============================================================
|
|
8671
|
+
// Note: 4️⃣ Prepare unique section names with indexes when needed
|
|
8672
|
+
var sectionCounts = {};
|
|
8673
|
+
try {
|
|
8674
|
+
for (var pipelineSections_1 = __values(pipelineSections), pipelineSections_1_1 = pipelineSections_1.next(); !pipelineSections_1_1.done; pipelineSections_1_1 = pipelineSections_1.next()) {
|
|
8675
|
+
var section = pipelineSections_1_1.value;
|
|
8676
|
+
var name_1 = titleToName(section.title);
|
|
8677
|
+
if (sectionCounts[name_1] === undefined) {
|
|
8678
|
+
sectionCounts[name_1] = { count: 0, currentIndex: 0 };
|
|
8679
|
+
}
|
|
8680
|
+
sectionCounts[name_1].count++;
|
|
8681
|
+
}
|
|
8682
|
+
}
|
|
8683
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
8684
|
+
finally {
|
|
8685
|
+
try {
|
|
8686
|
+
if (pipelineSections_1_1 && !pipelineSections_1_1.done && (_b = pipelineSections_1.return)) _b.call(pipelineSections_1);
|
|
8687
|
+
}
|
|
8688
|
+
finally { if (e_2) throw e_2.error; }
|
|
8689
|
+
}
|
|
8690
|
+
var getUniqueSectionName = function (title) {
|
|
8691
|
+
var name = titleToName(title);
|
|
8692
|
+
var count = sectionCounts[name];
|
|
8693
|
+
if (count.count === 1) {
|
|
8694
|
+
return name;
|
|
8695
|
+
}
|
|
8696
|
+
var nameWithSuffix = "".concat(name, "-").concat(count.currentIndex);
|
|
8697
|
+
count.currentIndex++;
|
|
8698
|
+
return nameWithSuffix;
|
|
8699
|
+
};
|
|
8641
8700
|
var _loop_2 = function (section) {
|
|
8642
|
-
var
|
|
8701
|
+
var e_6, _m, e_7, _o;
|
|
8643
8702
|
// TODO: Parse section's description (the content out of the codeblock and lists)
|
|
8644
8703
|
var listItems_2 = extractAllListItemsFromMarkdown(section.content);
|
|
8645
|
-
var
|
|
8704
|
+
var _p = extractOneBlockFromMarkdown(section.content), language = _p.language, content = _p.content;
|
|
8646
8705
|
// TODO: [🎾][1] DRY description
|
|
8647
8706
|
var description_1 = section.content;
|
|
8648
8707
|
// Note: Remove codeblocks - TODO: [🎾]
|
|
@@ -8658,7 +8717,7 @@
|
|
|
8658
8717
|
isSectionTypeSet: false,
|
|
8659
8718
|
isTask: true,
|
|
8660
8719
|
taskType: undefined /* <- Note: [🍙] Putting here placeholder to keep `taskType` on top at final JSON */,
|
|
8661
|
-
name:
|
|
8720
|
+
name: getUniqueSectionName(section.title),
|
|
8662
8721
|
title: section.title,
|
|
8663
8722
|
description: description_1,
|
|
8664
8723
|
content: content,
|
|
@@ -8706,17 +8765,17 @@
|
|
|
8706
8765
|
};
|
|
8707
8766
|
try {
|
|
8708
8767
|
// TODO [♓️] List commands and before apply order them to achieve order-agnostic commands
|
|
8709
|
-
for (var commands_1 = (
|
|
8710
|
-
var
|
|
8768
|
+
for (var commands_1 = (e_6 = void 0, __values(commands)), commands_1_1 = commands_1.next(); !commands_1_1.done; commands_1_1 = commands_1.next()) {
|
|
8769
|
+
var _q = commands_1_1.value, listItem = _q.listItem, command = _q.command;
|
|
8711
8770
|
_loop_4(listItem, command);
|
|
8712
8771
|
}
|
|
8713
8772
|
}
|
|
8714
|
-
catch (
|
|
8773
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
8715
8774
|
finally {
|
|
8716
8775
|
try {
|
|
8717
|
-
if (commands_1_1 && !commands_1_1.done && (
|
|
8776
|
+
if (commands_1_1 && !commands_1_1.done && (_m = commands_1.return)) _m.call(commands_1);
|
|
8718
8777
|
}
|
|
8719
|
-
finally { if (
|
|
8778
|
+
finally { if (e_6) throw e_6.error; }
|
|
8720
8779
|
}
|
|
8721
8780
|
// TODO: [🍧] Should be done in SECTION command
|
|
8722
8781
|
if ($taskJson.taskType === 'SCRIPT_TASK') {
|
|
@@ -8730,8 +8789,8 @@
|
|
|
8730
8789
|
}
|
|
8731
8790
|
$taskJson.dependentParameterNames = Array.from(extractParameterNamesFromTask($taskJson));
|
|
8732
8791
|
try {
|
|
8733
|
-
for (var
|
|
8734
|
-
var parameterName =
|
|
8792
|
+
for (var _r = (e_7 = void 0, __values($taskJson.dependentParameterNames)), _s = _r.next(); !_s.done; _s = _r.next()) {
|
|
8793
|
+
var parameterName = _s.value;
|
|
8735
8794
|
// TODO: [🧠] This definition should be made first in the task
|
|
8736
8795
|
defineParam({
|
|
8737
8796
|
parameterName: parameterName,
|
|
@@ -8742,12 +8801,12 @@
|
|
|
8742
8801
|
});
|
|
8743
8802
|
}
|
|
8744
8803
|
}
|
|
8745
|
-
catch (
|
|
8804
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
8746
8805
|
finally {
|
|
8747
8806
|
try {
|
|
8748
|
-
if (
|
|
8807
|
+
if (_s && !_s.done && (_o = _r.return)) _o.call(_r);
|
|
8749
8808
|
}
|
|
8750
|
-
finally { if (
|
|
8809
|
+
finally { if (e_7) throw e_7.error; }
|
|
8751
8810
|
}
|
|
8752
8811
|
/*
|
|
8753
8812
|
// TODO: [🍧] This should be checked in `MODEL` command + better error message
|
|
@@ -8776,21 +8835,21 @@
|
|
|
8776
8835
|
};
|
|
8777
8836
|
try {
|
|
8778
8837
|
// =============================================================
|
|
8779
|
-
// Note:
|
|
8780
|
-
for (var
|
|
8781
|
-
var section =
|
|
8838
|
+
// Note: 5️⃣ Process each section of the pipeline
|
|
8839
|
+
for (var pipelineSections_2 = __values(pipelineSections), pipelineSections_2_1 = pipelineSections_2.next(); !pipelineSections_2_1.done; pipelineSections_2_1 = pipelineSections_2.next()) {
|
|
8840
|
+
var section = pipelineSections_2_1.value;
|
|
8782
8841
|
_loop_2(section);
|
|
8783
8842
|
}
|
|
8784
8843
|
}
|
|
8785
|
-
catch (
|
|
8844
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
8786
8845
|
finally {
|
|
8787
8846
|
try {
|
|
8788
|
-
if (
|
|
8847
|
+
if (pipelineSections_2_1 && !pipelineSections_2_1.done && (_c = pipelineSections_2.return)) _c.call(pipelineSections_2);
|
|
8789
8848
|
}
|
|
8790
|
-
finally { if (
|
|
8849
|
+
finally { if (e_3) throw e_3.error; }
|
|
8791
8850
|
}
|
|
8792
8851
|
// =============================================================
|
|
8793
|
-
// Note:
|
|
8852
|
+
// Note: 6️⃣ Mark parameters as INPUT if not explicitly set
|
|
8794
8853
|
if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isInput; })) {
|
|
8795
8854
|
var _loop_3 = function (parameter) {
|
|
8796
8855
|
var isThisParameterResulting = $pipelineJson.tasks.some(function (task) { return task.resultingParameterName === parameter.name; });
|
|
@@ -8799,42 +8858,42 @@
|
|
|
8799
8858
|
}
|
|
8800
8859
|
};
|
|
8801
8860
|
try {
|
|
8802
|
-
for (var
|
|
8803
|
-
var parameter =
|
|
8861
|
+
for (var _h = __values($pipelineJson.parameters), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
8862
|
+
var parameter = _j.value;
|
|
8804
8863
|
_loop_3(parameter);
|
|
8805
8864
|
}
|
|
8806
8865
|
}
|
|
8807
|
-
catch (
|
|
8866
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
8808
8867
|
finally {
|
|
8809
8868
|
try {
|
|
8810
|
-
if (
|
|
8869
|
+
if (_j && !_j.done && (_d = _h.return)) _d.call(_h);
|
|
8811
8870
|
}
|
|
8812
|
-
finally { if (
|
|
8871
|
+
finally { if (e_4) throw e_4.error; }
|
|
8813
8872
|
}
|
|
8814
8873
|
}
|
|
8815
8874
|
// =============================================================
|
|
8816
|
-
// Note:
|
|
8875
|
+
// Note: 7️⃣ Mark all non-INPUT parameters as OUTPUT if any OUTPUT is not set
|
|
8817
8876
|
if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isOutput; })) {
|
|
8818
8877
|
try {
|
|
8819
|
-
for (var
|
|
8820
|
-
var parameter =
|
|
8878
|
+
for (var _k = __values($pipelineJson.parameters), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
8879
|
+
var parameter = _l.value;
|
|
8821
8880
|
if (!parameter.isInput) {
|
|
8822
8881
|
parameter.isOutput = true;
|
|
8823
8882
|
}
|
|
8824
8883
|
}
|
|
8825
8884
|
}
|
|
8826
|
-
catch (
|
|
8885
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
8827
8886
|
finally {
|
|
8828
8887
|
try {
|
|
8829
|
-
if (
|
|
8888
|
+
if (_l && !_l.done && (_e = _k.return)) _e.call(_k);
|
|
8830
8889
|
}
|
|
8831
|
-
finally { if (
|
|
8890
|
+
finally { if (e_5) throw e_5.error; }
|
|
8832
8891
|
}
|
|
8833
8892
|
}
|
|
8834
8893
|
// =============================================================
|
|
8835
|
-
// Note:
|
|
8894
|
+
// Note: 8️⃣ Cleanup of undefined values
|
|
8836
8895
|
$pipelineJson.tasks.forEach(function (tasks) {
|
|
8837
|
-
var
|
|
8896
|
+
var e_8, _a;
|
|
8838
8897
|
try {
|
|
8839
8898
|
for (var _b = __values(Object.entries(tasks)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
8840
8899
|
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
@@ -8843,16 +8902,16 @@
|
|
|
8843
8902
|
}
|
|
8844
8903
|
}
|
|
8845
8904
|
}
|
|
8846
|
-
catch (
|
|
8905
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
8847
8906
|
finally {
|
|
8848
8907
|
try {
|
|
8849
8908
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8850
8909
|
}
|
|
8851
|
-
finally { if (
|
|
8910
|
+
finally { if (e_8) throw e_8.error; }
|
|
8852
8911
|
}
|
|
8853
8912
|
});
|
|
8854
8913
|
$pipelineJson.parameters.forEach(function (parameter) {
|
|
8855
|
-
var
|
|
8914
|
+
var e_9, _a;
|
|
8856
8915
|
try {
|
|
8857
8916
|
for (var _b = __values(Object.entries(parameter)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
8858
8917
|
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
@@ -8861,12 +8920,12 @@
|
|
|
8861
8920
|
}
|
|
8862
8921
|
}
|
|
8863
8922
|
}
|
|
8864
|
-
catch (
|
|
8923
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
8865
8924
|
finally {
|
|
8866
8925
|
try {
|
|
8867
8926
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8868
8927
|
}
|
|
8869
|
-
finally { if (
|
|
8928
|
+
finally { if (e_9) throw e_9.error; }
|
|
8870
8929
|
}
|
|
8871
8930
|
});
|
|
8872
8931
|
// =============================================================
|
|
@@ -8939,18 +8998,19 @@
|
|
|
8939
8998
|
var warningLine = "<!-- ".concat(GENERATOR_WARNING, " -->");
|
|
8940
8999
|
var sectionRegex = new RegExp("<!--".concat(sectionName, "-->([\\s\\S]*?)<!--/").concat(sectionName, "-->"), 'g');
|
|
8941
9000
|
var sectionMatch = content.match(sectionRegex);
|
|
9001
|
+
var contentToInsert = spaceTrim.spaceTrim(function (block) { return "\n <!--".concat(sectionName, "-->\n ").concat(block(warningLine), "\n ").concat(block(sectionContent), "\n <!--/").concat(sectionName, "-->\n "); });
|
|
8942
9002
|
if (sectionMatch) {
|
|
8943
|
-
return content.replace(sectionRegex,
|
|
9003
|
+
return content.replace(sectionRegex, contentToInsert);
|
|
8944
9004
|
}
|
|
9005
|
+
// Note: Following is the case when the section is not found in the file so we add it there
|
|
8945
9006
|
var placeForSection = removeContentComments(content).match(/^##.*$/im);
|
|
8946
|
-
if (
|
|
8947
|
-
|
|
8948
|
-
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
|
|
8953
|
-
return content.replace(heading, "<!--".concat(sectionName, "-->\n").concat(warningLine, "\n").concat(sectionContent, "\n<!--/").concat(sectionName, "-->\n\n").concat(heading));
|
|
9007
|
+
if (placeForSection !== null) {
|
|
9008
|
+
var _a = __read(placeForSection, 1), heading_1 = _a[0];
|
|
9009
|
+
return content.replace(heading_1, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(contentToInsert), "\n \n ").concat(block(heading_1), "\n "); }));
|
|
9010
|
+
}
|
|
9011
|
+
console.warn("No place where to put the section <!--".concat(sectionName, "-->, using the end of the file"));
|
|
9012
|
+
// <- TODO: [🚎] Some better way how to get warnings from pipeline parsing / logic
|
|
9013
|
+
return spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(content), "\n \n ").concat(block(contentToInsert), "\n "); });
|
|
8954
9014
|
}
|
|
8955
9015
|
/**
|
|
8956
9016
|
* TODO: [🏛] This can be part of markdown builder
|
|
@@ -8978,7 +9038,7 @@
|
|
|
8978
9038
|
if (!task) {
|
|
8979
9039
|
throw new Error("Could not find task for {".concat(parameterName, "}"));
|
|
8980
9040
|
}
|
|
8981
|
-
return normalizeTo_camelCase('task-' + titleToName(task.title));
|
|
9041
|
+
return task.name || normalizeTo_camelCase('task-' + titleToName(task.title));
|
|
8982
9042
|
};
|
|
8983
9043
|
var promptbookMermaid = spaceTrim.spaceTrim(function (block) { return "\n\n %% \uD83D\uDD2E Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually\n\n flowchart LR\n subgraph \"".concat(pipelineJson.title, "\"\n\n direction TB\n\n input((Input)):::input\n ").concat(block(pipelineJson.tasks
|
|
8984
9044
|
.flatMap(function (_a) {
|
|
@@ -9041,7 +9101,7 @@
|
|
|
9041
9101
|
return { href: "#".concat(task.name), title: task.title };
|
|
9042
9102
|
},
|
|
9043
9103
|
});
|
|
9044
|
-
promptbookMermaidBlock = spaceTrim.spaceTrim(function (block) { return "\n
|
|
9104
|
+
promptbookMermaidBlock = spaceTrim.spaceTrim(function (block) { return "\n ```mermaid\n ".concat(block(promptbookMermaid_1), "\n ```\n "); });
|
|
9045
9105
|
pipelineString = addAutoGeneratedSection(pipelineString, {
|
|
9046
9106
|
sectionName: 'Graph',
|
|
9047
9107
|
sectionContent: promptbookMermaidBlock,
|
|
@@ -10656,7 +10716,6 @@
|
|
|
10656
10716
|
exports.DEFAULT_REMOTE_URL_PATH = DEFAULT_REMOTE_URL_PATH;
|
|
10657
10717
|
exports.DEFAULT_SCRAPE_CACHE_DIRNAME = DEFAULT_SCRAPE_CACHE_DIRNAME;
|
|
10658
10718
|
exports.DEFAULT_TITLE = DEFAULT_TITLE;
|
|
10659
|
-
exports.ERRORS = ERRORS;
|
|
10660
10719
|
exports.EXPECTATION_UNITS = EXPECTATION_UNITS;
|
|
10661
10720
|
exports.EnvironmentMismatchError = EnvironmentMismatchError;
|
|
10662
10721
|
exports.ExecutionReportStringOptionsDefaults = ExecutionReportStringOptionsDefaults;
|
|
@@ -10681,6 +10740,7 @@
|
|
|
10681
10740
|
exports.NotFoundError = NotFoundError;
|
|
10682
10741
|
exports.NotYetImplementedError = NotYetImplementedError;
|
|
10683
10742
|
exports.PROMPTBOOK_ENGINE_VERSION = PROMPTBOOK_ENGINE_VERSION;
|
|
10743
|
+
exports.PROMPTBOOK_ERRORS = PROMPTBOOK_ERRORS;
|
|
10684
10744
|
exports.ParseError = ParseError;
|
|
10685
10745
|
exports.PipelineExecutionError = PipelineExecutionError;
|
|
10686
10746
|
exports.PipelineLogicError = PipelineLogicError;
|