@promptbook/core 0.60.0-4 → 0.60.0-5

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.
Files changed (92) hide show
  1. package/README.md +3 -5
  2. package/esm/index.es.js +488 -485
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/promptbook-collection/index.d.ts +1 -1
  5. package/esm/typings/src/_packages/core.index.d.ts +9 -9
  6. package/esm/typings/src/_packages/node.index.d.ts +1 -1
  7. package/esm/typings/src/_packages/types.index.d.ts +3 -3
  8. package/{umd/typings/src/library → esm/typings/src/collection}/PipelineCollection.d.ts +4 -4
  9. package/{umd/typings/src/library → esm/typings/src/collection}/SimplePipelineCollection.d.ts +5 -5
  10. package/{umd/typings/src/library/libraryToJson.d.ts → esm/typings/src/collection/collectionToJson.d.ts} +2 -2
  11. package/esm/typings/src/{library → collection}/constructors/createCollectionFromDirectory.d.ts +3 -3
  12. package/esm/typings/src/{library → collection}/constructors/createCollectionFromJson.d.ts +1 -1
  13. package/{umd/typings/src/library → esm/typings/src/collection}/constructors/createCollectionFromPromise.d.ts +1 -1
  14. package/esm/typings/src/{library → collection}/constructors/createCollectionFromUrl.d.ts +1 -1
  15. package/esm/typings/src/collection/constructors/createSubcollection.d.ts +12 -0
  16. package/esm/typings/src/config.d.ts +2 -2
  17. package/esm/typings/src/conversion/prettify/prettifyPipelineString.d.ts +1 -1
  18. package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +1 -1
  19. package/esm/typings/src/errors/CollectionError.d.ts +1 -1
  20. package/esm/typings/src/errors/ExecutionError.d.ts +1 -1
  21. package/esm/typings/src/errors/NotFoundError.d.ts +1 -1
  22. package/esm/typings/src/execution/EmbeddingVector.d.ts +1 -1
  23. package/esm/typings/src/execution/{PromptbookExecutor.d.ts → PipelineExecutor.d.ts} +3 -3
  24. package/esm/typings/src/execution/assertsExecutionSuccessful.d.ts +2 -2
  25. package/{umd/typings/src/execution/createPromptbookExecutor.d.ts → esm/typings/src/execution/createPipelineExecutor.d.ts} +13 -13
  26. package/esm/typings/src/execution/utils/replaceParameters.d.ts +1 -1
  27. package/esm/typings/src/llm-providers/mocked/joker.test.d.ts +1 -1
  28. package/esm/typings/src/llm-providers/mocked/mocked-chat.test.d.ts +1 -1
  29. package/esm/typings/src/llm-providers/mocked/mocked-completion.test.d.ts +1 -1
  30. package/esm/typings/src/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +4 -4
  31. package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
  32. package/esm/typings/src/types/Command.d.ts +2 -2
  33. package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +5 -5
  34. package/esm/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +1 -1
  35. package/esm/typings/src/types/PipelineString.d.ts +1 -1
  36. package/esm/typings/src/types/Prompt.d.ts +3 -3
  37. package/esm/typings/src/types/TaskProgress.d.ts +1 -1
  38. package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +3 -3
  39. package/esm/typings/src/types/execution-report/config.d.ts +1 -1
  40. package/esm/typings/src/utils/emojis.d.ts +1 -1
  41. package/package.json +1 -1
  42. package/umd/index.umd.js +489 -486
  43. package/umd/index.umd.js.map +1 -1
  44. package/umd/typings/promptbook-collection/index.d.ts +1 -1
  45. package/umd/typings/src/_packages/core.index.d.ts +9 -9
  46. package/umd/typings/src/_packages/node.index.d.ts +1 -1
  47. package/umd/typings/src/_packages/types.index.d.ts +3 -3
  48. package/{esm/typings/src/library → umd/typings/src/collection}/PipelineCollection.d.ts +4 -4
  49. package/{esm/typings/src/library → umd/typings/src/collection}/SimplePipelineCollection.d.ts +5 -5
  50. package/{esm/typings/src/library/libraryToJson.d.ts → umd/typings/src/collection/collectionToJson.d.ts} +2 -2
  51. package/umd/typings/src/{library → collection}/constructors/createCollectionFromDirectory.d.ts +3 -3
  52. package/umd/typings/src/{library → collection}/constructors/createCollectionFromJson.d.ts +1 -1
  53. package/{esm/typings/src/library → umd/typings/src/collection}/constructors/createCollectionFromPromise.d.ts +1 -1
  54. package/umd/typings/src/{library → collection}/constructors/createCollectionFromUrl.d.ts +1 -1
  55. package/umd/typings/src/collection/constructors/createSubcollection.d.ts +12 -0
  56. package/umd/typings/src/config.d.ts +2 -2
  57. package/umd/typings/src/conversion/prettify/prettifyPipelineString.d.ts +1 -1
  58. package/umd/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +1 -1
  59. package/umd/typings/src/errors/CollectionError.d.ts +1 -1
  60. package/umd/typings/src/errors/ExecutionError.d.ts +1 -1
  61. package/umd/typings/src/errors/NotFoundError.d.ts +1 -1
  62. package/umd/typings/src/execution/EmbeddingVector.d.ts +1 -1
  63. package/umd/typings/src/execution/{PromptbookExecutor.d.ts → PipelineExecutor.d.ts} +3 -3
  64. package/umd/typings/src/execution/assertsExecutionSuccessful.d.ts +2 -2
  65. package/{esm/typings/src/execution/createPromptbookExecutor.d.ts → umd/typings/src/execution/createPipelineExecutor.d.ts} +13 -13
  66. package/umd/typings/src/execution/utils/replaceParameters.d.ts +1 -1
  67. package/umd/typings/src/llm-providers/mocked/joker.test.d.ts +1 -1
  68. package/umd/typings/src/llm-providers/mocked/mocked-chat.test.d.ts +1 -1
  69. package/umd/typings/src/llm-providers/mocked/mocked-completion.test.d.ts +1 -1
  70. package/umd/typings/src/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +4 -4
  71. package/umd/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
  72. package/umd/typings/src/types/Command.d.ts +2 -2
  73. package/umd/typings/src/types/PipelineJson/PipelineJson.d.ts +5 -5
  74. package/umd/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +1 -1
  75. package/umd/typings/src/types/PipelineString.d.ts +1 -1
  76. package/umd/typings/src/types/Prompt.d.ts +3 -3
  77. package/umd/typings/src/types/TaskProgress.d.ts +1 -1
  78. package/umd/typings/src/types/execution-report/ExecutionReportJson.d.ts +3 -3
  79. package/umd/typings/src/types/execution-report/config.d.ts +1 -1
  80. package/umd/typings/src/utils/emojis.d.ts +1 -1
  81. package/esm/typings/src/library/constructors/createSubcollection.d.ts +0 -12
  82. package/umd/typings/src/library/constructors/createSubcollection.d.ts +0 -12
  83. /package/esm/typings/src/{library/constructors/createCollectionFromDirectory.test.d.ts → collection/collectionToJson.test.d.ts} +0 -0
  84. /package/{umd/typings/src/library → esm/typings/src/collection}/constructors/createCollectionFromDirectory.test.d.ts +0 -0
  85. /package/esm/typings/src/{library → collection}/constructors/createCollectionFromJson.test.d.ts +0 -0
  86. /package/esm/typings/src/{library → collection}/constructors/createCollectionFromPromise.test.d.ts +0 -0
  87. /package/esm/typings/src/{library → collection}/constructors/justTestFsImport.d.ts +0 -0
  88. /package/{esm/typings/src/library/libraryToJson.test.d.ts → umd/typings/src/collection/collectionToJson.test.d.ts} +0 -0
  89. /package/umd/typings/src/{library/constructors/createCollectionFromJson.test.d.ts → collection/constructors/createCollectionFromDirectory.test.d.ts} +0 -0
  90. /package/umd/typings/src/{library/constructors/createCollectionFromPromise.test.d.ts → collection/constructors/createCollectionFromJson.test.d.ts} +0 -0
  91. /package/umd/typings/src/{library/libraryToJson.test.d.ts → collection/constructors/createCollectionFromPromise.test.d.ts} +0 -0
  92. /package/umd/typings/src/{library → collection}/constructors/justTestFsImport.d.ts +0 -0
package/umd/index.umd.js CHANGED
@@ -129,6 +129,28 @@
129
129
  return to.concat(ar || Array.prototype.slice.call(from));
130
130
  }
131
131
 
132
+ /**
133
+ * Converts PipelineCollection to serialized JSON
134
+ *
135
+ * Note: Functions `collectionToJson` and `createCollectionFromJson` are complementary
136
+ */
137
+ function collectionToJson(collection) {
138
+ return __awaiter(this, void 0, void 0, function () {
139
+ var pipelineUrls, promptbooks;
140
+ return __generator(this, function (_a) {
141
+ switch (_a.label) {
142
+ case 0: return [4 /*yield*/, collection.listPipelines()];
143
+ case 1:
144
+ pipelineUrls = _a.sent();
145
+ return [4 /*yield*/, Promise.all(pipelineUrls.map(function (url) { return collection.getPipelineByUrl(url); }))];
146
+ case 2:
147
+ promptbooks = _a.sent();
148
+ return [2 /*return*/, promptbooks];
149
+ }
150
+ });
151
+ });
152
+ }
153
+
132
154
  /**
133
155
  * Prettify the html code
134
156
  *
@@ -177,7 +199,7 @@
177
199
  */
178
200
  function pipelineJsonToString(pipelineJson) {
179
201
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
180
- var title = pipelineJson.title, promptbookUrl = pipelineJson.promptbookUrl, promptbookVersion = pipelineJson.promptbookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, promptTemplates = pipelineJson.promptTemplates;
202
+ var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, promptbookVersion = pipelineJson.promptbookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, promptTemplates = pipelineJson.promptTemplates;
181
203
  var pipelineString = "# ".concat(title);
182
204
  if (description) {
183
205
  pipelineString += '\n\n';
@@ -185,8 +207,8 @@
185
207
  }
186
208
  // TODO:> const commands: Array<Command>
187
209
  var commands = [];
188
- if (promptbookUrl) {
189
- commands.push("PROMPTBOOK URL ".concat(promptbookUrl));
210
+ if (pipelineUrl) {
211
+ commands.push("PIPELINE URL ".concat(pipelineUrl));
190
212
  }
191
213
  commands.push("PROMPTBOOK VERSION ".concat(promptbookVersion));
192
214
  pipelineString = prettifyMarkdown(pipelineString);
@@ -368,47 +390,6 @@
368
390
  * TODO: Escape all
369
391
  */
370
392
 
371
- var PipelineCollection = [{title:"Prepare Keywords",promptbookUrl:"https://promptbook.studio/promptbook/prepare-keywords.ptbk.md",promptbookVersion:"0.60.0-3",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],executionType:"PROMPT_TEMPLATE",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {content}",resultingParameterName:"keywords"}],knowledge:[]},{title:"Prepare Knowledge from Markdown",promptbookUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.60.0-3",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledge",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],executionType:"PROMPT_TEMPLATE",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {content}",resultingParameterName:"knowledge"}],knowledge:[]}];
372
-
373
- /**
374
- * This error indicates errors during the execution of the promptbook
375
- */
376
- var ExecutionError = /** @class */ (function (_super) {
377
- __extends(ExecutionError, _super);
378
- function ExecutionError(message) {
379
- var _this = _super.call(this, message) || this;
380
- _this.name = 'ExecutionError';
381
- Object.setPrototypeOf(_this, ExecutionError.prototype);
382
- return _this;
383
- }
384
- return ExecutionError;
385
- }(Error));
386
-
387
- /**
388
- * Asserts that the execution of a promptnook is successful
389
- *
390
- * @param executionResult - The partial result of the promptnook execution
391
- * @throws {ExecutionError} If the execution is not successful or if multiple errors occurred
392
- */
393
- function assertsExecutionSuccessful(executionResult) {
394
- var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors;
395
- if (isSuccessful === true) {
396
- return;
397
- }
398
- if (errors.length === 0) {
399
- throw new ExecutionError("Promptnook Execution failed because of unknown reason");
400
- }
401
- else if (errors.length === 1) {
402
- throw errors[0];
403
- }
404
- else {
405
- throw new ExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Multiple errors occurred during promptnook execution\n\n ".concat(block(errors.map(function (error) { return '- ' + error.message; }).join('\n')), "\n "); }));
406
- }
407
- }
408
- /**
409
- * TODO: [🧠] Can this return type be better typed than void
410
- */
411
-
412
393
  /**
413
394
  * The maximum number of iterations for a loops
414
395
  */
@@ -448,7 +429,7 @@
448
429
  var UnexpectedError = /** @class */ (function (_super) {
449
430
  __extends(UnexpectedError, _super);
450
431
  function UnexpectedError(message) {
451
- var _this = _super.call(this, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the promptbook library\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
432
+ var _this = _super.call(this, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
452
433
  _this.name = 'UnexpectedError';
453
434
  Object.setPrototypeOf(_this, UnexpectedError.prototype);
454
435
  return _this;
@@ -498,10 +479,10 @@
498
479
  function validatePipeline(pipeline) {
499
480
  // TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
500
481
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
501
- if (pipeline.promptbookUrl !== undefined) {
502
- if (!isValidUrl(pipeline.promptbookUrl)) {
482
+ if (pipeline.pipelineUrl !== undefined) {
483
+ if (!isValidUrl(pipeline.pipelineUrl)) {
503
484
  // TODO: This should be maybe the syntax error detected during parsing
504
- throw new PipelineLogicError("Invalid promptbook URL \"".concat(pipeline.promptbookUrl, "\""));
485
+ throw new PipelineLogicError("Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\""));
505
486
  }
506
487
  }
507
488
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
@@ -667,6 +648,369 @@
667
648
  * > ex port function validatePipeline(promptbook: unknown): asserts promptbook is PipelineJson {
668
649
  */
669
650
 
651
+ /**
652
+ * This error indicates that promptbook not found in the collection
653
+ */
654
+ var NotFoundError = /** @class */ (function (_super) {
655
+ __extends(NotFoundError, _super);
656
+ function NotFoundError(message) {
657
+ var _this = _super.call(this, message) || this;
658
+ _this.name = 'NotFoundError';
659
+ Object.setPrototypeOf(_this, NotFoundError.prototype);
660
+ return _this;
661
+ }
662
+ return NotFoundError;
663
+ }(Error));
664
+
665
+ /**
666
+ * This error indicates errors in referencing promptbooks between each other
667
+ */
668
+ var ReferenceError$1 = /** @class */ (function (_super) {
669
+ __extends(ReferenceError, _super);
670
+ function ReferenceError(message) {
671
+ var _this = _super.call(this, message) || this;
672
+ _this.name = 'ReferenceError';
673
+ Object.setPrototypeOf(_this, ReferenceError.prototype);
674
+ return _this;
675
+ }
676
+ return ReferenceError;
677
+ }(Error));
678
+
679
+ /**
680
+ * Library of promptbooks that groups together promptbooks for an application.
681
+ * This implementation is a very thin wrapper around the Array / Map of promptbooks.
682
+ *
683
+ * @private use `createCollectionFromJson` instead
684
+ * @see https://github.com/webgptorg/promptbook#promptbook-collection
685
+ */
686
+ var SimplePipelineCollection = /** @class */ (function () {
687
+ /**
688
+ * Constructs a pipeline collection from promptbooks
689
+ *
690
+ * @param promptbooks !!!
691
+ *
692
+ * @private Use instead `createCollectionFromJson`
693
+ * Note: During the construction logic of all promptbooks are validated
694
+ * Note: It is not recommended to use this constructor directly, use `createCollectionFromJson` *(or other variant)* instead
695
+ */
696
+ function SimplePipelineCollection() {
697
+ var e_1, _a;
698
+ var promptbooks = [];
699
+ for (var _i = 0; _i < arguments.length; _i++) {
700
+ promptbooks[_i] = arguments[_i];
701
+ }
702
+ this.collection = new Map();
703
+ try {
704
+ for (var promptbooks_1 = __values(promptbooks), promptbooks_1_1 = promptbooks_1.next(); !promptbooks_1_1.done; promptbooks_1_1 = promptbooks_1.next()) {
705
+ var promptbook = promptbooks_1_1.value;
706
+ if (promptbook.pipelineUrl === undefined) {
707
+ throw new ReferenceError$1(spaceTrim.spaceTrim("\n Promptbook with name \"".concat(promptbook.title, "\" does not have defined URL\n\n Note: Promptbooks without URLs are called anonymous promptbooks\n They can be used as standalone promptbooks, but they cannot be referenced by other promptbooks\n And also they cannot be used in the pipeline collection\n\n ")));
708
+ }
709
+ validatePipeline(promptbook);
710
+ // Note: [🦄]
711
+ if (this.collection.has(promptbook.pipelineUrl) &&
712
+ pipelineJsonToString(promptbook) !== pipelineJsonToString(this.collection.get(promptbook.pipelineUrl))) {
713
+ throw new ReferenceError$1(spaceTrim.spaceTrim("\n Promptbook with URL \"".concat(promptbook.pipelineUrl, "\" is already in the collection\n\n Note: Promptbooks with the same URL are not allowed\n Note: Automatically check whether the promptbooks are the same BUT they are DIFFERENT\n\n ")));
714
+ }
715
+ this.collection.set(promptbook.pipelineUrl, promptbook);
716
+ }
717
+ }
718
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
719
+ finally {
720
+ try {
721
+ if (promptbooks_1_1 && !promptbooks_1_1.done && (_a = promptbooks_1.return)) _a.call(promptbooks_1);
722
+ }
723
+ finally { if (e_1) throw e_1.error; }
724
+ }
725
+ }
726
+ /**
727
+ * Gets all promptbooks in the collection
728
+ */
729
+ SimplePipelineCollection.prototype.listPipelines = function () {
730
+ return Array.from(this.collection.keys());
731
+ };
732
+ /**
733
+ * Gets promptbook by its URL
734
+ *
735
+ * Note: This is not a direct fetching from the URL, but a lookup in the collection
736
+ */
737
+ SimplePipelineCollection.prototype.getPipelineByUrl = function (url) {
738
+ var _this = this;
739
+ var promptbook = this.collection.get(url);
740
+ if (!promptbook) {
741
+ if (this.listPipelines().length === 0) {
742
+ throw new NotFoundError(spaceTrim.spaceTrim("\n Promptbook with url \"".concat(url, "\" not found\n\n No promptbooks available\n ")));
743
+ }
744
+ throw new NotFoundError(spaceTrim.spaceTrim(function (block) { return "\n Promptbook with url \"".concat(url, "\" not found\n\n Available promptbooks:\n ").concat(block(_this.listPipelines()
745
+ .map(function (pipelineUrl) { return "- ".concat(pipelineUrl); })
746
+ .join('\n')), "\n\n "); }));
747
+ }
748
+ return promptbook;
749
+ };
750
+ /**
751
+ * Checks whether given prompt was defined in any promptbook in the collection
752
+ */
753
+ SimplePipelineCollection.prototype.isResponsibleForPrompt = function (prompt) {
754
+ return true;
755
+ };
756
+ return SimplePipelineCollection;
757
+ }());
758
+
759
+ /**
760
+ * Creates PipelineCollection from array of PipelineJson or PipelineString
761
+ *
762
+ * Note: Functions `collectionToJson` and `createCollectionFromJson` are complementary
763
+ * Note: During the construction syntax and logic of all sources are validated
764
+ *
765
+ * @param promptbookSources
766
+ * @returns PipelineCollection
767
+ */
768
+ function createCollectionFromJson() {
769
+ var promptbooks = [];
770
+ for (var _i = 0; _i < arguments.length; _i++) {
771
+ promptbooks[_i] = arguments[_i];
772
+ }
773
+ return new (SimplePipelineCollection.bind.apply(SimplePipelineCollection, __spreadArray([void 0], __read(promptbooks), false)))();
774
+ }
775
+
776
+ /**
777
+ * Constructs Promptbook from async sources
778
+ * It can be one of the following:
779
+ * - Promise of array of PipelineJson or PipelineString
780
+ * - Factory function that returns Promise of array of PipelineJson or PipelineString
781
+ *
782
+ * Note: This is useful as internal tool for other constructor functions like
783
+ * `createCollectionFromUrl` or `createCollectionFromDirectory`
784
+ * Consider using those functions instead of this one
785
+ *
786
+ * Note: The function does NOT return promise it returns the collection directly which waits for the sources to be resolved
787
+ * when error occurs in given promise or factory function, it is thrown during `listPipelines` or `getPipelineByUrl` call
788
+ *
789
+ * Note: Consider using `createCollectionFromDirectory` or `createCollectionFromUrl`
790
+ *
791
+ * @param promptbookSourcesPromiseOrFactory
792
+ * @returns PipelineCollection
793
+ * @deprecated Do not use, it will became internal tool for other constructor functions
794
+ */
795
+ function createCollectionFromPromise(promptbookSourcesPromiseOrFactory) {
796
+ var collection;
797
+ function forSources() {
798
+ return __awaiter(this, void 0, void 0, function () {
799
+ var promptbookSources;
800
+ return __generator(this, function (_a) {
801
+ switch (_a.label) {
802
+ case 0:
803
+ if (typeof promptbookSourcesPromiseOrFactory === 'function') {
804
+ // Note: Calling factory function only once despite multiple calls to resolveSources
805
+ promptbookSourcesPromiseOrFactory = promptbookSourcesPromiseOrFactory();
806
+ }
807
+ return [4 /*yield*/, promptbookSourcesPromiseOrFactory];
808
+ case 1:
809
+ promptbookSources = _a.sent();
810
+ collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(promptbookSources), false));
811
+ return [2 /*return*/];
812
+ }
813
+ });
814
+ });
815
+ }
816
+ function listPipelines() {
817
+ return __awaiter(this, void 0, void 0, function () {
818
+ return __generator(this, function (_a) {
819
+ switch (_a.label) {
820
+ case 0: return [4 /*yield*/, forSources()];
821
+ case 1:
822
+ _a.sent();
823
+ return [2 /*return*/, /* not await */ collection.listPipelines()];
824
+ }
825
+ });
826
+ });
827
+ }
828
+ function getPipelineByUrl(url) {
829
+ return __awaiter(this, void 0, void 0, function () {
830
+ return __generator(this, function (_a) {
831
+ switch (_a.label) {
832
+ case 0: return [4 /*yield*/, forSources()];
833
+ case 1:
834
+ _a.sent();
835
+ return [2 /*return*/, /* not await */ collection.getPipelineByUrl(url)];
836
+ }
837
+ });
838
+ });
839
+ }
840
+ function isResponsibleForPrompt(prompt) {
841
+ return __awaiter(this, void 0, void 0, function () {
842
+ return __generator(this, function (_a) {
843
+ switch (_a.label) {
844
+ case 0: return [4 /*yield*/, forSources()];
845
+ case 1:
846
+ _a.sent();
847
+ return [2 /*return*/, /* not await */ collection.isResponsibleForPrompt(prompt)];
848
+ }
849
+ });
850
+ });
851
+ }
852
+ return {
853
+ listPipelines: listPipelines,
854
+ getPipelineByUrl: getPipelineByUrl,
855
+ isResponsibleForPrompt: isResponsibleForPrompt,
856
+ };
857
+ }
858
+
859
+ /**
860
+ * Constructs Promptbook from remote Promptbase URL
861
+
862
+ * @returns PipelineCollection
863
+ */
864
+ function createCollectionFromUrl(url, options) {
865
+ return __awaiter(this, void 0, void 0, function () {
866
+ var _a, _b, isVerbose, _c, isLazyLoaded, collection;
867
+ var _this = this;
868
+ return __generator(this, function (_d) {
869
+ switch (_d.label) {
870
+ case 0:
871
+ _a = options || {}, _b = _a.isVerbose, isVerbose = _b === void 0 ? false : _b, _c = _a.isLazyLoaded, isLazyLoaded = _c === void 0 ? false : _c;
872
+ collection = createCollectionFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
873
+ return __generator(this, function (_a) {
874
+ if (isVerbose) {
875
+ console.info("Creating pipeline collection from url ".concat(url.toString()));
876
+ }
877
+ throw new Error('Not implemented yet');
878
+ });
879
+ }); });
880
+ if (!(isLazyLoaded === false)) return [3 /*break*/, 2];
881
+ return [4 /*yield*/, collection.listPipelines()];
882
+ case 1:
883
+ _d.sent();
884
+ _d.label = 2;
885
+ case 2: return [2 /*return*/, collection];
886
+ }
887
+ });
888
+ });
889
+ }
890
+ /**
891
+ * TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
892
+ */
893
+
894
+ /**
895
+ * Creates PipelineCollection as a subset of another PipelineCollection
896
+ *
897
+ * Note: You can use any type of collection as a parent collection - local, remote, etc.
898
+ * Note: This is just a thin wrapper / proxy around the parent collection
899
+ *
900
+ * @param promptbookSources
901
+ * @returns PipelineCollection
902
+ */
903
+ function createSubcollection(collection, predicate) {
904
+ function listPipelines() {
905
+ return __awaiter(this, void 0, void 0, function () {
906
+ var promptbooks;
907
+ return __generator(this, function (_a) {
908
+ switch (_a.label) {
909
+ case 0: return [4 /*yield*/, collection.listPipelines()];
910
+ case 1:
911
+ promptbooks = _a.sent();
912
+ promptbooks = promptbooks.filter(predicate);
913
+ return [2 /*return*/, promptbooks];
914
+ }
915
+ });
916
+ });
917
+ }
918
+ function getPipelineByUrl(url) {
919
+ return __awaiter(this, void 0, void 0, function () {
920
+ var _a, pipeline;
921
+ var _this = this;
922
+ return __generator(this, function (_b) {
923
+ switch (_b.label) {
924
+ case 0:
925
+ if (!!predicate(url)) return [3 /*break*/, 2];
926
+ _a = NotFoundError.bind;
927
+ return [4 /*yield*/, spaceTrim.spaceTrim(function (block) { return __awaiter(_this, void 0, void 0, function () {
928
+ var _a, _b, _c, _d, _e, _f;
929
+ return __generator(this, function (_g) {
930
+ switch (_g.label) {
931
+ case 0:
932
+ _c = (_b = "\n Promptbook with url \"".concat(url, "\" not found or not accessible\n\n Available promptbooks:\n ")).concat;
933
+ _d = block;
934
+ return [4 /*yield*/, listPipelines()];
935
+ case 1:
936
+ _e = (_a = _c.apply(_b, [_d.apply(void 0, [(_g.sent()).map(function (pipelineUrl) { return "- ".concat(pipelineUrl); }).join('\n')]), "\n\n All available promptbooks in parent collection:\n "])).concat;
937
+ _f = block;
938
+ return [4 /*yield*/, collection.listPipelines()];
939
+ case 2: return [2 /*return*/, _e.apply(_a, [_f.apply(void 0, [(_g.sent()).map(function (pipelineUrl) { return "- ".concat(pipelineUrl); }).join('\n')]), "\n\n "])];
940
+ }
941
+ });
942
+ }); })];
943
+ case 1: throw new (_a.apply(NotFoundError, [void 0, _b.sent()]))();
944
+ case 2: return [4 /*yield*/, collection.getPipelineByUrl(url)];
945
+ case 3:
946
+ pipeline = _b.sent();
947
+ return [2 /*return*/, pipeline];
948
+ }
949
+ });
950
+ });
951
+ }
952
+ function isResponsibleForPrompt(prompt) {
953
+ return __awaiter(this, void 0, void 0, function () {
954
+ var isResponsible;
955
+ return __generator(this, function (_a) {
956
+ switch (_a.label) {
957
+ case 0: return [4 /*yield*/, collection.isResponsibleForPrompt(prompt)];
958
+ case 1:
959
+ isResponsible = _a.sent();
960
+ // TODO: !! Only if responsible, check if predicate is true
961
+ return [2 /*return*/, isResponsible];
962
+ }
963
+ });
964
+ });
965
+ }
966
+ return {
967
+ listPipelines: listPipelines,
968
+ getPipelineByUrl: getPipelineByUrl,
969
+ isResponsibleForPrompt: isResponsibleForPrompt,
970
+ };
971
+ }
972
+
973
+ var PipelineCollection = [{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-keywords.ptbk.md",promptbookVersion:"0.60.0-4",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],executionType:"PROMPT_TEMPLATE",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {content}",resultingParameterName:"keywords"}],knowledge:[]},{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.60.0-4",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledge",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],executionType:"PROMPT_TEMPLATE",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {content}",resultingParameterName:"knowledge"}],knowledge:[]}];
974
+
975
+ /**
976
+ * This error indicates errors during the execution of the pipeline
977
+ */
978
+ var ExecutionError = /** @class */ (function (_super) {
979
+ __extends(ExecutionError, _super);
980
+ function ExecutionError(message) {
981
+ var _this = _super.call(this, message) || this;
982
+ _this.name = 'ExecutionError';
983
+ Object.setPrototypeOf(_this, ExecutionError.prototype);
984
+ return _this;
985
+ }
986
+ return ExecutionError;
987
+ }(Error));
988
+
989
+ /**
990
+ * Asserts that the execution of a promptnook is successful
991
+ *
992
+ * @param executionResult - The partial result of the promptnook execution
993
+ * @throws {ExecutionError} If the execution is not successful or if multiple errors occurred
994
+ */
995
+ function assertsExecutionSuccessful(executionResult) {
996
+ var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors;
997
+ if (isSuccessful === true) {
998
+ return;
999
+ }
1000
+ if (errors.length === 0) {
1001
+ throw new ExecutionError("Promptnook Execution failed because of unknown reason");
1002
+ }
1003
+ else if (errors.length === 1) {
1004
+ throw errors[0];
1005
+ }
1006
+ else {
1007
+ throw new ExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Multiple errors occurred during promptnook execution\n\n ".concat(block(errors.map(function (error) { return '- ' + error.message; }).join('\n')), "\n "); }));
1008
+ }
1009
+ }
1010
+ /**
1011
+ * TODO: [🧠] Can this return type be better typed than void
1012
+ */
1013
+
670
1014
  /**
671
1015
  * This error occurs when some expectation is not met in the execution of the pipeline
672
1016
  *
@@ -706,7 +1050,7 @@
706
1050
  /**
707
1051
  * The version of the Promptbook library
708
1052
  */
709
- var PROMPTBOOK_VERSION = '0.60.0-3';
1053
+ var PROMPTBOOK_VERSION = '0.60.0-4';
710
1054
 
711
1055
  /**
712
1056
  * Function `addUsage` will add multiple usages into one
@@ -1206,7 +1550,7 @@
1206
1550
  * @returns the template with replaced parameters
1207
1551
  * @throws {TemplateError} if parameter is not defined, not closed, or not opened
1208
1552
  *
1209
- * @private within the createPromptbookExecutor
1553
+ * @private within the createPipelineExecutor
1210
1554
  */
1211
1555
  function replaceParameters(template, parameters) {
1212
1556
  var replacedTemplate = template;
@@ -1259,17 +1603,17 @@
1259
1603
  }
1260
1604
 
1261
1605
  /**
1262
- * Creates executor function from promptbook and execution tools.
1606
+ * Creates executor function from pipeline and execution tools.
1263
1607
  *
1264
1608
  * @returns The executor function
1265
- * @throws {PipelineLogicError} on logical error in the promptbook
1609
+ * @throws {PipelineLogicError} on logical error in the pipeline
1266
1610
  */
1267
- function createPromptbookExecutor(options) {
1611
+ function createPipelineExecutor(options) {
1268
1612
  var _this = this;
1269
- var promptbook = options.promptbook, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
1613
+ var pipeline = options.pipeline, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
1270
1614
  var _b = settings.maxExecutionAttempts, maxExecutionAttempts = _b === void 0 ? 3 : _b;
1271
- validatePipeline(promptbook);
1272
- var promptbookExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
1615
+ validatePipeline(pipeline);
1616
+ var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
1273
1617
  function executeSingleTemplate(currentTemplate) {
1274
1618
  return __awaiter(this, void 0, void 0, function () {
1275
1619
  var name, title, priority, prompt, chatThread, completionResult, result, resultString, expectError, scriptExecutionErrors, maxAttempts, jokers, attempt, isJokerAttempt, joker, _a, _b, _c, _d, scriptTools, error_2, e_2_1, _e, _f, functionName, postprocessingError, _g, _h, scriptTools, error_3, e_3_1, e_4_1, error_4;
@@ -1278,9 +1622,9 @@
1278
1622
  return __generator(this, function (_o) {
1279
1623
  switch (_o.label) {
1280
1624
  case 0:
1281
- name = "promptbook-executor-frame-".concat(currentTemplate.name);
1625
+ name = "pipeline-executor-frame-".concat(currentTemplate.name);
1282
1626
  title = currentTemplate.title;
1283
- priority = promptbook.promptTemplates.length - promptbook.promptTemplates.indexOf(currentTemplate);
1627
+ priority = pipeline.promptTemplates.length - pipeline.promptTemplates.indexOf(currentTemplate);
1284
1628
  if (!onProgress /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
1285
1629
  return [4 /*yield*/, onProgress({
1286
1630
  name: name,
@@ -1337,9 +1681,9 @@
1337
1681
  case 6:
1338
1682
  prompt = {
1339
1683
  title: currentTemplate.title,
1340
- promptbookUrl: "".concat(promptbook.promptbookUrl
1341
- ? promptbook.promptbookUrl
1342
- : 'anonymous' /* <- TODO: [🧠] How to deal with anonymous PROMPTBOOKs, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(currentTemplate.name),
1684
+ pipelineUrl: "".concat(pipeline.pipelineUrl
1685
+ ? pipeline.pipelineUrl
1686
+ : 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(currentTemplate.name),
1343
1687
  parameters: parametersToPass,
1344
1688
  content: replaceParameters(currentTemplate.content, parametersToPass) /* <- [2] */,
1345
1689
  modelRequirements: currentTemplate.modelRequirements,
@@ -1616,7 +1960,7 @@
1616
1960
  // TODO: [🧠] Maybe put other executionTypes into report
1617
1961
  executionReport.promptExecutions.push({
1618
1962
  prompt: {
1619
- title: currentTemplate.title /* <- Note: If title in promptbook contains emojis, pass it innto report */,
1963
+ title: currentTemplate.title /* <- Note: If title in pipeline contains emojis, pass it innto report */,
1620
1964
  content: prompt.content,
1621
1965
  modelRequirements: prompt.modelRequirements,
1622
1966
  expectations: prompt.expectations,
@@ -1652,7 +1996,7 @@
1652
1996
  // <- [3]
1653
1997
  });
1654
1998
  }
1655
- parametersToPass = __assign(__assign({}, parametersToPass), (_m = {}, _m[currentTemplate.resultingParameterName] = resultString /* <- Note: Not need to detect parameter collision here because Promptbook checks logic consistency during construction */, _m));
1999
+ parametersToPass = __assign(__assign({}, parametersToPass), (_m = {}, _m[currentTemplate.resultingParameterName] = resultString /* <- Note: Not need to detect parameter collision here because pipeline checks logic consistency during construction */, _m));
1656
2000
  return [2 /*return*/];
1657
2001
  }
1658
2002
  });
@@ -1665,17 +2009,17 @@
1665
2009
  case 0:
1666
2010
  parametersToPass = inputParameters;
1667
2011
  executionReport = {
1668
- promptbookUrl: promptbook.promptbookUrl,
1669
- title: promptbook.title,
2012
+ pipelineUrl: pipeline.pipelineUrl,
2013
+ title: pipeline.title,
1670
2014
  promptbookUsedVersion: PROMPTBOOK_VERSION,
1671
- promptbookRequestedVersion: promptbook.promptbookVersion,
1672
- description: promptbook.description,
2015
+ promptbookRequestedVersion: pipeline.promptbookVersion,
2016
+ description: pipeline.description,
1673
2017
  promptExecutions: [],
1674
2018
  };
1675
2019
  _d.label = 1;
1676
2020
  case 1:
1677
2021
  _d.trys.push([1, 6, , 7]);
1678
- resovedParameters_1 = promptbook.parameters
2022
+ resovedParameters_1 = pipeline.parameters
1679
2023
  .filter(function (_a) {
1680
2024
  var isInput = _a.isInput;
1681
2025
  return isInput;
@@ -1684,7 +2028,7 @@
1684
2028
  var name = _a.name;
1685
2029
  return name;
1686
2030
  });
1687
- unresovedTemplates = __spreadArray([], __read(promptbook.promptTemplates), false);
2031
+ unresovedTemplates = __spreadArray([], __read(pipeline.promptTemplates), false);
1688
2032
  resolving_1 = [];
1689
2033
  loopLimit = LOOP_LIMIT;
1690
2034
  _loop_1 = function () {
@@ -1693,7 +2037,7 @@
1693
2037
  switch (_e.label) {
1694
2038
  case 0:
1695
2039
  if (loopLimit-- < 0) {
1696
- throw new UnexpectedError('Loop limit reached during resolving parameters promptbook execution');
2040
+ throw new UnexpectedError('Loop limit reached during resolving parameters pipeline execution');
1697
2041
  }
1698
2042
  currentTemplate = unresovedTemplates.find(function (template) {
1699
2043
  return template.dependentParameterNames.every(function (name) { return resovedParameters_1.includes(name); });
@@ -1742,177 +2086,52 @@
1742
2086
  return (result === null || result === void 0 ? void 0 : result.usage) || addUsage();
1743
2087
  })), false));
1744
2088
  return [2 /*return*/, {
1745
- isSuccessful: false,
1746
- errors: [error_1],
1747
- usage: usage_1,
1748
- executionReport: executionReport,
1749
- outputParameters: parametersToPass,
1750
- }];
1751
- case 7:
1752
- try {
1753
- // Note: Filter ONLY output parameters
1754
- for (_a = __values(promptbook.parameters), _b = _a.next(); !_b.done; _b = _a.next()) {
1755
- parameter = _b.value;
1756
- if (parameter.isOutput) {
1757
- continue;
1758
- }
1759
- delete parametersToPass[parameter.name];
1760
- }
1761
- }
1762
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1763
- finally {
1764
- try {
1765
- if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
1766
- }
1767
- finally { if (e_1) throw e_1.error; }
1768
- }
1769
- usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
1770
- var result = _a.result;
1771
- return (result === null || result === void 0 ? void 0 : result.usage) || addUsage();
1772
- })), false));
1773
- return [2 /*return*/, {
1774
- isSuccessful: true,
1775
- errors: [],
1776
- usage: usage,
1777
- executionReport: executionReport,
1778
- outputParameters: parametersToPass,
1779
- }];
1780
- }
1781
- });
1782
- }); };
1783
- return promptbookExecutor;
1784
- }
1785
- /**
1786
- * TODO: [🧠] When not meet expectations in PROMPT_DIALOG, make some way to tell the user
1787
- * TODO: [👧] Strongly type the executors to avoid need of remove nullables whtn noUncheckedIndexedAccess in tsconfig.json
1788
- * Note: CreatePromptbookExecutorOptions are just connected to PromptbookExecutor so do not extract to types folder
1789
- * TODO: [🧠][3] transparent = (report intermediate parameters) / opaque execution = (report only output parameters) progress reporting mode
1790
- */
1791
-
1792
- /**
1793
- * This error indicates that promptbook not found in the library
1794
- */
1795
- var NotFoundError = /** @class */ (function (_super) {
1796
- __extends(NotFoundError, _super);
1797
- function NotFoundError(message) {
1798
- var _this = _super.call(this, message) || this;
1799
- _this.name = 'NotFoundError';
1800
- Object.setPrototypeOf(_this, NotFoundError.prototype);
1801
- return _this;
1802
- }
1803
- return NotFoundError;
1804
- }(Error));
1805
-
1806
- /**
1807
- * This error indicates errors in referencing promptbooks between each other
1808
- */
1809
- var ReferenceError$1 = /** @class */ (function (_super) {
1810
- __extends(ReferenceError, _super);
1811
- function ReferenceError(message) {
1812
- var _this = _super.call(this, message) || this;
1813
- _this.name = 'ReferenceError';
1814
- Object.setPrototypeOf(_this, ReferenceError.prototype);
1815
- return _this;
1816
- }
1817
- return ReferenceError;
1818
- }(Error));
1819
-
1820
- /**
1821
- * Library of promptbooks that groups together promptbooks for an application.
1822
- * This implementation is a very thin wrapper around the Array / Map of promptbooks.
1823
- *
1824
- * @private use `createCollectionFromJson` instead
1825
- * @see https://github.com/webgptorg/promptbook#promptbook-collection
1826
- */
1827
- var SimplePipelineCollection = /** @class */ (function () {
1828
- /**
1829
- * Constructs a promptbook library from promptbooks
1830
- *
1831
- * @param promptbooks !!!
1832
- *
1833
- * @private Use instead `createCollectionFromJson`
1834
- * Note: During the construction logic of all promptbooks are validated
1835
- * Note: It is not recommended to use this constructor directly, use `createCollectionFromJson` *(or other variant)* instead
1836
- */
1837
- function SimplePipelineCollection() {
1838
- var e_1, _a;
1839
- var promptbooks = [];
1840
- for (var _i = 0; _i < arguments.length; _i++) {
1841
- promptbooks[_i] = arguments[_i];
1842
- }
1843
- this.library = new Map();
1844
- try {
1845
- for (var promptbooks_1 = __values(promptbooks), promptbooks_1_1 = promptbooks_1.next(); !promptbooks_1_1.done; promptbooks_1_1 = promptbooks_1.next()) {
1846
- var promptbook = promptbooks_1_1.value;
1847
- if (promptbook.promptbookUrl === undefined) {
1848
- throw new ReferenceError$1(spaceTrim.spaceTrim("\n Promptbook with name \"".concat(promptbook.title, "\" does not have defined URL\n\n Note: Promptbooks without URLs are called anonymous promptbooks\n They can be used as standalone promptbooks, but they cannot be referenced by other promptbooks\n And also they cannot be used in the promptbook library\n\n ")));
1849
- }
1850
- validatePipeline(promptbook);
1851
- // Note: [🦄]
1852
- if (this.library.has(promptbook.promptbookUrl) &&
1853
- pipelineJsonToString(promptbook) !== pipelineJsonToString(this.library.get(promptbook.promptbookUrl))) {
1854
- throw new ReferenceError$1(spaceTrim.spaceTrim("\n Promptbook with URL \"".concat(promptbook.promptbookUrl, "\" is already in the library\n\n Note: Promptbooks with the same URL are not allowed\n Note: Automatically check whether the promptbooks are the same BUT they are DIFFERENT\n\n ")));
1855
- }
1856
- this.library.set(promptbook.promptbookUrl, promptbook);
1857
- }
1858
- }
1859
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1860
- finally {
1861
- try {
1862
- if (promptbooks_1_1 && !promptbooks_1_1.done && (_a = promptbooks_1.return)) _a.call(promptbooks_1);
1863
- }
1864
- finally { if (e_1) throw e_1.error; }
1865
- }
1866
- }
1867
- /**
1868
- * Gets all promptbooks in the library
1869
- */
1870
- SimplePipelineCollection.prototype.listPipelines = function () {
1871
- return Array.from(this.library.keys());
1872
- };
1873
- /**
1874
- * Gets promptbook by its URL
1875
- *
1876
- * Note: This is not a direct fetching from the URL, but a lookup in the library
1877
- */
1878
- SimplePipelineCollection.prototype.getPipelineByUrl = function (url) {
1879
- var _this = this;
1880
- var promptbook = this.library.get(url);
1881
- if (!promptbook) {
1882
- if (this.listPipelines().length === 0) {
1883
- throw new NotFoundError(spaceTrim.spaceTrim("\n Promptbook with url \"".concat(url, "\" not found\n\n No promptbooks available\n ")));
2089
+ isSuccessful: false,
2090
+ errors: [error_1],
2091
+ usage: usage_1,
2092
+ executionReport: executionReport,
2093
+ outputParameters: parametersToPass,
2094
+ }];
2095
+ case 7:
2096
+ try {
2097
+ // Note: Filter ONLY output parameters
2098
+ for (_a = __values(pipeline.parameters), _b = _a.next(); !_b.done; _b = _a.next()) {
2099
+ parameter = _b.value;
2100
+ if (parameter.isOutput) {
2101
+ continue;
2102
+ }
2103
+ delete parametersToPass[parameter.name];
2104
+ }
2105
+ }
2106
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2107
+ finally {
2108
+ try {
2109
+ if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
2110
+ }
2111
+ finally { if (e_1) throw e_1.error; }
2112
+ }
2113
+ usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
2114
+ var result = _a.result;
2115
+ return (result === null || result === void 0 ? void 0 : result.usage) || addUsage();
2116
+ })), false));
2117
+ return [2 /*return*/, {
2118
+ isSuccessful: true,
2119
+ errors: [],
2120
+ usage: usage,
2121
+ executionReport: executionReport,
2122
+ outputParameters: parametersToPass,
2123
+ }];
1884
2124
  }
1885
- throw new NotFoundError(spaceTrim.spaceTrim(function (block) { return "\n Promptbook with url \"".concat(url, "\" not found\n\n Available promptbooks:\n ").concat(block(_this.listPipelines()
1886
- .map(function (promptbookUrl) { return "- ".concat(promptbookUrl); })
1887
- .join('\n')), "\n\n "); }));
1888
- }
1889
- return promptbook;
1890
- };
1891
- /**
1892
- * Checks whether given prompt was defined in any promptbook in the library
1893
- */
1894
- SimplePipelineCollection.prototype.isResponsibleForPrompt = function (prompt) {
1895
- return true;
1896
- };
1897
- return SimplePipelineCollection;
1898
- }());
1899
-
2125
+ });
2126
+ }); };
2127
+ return pipelineExecutor;
2128
+ }
1900
2129
  /**
1901
- * Creates PipelineCollection from array of PipelineJson or PipelineString
1902
- *
1903
- * Note: Functions `libraryToJson` and `createCollectionFromJson` are complementary
1904
- * Note: During the construction syntax and logic of all sources are validated
1905
- *
1906
- * @param promptbookSources
1907
- * @returns PipelineCollection
2130
+ * TODO: [🧠] When not meet expectations in PROMPT_DIALOG, make some way to tell the user
2131
+ * TODO: [👧] Strongly type the executors to avoid need of remove nullables whtn noUncheckedIndexedAccess in tsconfig.json
2132
+ * Note: CreatePipelineExecutorOptions are just connected to PipelineExecutor so do not extract to types folder
2133
+ * TODO: [🧠][3] transparent = (report intermediate parameters) / opaque execution = (report only output parameters) progress reporting mode
1908
2134
  */
1909
- function createCollectionFromJson() {
1910
- var promptbooks = [];
1911
- for (var _i = 0; _i < arguments.length; _i++) {
1912
- promptbooks[_i] = arguments[_i];
1913
- }
1914
- return new (SimplePipelineCollection.bind.apply(SimplePipelineCollection, __spreadArray([void 0], __read(promptbooks), false)))();
1915
- }
1916
2135
 
1917
2136
  /* tslint:disable */
1918
2137
  function normalizeToKebabCase(sentence) {
@@ -1971,18 +2190,18 @@
1971
2190
 
1972
2191
  function prepareKnowledgeFromMarkdown(options) {
1973
2192
  return __awaiter(this, void 0, void 0, function () {
1974
- var content, llmTools, _a, isVerbose, library, prepareKnowledgeFromMarkdownPromptbook, prepareKnowledgeFromMarkdownExecutor, prepareKeywordsPromptbook, prepareKeywordsExecutor, result, outputParameters, knowledgeRaw, knowledgeTextPieces, knowledge;
2193
+ var content, llmTools, _a, isVerbose, collection, prepareKnowledgeFromMarkdownPromptbook, prepareKnowledgeFromMarkdownExecutor, prepareKeywordsPromptbook, prepareKeywordsExecutor, result, outputParameters, knowledgeRaw, knowledgeTextPieces, knowledge;
1975
2194
  var _this = this;
1976
2195
  return __generator(this, function (_b) {
1977
2196
  switch (_b.label) {
1978
2197
  case 0:
1979
2198
  content = options.content, llmTools = options.llmTools, _a = options.isVerbose, isVerbose = _a === void 0 ? false : _a;
1980
- library = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
1981
- return [4 /*yield*/, library.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md')];
2199
+ collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
2200
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md')];
1982
2201
  case 1:
1983
2202
  prepareKnowledgeFromMarkdownPromptbook = _b.sent();
1984
- prepareKnowledgeFromMarkdownExecutor = createPromptbookExecutor({
1985
- promptbook: prepareKnowledgeFromMarkdownPromptbook,
2203
+ prepareKnowledgeFromMarkdownExecutor = createPipelineExecutor({
2204
+ pipeline: prepareKnowledgeFromMarkdownPromptbook,
1986
2205
  tools: {
1987
2206
  llm: llmTools,
1988
2207
  script: [
@@ -1990,11 +2209,11 @@
1990
2209
  ],
1991
2210
  },
1992
2211
  });
1993
- return [4 /*yield*/, library.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-keywords.ptbk.md')];
2212
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-keywords.ptbk.md')];
1994
2213
  case 2:
1995
2214
  prepareKeywordsPromptbook = _b.sent();
1996
- prepareKeywordsExecutor = createPromptbookExecutor({
1997
- promptbook: prepareKeywordsPromptbook,
2215
+ prepareKeywordsExecutor = createPipelineExecutor({
2216
+ pipeline: prepareKeywordsPromptbook,
1998
2217
  tools: {
1999
2218
  llm: llmTools,
2000
2219
  script: [
@@ -2688,28 +2907,31 @@
2688
2907
  .map(function (part) { return part.trim(); })
2689
2908
  .filter(function (item) { return item !== ''; })
2690
2909
  .filter(function (item) { return !/^PTBK$/i.test(item); })
2910
+ .filter(function (item) { return !/^PIPELINE$/i.test(item); })
2691
2911
  .filter(function (item) { return !/^PROMPTBOOK$/i.test(item); })
2692
2912
  .map(removeMarkdownFormatting);
2693
2913
  if (type.startsWith('URL') ||
2694
2914
  type.startsWith('PTBK_URL') ||
2695
2915
  type.startsWith('PTBKURL') ||
2916
+ type.startsWith('PIPELINE_URL') ||
2917
+ type.startsWith('PIPELINEURL') ||
2696
2918
  type.startsWith('PROMPTBOOK_URL') ||
2697
2919
  type.startsWith('PROMPTBOOKURL') ||
2698
2920
  type.startsWith('HTTPS')) {
2699
2921
  if (!(listItemParts.length === 2 || (listItemParts.length === 1 && type.startsWith('HTTPS')))) {
2700
- throw new SyntaxError(spaceTrim.spaceTrim("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n ")));
2922
+ throw new SyntaxError(spaceTrim.spaceTrim("\n Invalid PIPELINE_URL command:\n\n - ".concat(listItem, "\n ")));
2701
2923
  }
2702
- var promptbookUrlString = listItemParts.pop();
2703
- var promptbookUrl = new URL(promptbookUrlString);
2704
- if (promptbookUrl.protocol !== 'https:') {
2705
- throw new SyntaxError(spaceTrim.spaceTrim("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n\n Protocol must be HTTPS\n ")));
2924
+ var pipelineUrlString = listItemParts.pop();
2925
+ var pipelineUrl = new URL(pipelineUrlString);
2926
+ if (pipelineUrl.protocol !== 'https:') {
2927
+ throw new SyntaxError(spaceTrim.spaceTrim("\n Invalid PIPELINE_URL command:\n\n - ".concat(listItem, "\n\n Protocol must be HTTPS\n ")));
2706
2928
  }
2707
- if (promptbookUrl.hash !== '') {
2708
- throw new SyntaxError(spaceTrim.spaceTrim("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n\n URL must not contain hash\n Hash is used for identification of the prompt template in the pipeline\n ")));
2929
+ if (pipelineUrl.hash !== '') {
2930
+ throw new SyntaxError(spaceTrim.spaceTrim("\n Invalid PIPELINE_URL command:\n\n - ".concat(listItem, "\n\n URL must not contain hash\n Hash is used for identification of the prompt template in the pipeline\n ")));
2709
2931
  }
2710
2932
  return {
2711
- type: 'PROMPTBOOK_URL',
2712
- promptbookUrl: promptbookUrl,
2933
+ type: 'PIPELINE_URL',
2934
+ pipelineUrl: pipelineUrl,
2713
2935
  };
2714
2936
  }
2715
2937
  else if (type.startsWith('PROMPTBOOK_VERSION') || type.startsWith('PTBK_VERSION')) {
@@ -2901,7 +3123,7 @@
2901
3123
  */
2902
3124
  }
2903
3125
  else {
2904
- throw new SyntaxError(spaceTrim.spaceTrim("\n Unknown command:\n\n - ".concat(listItem, "\n\n Supported commands are:\n - PROMPTBOOK_URL <url>\n - PROMPTBOOK_VERSION <version>\n - EXECUTE PROMPT TEMPLATE\n - EXECUTE SIMPLE TEMPLATE\n - SIMPLE TEMPLATE\n - EXECUTE SCRIPT\n - EXECUTE PROMPT_DIALOG'\n - PROMPT_DIALOG'\n - MODEL NAME <name>\n - MODEL VARIANT <\"Chat\"|\"Completion\">\n - INPUT PARAM {<name>} <description>\n - OUTPUT PARAM {<name>} <description>\n - POSTPROCESS `{functionName}`\n - JOKER {<name>}\n - EXPECT JSON\n - EXPECT <\"Exactly\"|\"Min\"|\"Max\"> <number> <\"Chars\"|\"Words\"|\"Sentences\"|\"Paragraphs\"|\"Pages\">\n\n ")));
3126
+ throw new SyntaxError(spaceTrim.spaceTrim("\n Unknown command:\n\n - ".concat(listItem, "\n\n Supported commands are:\n - PIPELINE_URL <url>\n - PROMPTBOOK_VERSION <version>\n - EXECUTE PROMPT TEMPLATE\n - EXECUTE SIMPLE TEMPLATE\n - SIMPLE TEMPLATE\n - EXECUTE SCRIPT\n - EXECUTE PROMPT_DIALOG'\n - PROMPT_DIALOG'\n - MODEL NAME <name>\n - MODEL VARIANT <\"Chat\"|\"Completion\">\n - INPUT PARAM {<name>} <description>\n - OUTPUT PARAM {<name>} <description>\n - POSTPROCESS `{functionName}`\n - JOKER {<name>}\n - EXPECT JSON\n - EXPECT <\"Exactly\"|\"Min\"|\"Max\"> <number> <\"Chars\"|\"Words\"|\"Sentences\"|\"Paragraphs\"|\"Pages\">\n\n ")));
2905
3127
  }
2906
3128
  }
2907
3129
 
@@ -2950,7 +3172,7 @@
2950
3172
  var pipelineJson = {
2951
3173
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2952
3174
  title: undefined /* <- Note: Putting here placeholder to keep `title` on top at final JSON */,
2953
- promptbookUrl: undefined /* <- Note: Putting here placeholder to keep `promptbookUrl` on top at final JSON */,
3175
+ pipelineUrl: undefined /* <- Note: Putting here placeholder to keep `pipelineUrl` on top at final JSON */,
2954
3176
  promptbookVersion: PROMPTBOOK_VERSION,
2955
3177
  description: undefined /* <- Note: Putting here placeholder to keep `description` on top at final JSON */,
2956
3178
  parameters: [],
@@ -3013,8 +3235,8 @@
3013
3235
  var listItem = listItems_1_1.value;
3014
3236
  var command = parseCommand(listItem);
3015
3237
  switch (command.type) {
3016
- case 'PROMPTBOOK_URL':
3017
- pipelineJson.promptbookUrl = command.promptbookUrl.href;
3238
+ case 'PIPELINE_URL':
3239
+ pipelineJson.pipelineUrl = command.pipelineUrl.href;
3018
3240
  break;
3019
3241
  case 'PROMPTBOOK_VERSION':
3020
3242
  pipelineJson.promptbookVersion = command.promptbookVersion;
@@ -3369,7 +3591,7 @@
3369
3591
  return promptbookMermaid;
3370
3592
  }
3371
3593
  /**
3372
- * TODO: Maybe use some Mermaid library instead of string templating
3594
+ * TODO: Maybe use some Mermaid package instead of string templating
3373
3595
  * TODO: [🕌] When more than 2 functionalities, split into separate functions
3374
3596
  */
3375
3597
 
@@ -3408,12 +3630,12 @@
3408
3630
  });
3409
3631
  }
3410
3632
  /**
3411
- * TODO: Maybe use some Mermaid library instead of string templating
3633
+ * TODO: Maybe use some Mermaid package instead of string templating
3412
3634
  * TODO: [🕌] When more than 2 functionalities, split into separate functions
3413
3635
  */
3414
3636
 
3415
3637
  /**
3416
- * This error indicates that the promptbook library cannot be propperly loaded
3638
+ * This error indicates that the pipeline collection cannot be propperly loaded
3417
3639
  */
3418
3640
  var CollectionError = /** @class */ (function (_super) {
3419
3641
  __extends(CollectionError, _super);
@@ -3514,225 +3736,6 @@
3514
3736
  return SimplePromptInterfaceTools;
3515
3737
  }());
3516
3738
 
3517
- /**
3518
- * Constructs Promptbook from async sources
3519
- * It can be one of the following:
3520
- * - Promise of array of PipelineJson or PipelineString
3521
- * - Factory function that returns Promise of array of PipelineJson or PipelineString
3522
- *
3523
- * Note: This is useful as internal tool for other constructor functions like
3524
- * `createCollectionFromUrl` or `createCollectionFromDirectory`
3525
- * Consider using those functions instead of this one
3526
- *
3527
- * Note: The function does NOT return promise it returns the library directly which waits for the sources to be resolved
3528
- * when error occurs in given promise or factory function, it is thrown during `listPipelines` or `getPipelineByUrl` call
3529
- *
3530
- * Note: Consider using `createCollectionFromDirectory` or `createCollectionFromUrl`
3531
- *
3532
- * @param promptbookSourcesPromiseOrFactory
3533
- * @returns PipelineCollection
3534
- * @deprecated Do not use, it will became internal tool for other constructor functions
3535
- */
3536
- function createCollectionFromPromise(promptbookSourcesPromiseOrFactory) {
3537
- var library;
3538
- function forSources() {
3539
- return __awaiter(this, void 0, void 0, function () {
3540
- var promptbookSources;
3541
- return __generator(this, function (_a) {
3542
- switch (_a.label) {
3543
- case 0:
3544
- if (typeof promptbookSourcesPromiseOrFactory === 'function') {
3545
- // Note: Calling factory function only once despite multiple calls to resolveSources
3546
- promptbookSourcesPromiseOrFactory = promptbookSourcesPromiseOrFactory();
3547
- }
3548
- return [4 /*yield*/, promptbookSourcesPromiseOrFactory];
3549
- case 1:
3550
- promptbookSources = _a.sent();
3551
- library = createCollectionFromJson.apply(void 0, __spreadArray([], __read(promptbookSources), false));
3552
- return [2 /*return*/];
3553
- }
3554
- });
3555
- });
3556
- }
3557
- function listPipelines() {
3558
- return __awaiter(this, void 0, void 0, function () {
3559
- return __generator(this, function (_a) {
3560
- switch (_a.label) {
3561
- case 0: return [4 /*yield*/, forSources()];
3562
- case 1:
3563
- _a.sent();
3564
- return [2 /*return*/, /* not await */ library.listPipelines()];
3565
- }
3566
- });
3567
- });
3568
- }
3569
- function getPipelineByUrl(url) {
3570
- return __awaiter(this, void 0, void 0, function () {
3571
- return __generator(this, function (_a) {
3572
- switch (_a.label) {
3573
- case 0: return [4 /*yield*/, forSources()];
3574
- case 1:
3575
- _a.sent();
3576
- return [2 /*return*/, /* not await */ library.getPipelineByUrl(url)];
3577
- }
3578
- });
3579
- });
3580
- }
3581
- function isResponsibleForPrompt(prompt) {
3582
- return __awaiter(this, void 0, void 0, function () {
3583
- return __generator(this, function (_a) {
3584
- switch (_a.label) {
3585
- case 0: return [4 /*yield*/, forSources()];
3586
- case 1:
3587
- _a.sent();
3588
- return [2 /*return*/, /* not await */ library.isResponsibleForPrompt(prompt)];
3589
- }
3590
- });
3591
- });
3592
- }
3593
- return {
3594
- listPipelines: listPipelines,
3595
- getPipelineByUrl: getPipelineByUrl,
3596
- isResponsibleForPrompt: isResponsibleForPrompt,
3597
- };
3598
- }
3599
-
3600
- /**
3601
- * Constructs Promptbook from remote Promptbase URL
3602
-
3603
- * @returns PipelineCollection
3604
- */
3605
- function createCollectionFromUrl(url, options) {
3606
- return __awaiter(this, void 0, void 0, function () {
3607
- var _a, _b, isVerbose, _c, isLazyLoaded, library;
3608
- var _this = this;
3609
- return __generator(this, function (_d) {
3610
- switch (_d.label) {
3611
- case 0:
3612
- _a = options || {}, _b = _a.isVerbose, isVerbose = _b === void 0 ? false : _b, _c = _a.isLazyLoaded, isLazyLoaded = _c === void 0 ? false : _c;
3613
- library = createCollectionFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
3614
- return __generator(this, function (_a) {
3615
- if (isVerbose) {
3616
- console.info("Creating promptbook library from url ".concat(url.toString()));
3617
- }
3618
- throw new Error('Not implemented yet');
3619
- });
3620
- }); });
3621
- if (!(isLazyLoaded === false)) return [3 /*break*/, 2];
3622
- return [4 /*yield*/, library.listPipelines()];
3623
- case 1:
3624
- _d.sent();
3625
- _d.label = 2;
3626
- case 2: return [2 /*return*/, library];
3627
- }
3628
- });
3629
- });
3630
- }
3631
- /**
3632
- * TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
3633
- */
3634
-
3635
- /**
3636
- * Creates PipelineCollection as a subset of another PipelineCollection
3637
- *
3638
- * Note: You can use any type of library as a parent library - local, remote, etc.
3639
- * Note: This is just a thin wrapper / proxy around the parent library
3640
- *
3641
- * @param promptbookSources
3642
- * @returns PipelineCollection
3643
- */
3644
- function createSubcollection(library, predicate) {
3645
- function listPipelines() {
3646
- return __awaiter(this, void 0, void 0, function () {
3647
- var promptbooks;
3648
- return __generator(this, function (_a) {
3649
- switch (_a.label) {
3650
- case 0: return [4 /*yield*/, library.listPipelines()];
3651
- case 1:
3652
- promptbooks = _a.sent();
3653
- promptbooks = promptbooks.filter(predicate);
3654
- return [2 /*return*/, promptbooks];
3655
- }
3656
- });
3657
- });
3658
- }
3659
- function getPipelineByUrl(url) {
3660
- return __awaiter(this, void 0, void 0, function () {
3661
- var _a, promptbook;
3662
- var _this = this;
3663
- return __generator(this, function (_b) {
3664
- switch (_b.label) {
3665
- case 0:
3666
- if (!!predicate(url)) return [3 /*break*/, 2];
3667
- _a = NotFoundError.bind;
3668
- return [4 /*yield*/, spaceTrim.spaceTrim(function (block) { return __awaiter(_this, void 0, void 0, function () {
3669
- var _a, _b, _c, _d, _e, _f;
3670
- return __generator(this, function (_g) {
3671
- switch (_g.label) {
3672
- case 0:
3673
- _c = (_b = "\n Promptbook with url \"".concat(url, "\" not found or not accessible\n\n Available promptbooks:\n ")).concat;
3674
- _d = block;
3675
- return [4 /*yield*/, listPipelines()];
3676
- case 1:
3677
- _e = (_a = _c.apply(_b, [_d.apply(void 0, [(_g.sent()).map(function (promptbookUrl) { return "- ".concat(promptbookUrl); }).join('\n')]), "\n\n All available promptbooks in parent library:\n "])).concat;
3678
- _f = block;
3679
- return [4 /*yield*/, library.listPipelines()];
3680
- case 2: return [2 /*return*/, _e.apply(_a, [_f.apply(void 0, [(_g.sent()).map(function (promptbookUrl) { return "- ".concat(promptbookUrl); }).join('\n')]), "\n\n "])];
3681
- }
3682
- });
3683
- }); })];
3684
- case 1: throw new (_a.apply(NotFoundError, [void 0, _b.sent()]))();
3685
- case 2: return [4 /*yield*/, library.getPipelineByUrl(url)];
3686
- case 3:
3687
- promptbook = _b.sent();
3688
- return [2 /*return*/, promptbook];
3689
- }
3690
- });
3691
- });
3692
- }
3693
- function isResponsibleForPrompt(prompt) {
3694
- return __awaiter(this, void 0, void 0, function () {
3695
- var isResponsible;
3696
- return __generator(this, function (_a) {
3697
- switch (_a.label) {
3698
- case 0: return [4 /*yield*/, library.isResponsibleForPrompt(prompt)];
3699
- case 1:
3700
- isResponsible = _a.sent();
3701
- // TODO: !! Only if responsible, check if predicate is true
3702
- return [2 /*return*/, isResponsible];
3703
- }
3704
- });
3705
- });
3706
- }
3707
- return {
3708
- listPipelines: listPipelines,
3709
- getPipelineByUrl: getPipelineByUrl,
3710
- isResponsibleForPrompt: isResponsibleForPrompt,
3711
- };
3712
- }
3713
-
3714
- /**
3715
- * Converts PipelineCollection to serialized JSON
3716
- *
3717
- * Note: Functions `libraryToJson` and `createCollectionFromJson` are complementary
3718
- */
3719
- function libraryToJson(library) {
3720
- return __awaiter(this, void 0, void 0, function () {
3721
- var promptbookUrls, promptbooks;
3722
- return __generator(this, function (_a) {
3723
- switch (_a.label) {
3724
- case 0: return [4 /*yield*/, library.listPipelines()];
3725
- case 1:
3726
- promptbookUrls = _a.sent();
3727
- return [4 /*yield*/, Promise.all(promptbookUrls.map(function (url) { return library.getPipelineByUrl(url); }))];
3728
- case 2:
3729
- promptbooks = _a.sent();
3730
- return [2 /*return*/, promptbooks];
3731
- }
3732
- });
3733
- });
3734
- }
3735
-
3736
3739
  /**
3737
3740
  * Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
3738
3741
  *
@@ -3965,7 +3968,7 @@
3965
3968
  }
3966
3969
 
3967
3970
  /**
3968
- * The thresholds for the relative time in the `moment` library.
3971
+ * The thresholds for the relative time in the `moment` NPM package.
3969
3972
  *
3970
3973
  * @see https://momentjscom.readthedocs.io/en/latest/moment/07-customization/13-relative-time-threshold/
3971
3974
  */
@@ -4015,8 +4018,8 @@
4015
4018
  var _h = __assign(__assign({}, ExecutionReportStringOptionsDefaults), (options || {})), taxRate = _h.taxRate, chartsWidth = _h.chartsWidth;
4016
4019
  var executionReportString = spaceTrim.spaceTrim(function (block) { return "\n # ".concat(executionReportJson.title || 'Execution report', "\n\n ").concat(block(executionReportJson.description || ''), "\n "); });
4017
4020
  var headerList = [];
4018
- if (executionReportJson.promptbookUrl) {
4019
- headerList.push("PROMPTBOOK URL ".concat(executionReportJson.promptbookUrl));
4021
+ if (executionReportJson.pipelineUrl) {
4022
+ headerList.push("PIPELINE URL ".concat(executionReportJson.pipelineUrl));
4020
4023
  }
4021
4024
  headerList.push("PROMPTBOOK VERSION ".concat(executionReportJson.promptbookUsedVersion) +
4022
4025
  (!executionReportJson.promptbookRequestedVersion
@@ -4185,15 +4188,15 @@
4185
4188
  exports.addUsage = addUsage;
4186
4189
  exports.assertsExecutionSuccessful = assertsExecutionSuccessful;
4187
4190
  exports.checkExpectations = checkExpectations;
4191
+ exports.collectionToJson = collectionToJson;
4188
4192
  exports.createCollectionFromJson = createCollectionFromJson;
4189
4193
  exports.createCollectionFromPromise = createCollectionFromPromise;
4190
4194
  exports.createCollectionFromUrl = createCollectionFromUrl;
4191
- exports.createPromptbookExecutor = createPromptbookExecutor;
4195
+ exports.createPipelineExecutor = createPipelineExecutor;
4192
4196
  exports.createSublibrary = createSubcollection;
4193
4197
  exports.embeddingVectorToString = embeddingVectorToString;
4194
4198
  exports.executionReportJsonToString = executionReportJsonToString;
4195
4199
  exports.isPassingExpectations = isPassingExpectations;
4196
- exports.libraryToJson = libraryToJson;
4197
4200
  exports.pipelineJsonToString = pipelineJsonToString;
4198
4201
  exports.pipelineStringToJson = pipelineStringToJson;
4199
4202
  exports.pipelineStringToJsonSync = pipelineStringToJsonSync;