@promptbook/node 0.60.0-4 → 0.60.0-6

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 +505 -502
  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 +2 -2
  42. package/umd/index.umd.js +471 -468
  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
@@ -134,49 +134,249 @@
134
134
  */
135
135
  var LOOP_LIMIT = 1000;
136
136
  /**
137
- * The name of the builded promptbook library made by CLI `promptbook make` and for lookup in `createCollectionFromDirectory`
137
+ * The name of the builded pipeline collection made by CLI `promptbook make` and for lookup in `createCollectionFromDirectory`
138
138
  */
139
- var PROMPTBOOK_MAKED_BASE_FILENAME = "index";
139
+ var PIPELINE_COLLECTION_BASE_FILENAME = "index";
140
140
 
141
- 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:[]}];
141
+ var PipelineCollection = [{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-keywords.ptbk.md",promptbookVersion:"0.60.0-5",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-5",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:[]}];
142
142
 
143
143
  /**
144
- * This error indicates errors during the execution of the promptbook
144
+ * Prettify the html code
145
+ *
146
+ * @param content raw html code
147
+ * @returns formatted html code
145
148
  */
146
- var ExecutionError = /** @class */ (function (_super) {
147
- __extends(ExecutionError, _super);
148
- function ExecutionError(message) {
149
- var _this = _super.call(this, message) || this;
150
- _this.name = 'ExecutionError';
151
- Object.setPrototypeOf(_this, ExecutionError.prototype);
152
- return _this;
149
+ function prettifyMarkdown(content) {
150
+ try {
151
+ return prettier.format(content, {
152
+ parser: 'markdown',
153
+ plugins: [parserHtml__default["default"]],
154
+ // TODO: DRY - make some import or auto-copy of .prettierrc
155
+ endOfLine: 'lf',
156
+ tabWidth: 4,
157
+ singleQuote: true,
158
+ trailingComma: 'all',
159
+ arrowParens: 'always',
160
+ printWidth: 120,
161
+ htmlWhitespaceSensitivity: 'ignore',
162
+ jsxBracketSameLine: false,
163
+ bracketSpacing: true,
164
+ });
153
165
  }
154
- return ExecutionError;
155
- }(Error));
166
+ catch (error) {
167
+ console.error('There was an error with prettifying the markdown, using the original as the fallback', {
168
+ error: error,
169
+ html: content,
170
+ });
171
+ return content;
172
+ }
173
+ }
156
174
 
157
175
  /**
158
- * Asserts that the execution of a promptnook is successful
176
+ * Makes first letter of a string uppercase
159
177
  *
160
- * @param executionResult - The partial result of the promptnook execution
161
- * @throws {ExecutionError} If the execution is not successful or if multiple errors occurred
162
178
  */
163
- function assertsExecutionSuccessful(executionResult) {
164
- var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors;
165
- if (isSuccessful === true) {
166
- return;
179
+ function capitalize(word) {
180
+ return word.substring(0, 1).toUpperCase() + word.substring(1);
181
+ }
182
+
183
+ /**
184
+ * Converts promptbook in JSON format to string format
185
+ *
186
+ * @param pipelineJson Promptbook in JSON format (.ptbk.json)
187
+ * @returns Promptbook in string format (.ptbk.md)
188
+ */
189
+ function pipelineJsonToString(pipelineJson) {
190
+ var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
191
+ var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, promptbookVersion = pipelineJson.promptbookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, promptTemplates = pipelineJson.promptTemplates;
192
+ var pipelineString = "# ".concat(title);
193
+ if (description) {
194
+ pipelineString += '\n\n';
195
+ pipelineString += description;
167
196
  }
168
- if (errors.length === 0) {
169
- throw new ExecutionError("Promptnook Execution failed because of unknown reason");
197
+ // TODO:> const commands: Array<Command>
198
+ var commands = [];
199
+ if (pipelineUrl) {
200
+ commands.push("PIPELINE URL ".concat(pipelineUrl));
170
201
  }
171
- else if (errors.length === 1) {
172
- throw errors[0];
202
+ commands.push("PROMPTBOOK VERSION ".concat(promptbookVersion));
203
+ pipelineString = prettifyMarkdown(pipelineString);
204
+ try {
205
+ for (var _g = __values(parameters.filter(function (_a) {
206
+ var isInput = _a.isInput;
207
+ return isInput;
208
+ })), _h = _g.next(); !_h.done; _h = _g.next()) {
209
+ var parameter = _h.value;
210
+ commands.push("INPUT PARAMETER ".concat(promptTemplateParameterJsonToString(parameter)));
211
+ }
173
212
  }
174
- else {
175
- 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 "); }));
213
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
214
+ finally {
215
+ try {
216
+ if (_h && !_h.done && (_a = _g.return)) _a.call(_g);
217
+ }
218
+ finally { if (e_1) throw e_1.error; }
219
+ }
220
+ try {
221
+ for (var _j = __values(parameters.filter(function (_a) {
222
+ var isOutput = _a.isOutput;
223
+ return isOutput;
224
+ })), _k = _j.next(); !_k.done; _k = _j.next()) {
225
+ var parameter = _k.value;
226
+ commands.push("OUTPUT PARAMETER ".concat(promptTemplateParameterJsonToString(parameter)));
227
+ }
228
+ }
229
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
230
+ finally {
231
+ try {
232
+ if (_k && !_k.done && (_b = _j.return)) _b.call(_j);
233
+ }
234
+ finally { if (e_2) throw e_2.error; }
235
+ }
236
+ pipelineString += '\n\n';
237
+ pipelineString += commands.map(function (command) { return "- ".concat(command); }).join('\n');
238
+ try {
239
+ for (var promptTemplates_1 = __values(promptTemplates), promptTemplates_1_1 = promptTemplates_1.next(); !promptTemplates_1_1.done; promptTemplates_1_1 = promptTemplates_1.next()) {
240
+ var promptTemplate = promptTemplates_1_1.value;
241
+ var
242
+ /* Note: Not using:> name, */
243
+ title_1 = promptTemplate.title, description_1 = promptTemplate.description,
244
+ /* Note: dependentParameterNames, */
245
+ jokers = promptTemplate.jokers, executionType = promptTemplate.executionType, content = promptTemplate.content, postprocessing = promptTemplate.postprocessing, expectations = promptTemplate.expectations, expectFormat = promptTemplate.expectFormat, resultingParameterName = promptTemplate.resultingParameterName;
246
+ pipelineString += '\n\n';
247
+ pipelineString += "## ".concat(title_1);
248
+ if (description_1) {
249
+ pipelineString += '\n\n';
250
+ pipelineString += description_1;
251
+ }
252
+ // TODO:> const commands: Array<Command>
253
+ var commands_1 = [];
254
+ var contentLanguage = 'text';
255
+ if (executionType === 'PROMPT_TEMPLATE') {
256
+ var modelRequirements = promptTemplate.modelRequirements;
257
+ var modelName = modelRequirements.modelName, modelVariant = modelRequirements.modelVariant;
258
+ commands_1.push("EXECUTE PROMPT TEMPLATE");
259
+ if (modelVariant) {
260
+ commands_1.push("MODEL VARIANT ".concat(capitalize(modelVariant)));
261
+ }
262
+ if (modelName) {
263
+ commands_1.push("MODEL NAME `".concat(modelName, "`"));
264
+ }
265
+ }
266
+ else if (executionType === 'SIMPLE_TEMPLATE') {
267
+ commands_1.push("SIMPLE TEMPLATE");
268
+ // Note: Nothing special here
269
+ }
270
+ else if (executionType === 'SCRIPT') {
271
+ commands_1.push("EXECUTE SCRIPT");
272
+ if (promptTemplate.contentLanguage) {
273
+ contentLanguage = promptTemplate.contentLanguage;
274
+ }
275
+ else {
276
+ contentLanguage = '';
277
+ }
278
+ }
279
+ else if (executionType === 'PROMPT_DIALOG') {
280
+ commands_1.push("PROMPT DIALOG");
281
+ // Note: Nothing special here
282
+ }
283
+ if (jokers) {
284
+ try {
285
+ for (var jokers_1 = (e_4 = void 0, __values(jokers)), jokers_1_1 = jokers_1.next(); !jokers_1_1.done; jokers_1_1 = jokers_1.next()) {
286
+ var joker = jokers_1_1.value;
287
+ commands_1.push("JOKER {".concat(joker, "}"));
288
+ }
289
+ }
290
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
291
+ finally {
292
+ try {
293
+ if (jokers_1_1 && !jokers_1_1.done && (_d = jokers_1.return)) _d.call(jokers_1);
294
+ }
295
+ finally { if (e_4) throw e_4.error; }
296
+ }
297
+ } /* not else */
298
+ if (postprocessing) {
299
+ try {
300
+ for (var postprocessing_1 = (e_5 = void 0, __values(postprocessing)), postprocessing_1_1 = postprocessing_1.next(); !postprocessing_1_1.done; postprocessing_1_1 = postprocessing_1.next()) {
301
+ var postprocessingFunctionName = postprocessing_1_1.value;
302
+ commands_1.push("POSTPROCESSING `".concat(postprocessingFunctionName, "`"));
303
+ }
304
+ }
305
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
306
+ finally {
307
+ try {
308
+ if (postprocessing_1_1 && !postprocessing_1_1.done && (_e = postprocessing_1.return)) _e.call(postprocessing_1);
309
+ }
310
+ finally { if (e_5) throw e_5.error; }
311
+ }
312
+ } /* not else */
313
+ if (expectations) {
314
+ try {
315
+ for (var _l = (e_6 = void 0, __values(Object.entries(expectations))), _m = _l.next(); !_m.done; _m = _l.next()) {
316
+ var _o = __read(_m.value, 2), unit = _o[0], _p = _o[1], min = _p.min, max = _p.max;
317
+ if (min === max) {
318
+ commands_1.push("EXPECT EXACTLY ".concat(min, " ").concat(capitalize(unit + (min > 1 ? 's' : ''))));
319
+ }
320
+ else {
321
+ if (min !== undefined) {
322
+ commands_1.push("EXPECT MIN ".concat(min, " ").concat(capitalize(unit + (min > 1 ? 's' : ''))));
323
+ } /* not else */
324
+ if (max !== undefined) {
325
+ commands_1.push("EXPECT MAX ".concat(max, " ").concat(capitalize(unit + (max > 1 ? 's' : ''))));
326
+ }
327
+ }
328
+ }
329
+ }
330
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
331
+ finally {
332
+ try {
333
+ if (_m && !_m.done && (_f = _l.return)) _f.call(_l);
334
+ }
335
+ finally { if (e_6) throw e_6.error; }
336
+ }
337
+ } /* not else */
338
+ if (expectFormat) {
339
+ if (expectFormat === 'JSON') {
340
+ // TODO: @deprecated remove
341
+ commands_1.push("EXPECT JSON");
342
+ }
343
+ } /* not else */
344
+ pipelineString += '\n\n';
345
+ pipelineString += commands_1.map(function (command) { return "- ".concat(command); }).join('\n');
346
+ pipelineString += '\n\n';
347
+ pipelineString += '```' + contentLanguage;
348
+ pipelineString += '\n';
349
+ pipelineString += spaceTrim__default["default"](content);
350
+ // <- TODO: !!! Escape
351
+ // <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
352
+ pipelineString += '\n';
353
+ pipelineString += '```';
354
+ pipelineString += '\n\n';
355
+ pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: !!! If the parameter here has description, add it and use promptTemplateParameterJsonToString
356
+ }
357
+ }
358
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
359
+ finally {
360
+ try {
361
+ if (promptTemplates_1_1 && !promptTemplates_1_1.done && (_c = promptTemplates_1.return)) _c.call(promptTemplates_1);
362
+ }
363
+ finally { if (e_3) throw e_3.error; }
176
364
  }
365
+ return pipelineString;
177
366
  }
178
367
  /**
179
- * TODO: [🧠] Can this return type be better typed than void
368
+ * @private internal util of pipelineJsonToString
369
+ */
370
+ function promptTemplateParameterJsonToString(promptTemplateParameterJson) {
371
+ var name = promptTemplateParameterJson.name, description = promptTemplateParameterJson.description;
372
+ var parameterString = "{".concat(name, "}");
373
+ if (description) {
374
+ parameterString = "".concat(parameterString, " ").concat(description);
375
+ }
376
+ return parameterString;
377
+ }
378
+ /**
379
+ * TODO: Escape all
180
380
  */
181
381
 
182
382
  /**
@@ -213,7 +413,7 @@
213
413
  var UnexpectedError = /** @class */ (function (_super) {
214
414
  __extends(UnexpectedError, _super);
215
415
  function UnexpectedError(message) {
216
- 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;
416
+ 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;
217
417
  _this.name = 'UnexpectedError';
218
418
  Object.setPrototypeOf(_this, UnexpectedError.prototype);
219
419
  return _this;
@@ -263,10 +463,10 @@
263
463
  function validatePipeline(pipeline) {
264
464
  // TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
265
465
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
266
- if (pipeline.promptbookUrl !== undefined) {
267
- if (!isValidUrl(pipeline.promptbookUrl)) {
466
+ if (pipeline.pipelineUrl !== undefined) {
467
+ if (!isValidUrl(pipeline.pipelineUrl)) {
268
468
  // TODO: This should be maybe the syntax error detected during parsing
269
- throw new PipelineLogicError("Invalid promptbook URL \"".concat(pipeline.promptbookUrl, "\""));
469
+ throw new PipelineLogicError("Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\""));
270
470
  }
271
471
  }
272
472
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
@@ -433,17 +633,181 @@
433
633
  */
434
634
 
435
635
  /**
436
- * This error occurs when some expectation is not met in the execution of the pipeline
437
- *
438
- * @private Always catched and rethrown as `ExecutionError`
439
- * Note: This is a kindof subtype of ExecutionError
636
+ * This error indicates that promptbook not found in the collection
440
637
  */
441
- var ExpectError = /** @class */ (function (_super) {
442
- __extends(ExpectError, _super);
443
- function ExpectError(message) {
638
+ var NotFoundError = /** @class */ (function (_super) {
639
+ __extends(NotFoundError, _super);
640
+ function NotFoundError(message) {
444
641
  var _this = _super.call(this, message) || this;
445
- _this.name = 'ExpectError';
446
- Object.setPrototypeOf(_this, ExpectError.prototype);
642
+ _this.name = 'NotFoundError';
643
+ Object.setPrototypeOf(_this, NotFoundError.prototype);
644
+ return _this;
645
+ }
646
+ return NotFoundError;
647
+ }(Error));
648
+
649
+ /**
650
+ * This error indicates errors in referencing promptbooks between each other
651
+ */
652
+ var ReferenceError$1 = /** @class */ (function (_super) {
653
+ __extends(ReferenceError, _super);
654
+ function ReferenceError(message) {
655
+ var _this = _super.call(this, message) || this;
656
+ _this.name = 'ReferenceError';
657
+ Object.setPrototypeOf(_this, ReferenceError.prototype);
658
+ return _this;
659
+ }
660
+ return ReferenceError;
661
+ }(Error));
662
+
663
+ /**
664
+ * Library of promptbooks that groups together promptbooks for an application.
665
+ * This implementation is a very thin wrapper around the Array / Map of promptbooks.
666
+ *
667
+ * @private use `createCollectionFromJson` instead
668
+ * @see https://github.com/webgptorg/promptbook#promptbook-collection
669
+ */
670
+ var SimplePipelineCollection = /** @class */ (function () {
671
+ /**
672
+ * Constructs a pipeline collection from promptbooks
673
+ *
674
+ * @param promptbooks !!!
675
+ *
676
+ * @private Use instead `createCollectionFromJson`
677
+ * Note: During the construction logic of all promptbooks are validated
678
+ * Note: It is not recommended to use this constructor directly, use `createCollectionFromJson` *(or other variant)* instead
679
+ */
680
+ function SimplePipelineCollection() {
681
+ var e_1, _a;
682
+ var promptbooks = [];
683
+ for (var _i = 0; _i < arguments.length; _i++) {
684
+ promptbooks[_i] = arguments[_i];
685
+ }
686
+ this.collection = new Map();
687
+ try {
688
+ for (var promptbooks_1 = __values(promptbooks), promptbooks_1_1 = promptbooks_1.next(); !promptbooks_1_1.done; promptbooks_1_1 = promptbooks_1.next()) {
689
+ var promptbook = promptbooks_1_1.value;
690
+ if (promptbook.pipelineUrl === undefined) {
691
+ 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 ")));
692
+ }
693
+ validatePipeline(promptbook);
694
+ // Note: [🦄]
695
+ if (this.collection.has(promptbook.pipelineUrl) &&
696
+ pipelineJsonToString(promptbook) !== pipelineJsonToString(this.collection.get(promptbook.pipelineUrl))) {
697
+ 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 ")));
698
+ }
699
+ this.collection.set(promptbook.pipelineUrl, promptbook);
700
+ }
701
+ }
702
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
703
+ finally {
704
+ try {
705
+ if (promptbooks_1_1 && !promptbooks_1_1.done && (_a = promptbooks_1.return)) _a.call(promptbooks_1);
706
+ }
707
+ finally { if (e_1) throw e_1.error; }
708
+ }
709
+ }
710
+ /**
711
+ * Gets all promptbooks in the collection
712
+ */
713
+ SimplePipelineCollection.prototype.listPipelines = function () {
714
+ return Array.from(this.collection.keys());
715
+ };
716
+ /**
717
+ * Gets promptbook by its URL
718
+ *
719
+ * Note: This is not a direct fetching from the URL, but a lookup in the collection
720
+ */
721
+ SimplePipelineCollection.prototype.getPipelineByUrl = function (url) {
722
+ var _this = this;
723
+ var promptbook = this.collection.get(url);
724
+ if (!promptbook) {
725
+ if (this.listPipelines().length === 0) {
726
+ throw new NotFoundError(spaceTrim.spaceTrim("\n Promptbook with url \"".concat(url, "\" not found\n\n No promptbooks available\n ")));
727
+ }
728
+ 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()
729
+ .map(function (pipelineUrl) { return "- ".concat(pipelineUrl); })
730
+ .join('\n')), "\n\n "); }));
731
+ }
732
+ return promptbook;
733
+ };
734
+ /**
735
+ * Checks whether given prompt was defined in any promptbook in the collection
736
+ */
737
+ SimplePipelineCollection.prototype.isResponsibleForPrompt = function (prompt) {
738
+ return true;
739
+ };
740
+ return SimplePipelineCollection;
741
+ }());
742
+
743
+ /**
744
+ * Creates PipelineCollection from array of PipelineJson or PipelineString
745
+ *
746
+ * Note: Functions `collectionToJson` and `createCollectionFromJson` are complementary
747
+ * Note: During the construction syntax and logic of all sources are validated
748
+ *
749
+ * @param promptbookSources
750
+ * @returns PipelineCollection
751
+ */
752
+ function createCollectionFromJson() {
753
+ var promptbooks = [];
754
+ for (var _i = 0; _i < arguments.length; _i++) {
755
+ promptbooks[_i] = arguments[_i];
756
+ }
757
+ return new (SimplePipelineCollection.bind.apply(SimplePipelineCollection, __spreadArray([void 0], __read(promptbooks), false)))();
758
+ }
759
+
760
+ /**
761
+ * This error indicates errors during the execution of the pipeline
762
+ */
763
+ var ExecutionError = /** @class */ (function (_super) {
764
+ __extends(ExecutionError, _super);
765
+ function ExecutionError(message) {
766
+ var _this = _super.call(this, message) || this;
767
+ _this.name = 'ExecutionError';
768
+ Object.setPrototypeOf(_this, ExecutionError.prototype);
769
+ return _this;
770
+ }
771
+ return ExecutionError;
772
+ }(Error));
773
+
774
+ /**
775
+ * Asserts that the execution of a promptnook is successful
776
+ *
777
+ * @param executionResult - The partial result of the promptnook execution
778
+ * @throws {ExecutionError} If the execution is not successful or if multiple errors occurred
779
+ */
780
+ function assertsExecutionSuccessful(executionResult) {
781
+ var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors;
782
+ if (isSuccessful === true) {
783
+ return;
784
+ }
785
+ if (errors.length === 0) {
786
+ throw new ExecutionError("Promptnook Execution failed because of unknown reason");
787
+ }
788
+ else if (errors.length === 1) {
789
+ throw errors[0];
790
+ }
791
+ else {
792
+ 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 "); }));
793
+ }
794
+ }
795
+ /**
796
+ * TODO: [🧠] Can this return type be better typed than void
797
+ */
798
+
799
+ /**
800
+ * This error occurs when some expectation is not met in the execution of the pipeline
801
+ *
802
+ * @private Always catched and rethrown as `ExecutionError`
803
+ * Note: This is a kindof subtype of ExecutionError
804
+ */
805
+ var ExpectError = /** @class */ (function (_super) {
806
+ __extends(ExpectError, _super);
807
+ function ExpectError(message) {
808
+ var _this = _super.call(this, message) || this;
809
+ _this.name = 'ExpectError';
810
+ Object.setPrototypeOf(_this, ExpectError.prototype);
447
811
  return _this;
448
812
  }
449
813
  return ExpectError;
@@ -471,7 +835,7 @@
471
835
  /**
472
836
  * The version of the Promptbook library
473
837
  */
474
- var PROMPTBOOK_VERSION = '0.60.0-3';
838
+ var PROMPTBOOK_VERSION = '0.60.0-5';
475
839
 
476
840
  /**
477
841
  * Function `addUsage` will add multiple usages into one
@@ -950,7 +1314,7 @@
950
1314
  * @returns the template with replaced parameters
951
1315
  * @throws {TemplateError} if parameter is not defined, not closed, or not opened
952
1316
  *
953
- * @private within the createPromptbookExecutor
1317
+ * @private within the createPipelineExecutor
954
1318
  */
955
1319
  function replaceParameters(template, parameters) {
956
1320
  var replacedTemplate = template;
@@ -1003,17 +1367,17 @@
1003
1367
  }
1004
1368
 
1005
1369
  /**
1006
- * Creates executor function from promptbook and execution tools.
1370
+ * Creates executor function from pipeline and execution tools.
1007
1371
  *
1008
1372
  * @returns The executor function
1009
- * @throws {PipelineLogicError} on logical error in the promptbook
1373
+ * @throws {PipelineLogicError} on logical error in the pipeline
1010
1374
  */
1011
- function createPromptbookExecutor(options) {
1375
+ function createPipelineExecutor(options) {
1012
1376
  var _this = this;
1013
- var promptbook = options.promptbook, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
1377
+ var pipeline = options.pipeline, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
1014
1378
  var _b = settings.maxExecutionAttempts, maxExecutionAttempts = _b === void 0 ? 3 : _b;
1015
- validatePipeline(promptbook);
1016
- var promptbookExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
1379
+ validatePipeline(pipeline);
1380
+ var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
1017
1381
  function executeSingleTemplate(currentTemplate) {
1018
1382
  return __awaiter(this, void 0, void 0, function () {
1019
1383
  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;
@@ -1022,9 +1386,9 @@
1022
1386
  return __generator(this, function (_o) {
1023
1387
  switch (_o.label) {
1024
1388
  case 0:
1025
- name = "promptbook-executor-frame-".concat(currentTemplate.name);
1389
+ name = "pipeline-executor-frame-".concat(currentTemplate.name);
1026
1390
  title = currentTemplate.title;
1027
- priority = promptbook.promptTemplates.length - promptbook.promptTemplates.indexOf(currentTemplate);
1391
+ priority = pipeline.promptTemplates.length - pipeline.promptTemplates.indexOf(currentTemplate);
1028
1392
  if (!onProgress /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
1029
1393
  return [4 /*yield*/, onProgress({
1030
1394
  name: name,
@@ -1081,9 +1445,9 @@
1081
1445
  case 6:
1082
1446
  prompt = {
1083
1447
  title: currentTemplate.title,
1084
- promptbookUrl: "".concat(promptbook.promptbookUrl
1085
- ? promptbook.promptbookUrl
1086
- : 'anonymous' /* <- TODO: [🧠] How to deal with anonymous PROMPTBOOKs, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(currentTemplate.name),
1448
+ pipelineUrl: "".concat(pipeline.pipelineUrl
1449
+ ? pipeline.pipelineUrl
1450
+ : 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(currentTemplate.name),
1087
1451
  parameters: parametersToPass,
1088
1452
  content: replaceParameters(currentTemplate.content, parametersToPass) /* <- [2] */,
1089
1453
  modelRequirements: currentTemplate.modelRequirements,
@@ -1360,7 +1724,7 @@
1360
1724
  // TODO: [🧠] Maybe put other executionTypes into report
1361
1725
  executionReport.promptExecutions.push({
1362
1726
  prompt: {
1363
- title: currentTemplate.title /* <- Note: If title in promptbook contains emojis, pass it innto report */,
1727
+ title: currentTemplate.title /* <- Note: If title in pipeline contains emojis, pass it innto report */,
1364
1728
  content: prompt.content,
1365
1729
  modelRequirements: prompt.modelRequirements,
1366
1730
  expectations: prompt.expectations,
@@ -1396,7 +1760,7 @@
1396
1760
  // <- [3]
1397
1761
  });
1398
1762
  }
1399
- 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));
1763
+ 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));
1400
1764
  return [2 /*return*/];
1401
1765
  }
1402
1766
  });
@@ -1409,17 +1773,17 @@
1409
1773
  case 0:
1410
1774
  parametersToPass = inputParameters;
1411
1775
  executionReport = {
1412
- promptbookUrl: promptbook.promptbookUrl,
1413
- title: promptbook.title,
1776
+ pipelineUrl: pipeline.pipelineUrl,
1777
+ title: pipeline.title,
1414
1778
  promptbookUsedVersion: PROMPTBOOK_VERSION,
1415
- promptbookRequestedVersion: promptbook.promptbookVersion,
1416
- description: promptbook.description,
1779
+ promptbookRequestedVersion: pipeline.promptbookVersion,
1780
+ description: pipeline.description,
1417
1781
  promptExecutions: [],
1418
1782
  };
1419
1783
  _d.label = 1;
1420
1784
  case 1:
1421
1785
  _d.trys.push([1, 6, , 7]);
1422
- resovedParameters_1 = promptbook.parameters
1786
+ resovedParameters_1 = pipeline.parameters
1423
1787
  .filter(function (_a) {
1424
1788
  var isInput = _a.isInput;
1425
1789
  return isInput;
@@ -1428,7 +1792,7 @@
1428
1792
  var name = _a.name;
1429
1793
  return name;
1430
1794
  });
1431
- unresovedTemplates = __spreadArray([], __read(promptbook.promptTemplates), false);
1795
+ unresovedTemplates = __spreadArray([], __read(pipeline.promptTemplates), false);
1432
1796
  resolving_1 = [];
1433
1797
  loopLimit = LOOP_LIMIT;
1434
1798
  _loop_1 = function () {
@@ -1437,7 +1801,7 @@
1437
1801
  switch (_e.label) {
1438
1802
  case 0:
1439
1803
  if (loopLimit-- < 0) {
1440
- throw new UnexpectedError('Loop limit reached during resolving parameters promptbook execution');
1804
+ throw new UnexpectedError('Loop limit reached during resolving parameters pipeline execution');
1441
1805
  }
1442
1806
  currentTemplate = unresovedTemplates.find(function (template) {
1443
1807
  return template.dependentParameterNames.every(function (name) { return resovedParameters_1.includes(name); });
@@ -1495,7 +1859,7 @@
1495
1859
  case 7:
1496
1860
  try {
1497
1861
  // Note: Filter ONLY output parameters
1498
- for (_a = __values(promptbook.parameters), _b = _a.next(); !_b.done; _b = _a.next()) {
1862
+ for (_a = __values(pipeline.parameters), _b = _a.next(); !_b.done; _b = _a.next()) {
1499
1863
  parameter = _b.value;
1500
1864
  if (parameter.isOutput) {
1501
1865
  continue;
@@ -1524,379 +1888,15 @@
1524
1888
  }
1525
1889
  });
1526
1890
  }); };
1527
- return promptbookExecutor;
1891
+ return pipelineExecutor;
1528
1892
  }
1529
1893
  /**
1530
1894
  * TODO: [🧠] When not meet expectations in PROMPT_DIALOG, make some way to tell the user
1531
1895
  * TODO: [👧] Strongly type the executors to avoid need of remove nullables whtn noUncheckedIndexedAccess in tsconfig.json
1532
- * Note: CreatePromptbookExecutorOptions are just connected to PromptbookExecutor so do not extract to types folder
1896
+ * Note: CreatePipelineExecutorOptions are just connected to PipelineExecutor so do not extract to types folder
1533
1897
  * TODO: [🧠][3] transparent = (report intermediate parameters) / opaque execution = (report only output parameters) progress reporting mode
1534
1898
  */
1535
1899
 
1536
- /**
1537
- * Prettify the html code
1538
- *
1539
- * @param content raw html code
1540
- * @returns formatted html code
1541
- */
1542
- function prettifyMarkdown(content) {
1543
- try {
1544
- return prettier.format(content, {
1545
- parser: 'markdown',
1546
- plugins: [parserHtml__default["default"]],
1547
- // TODO: DRY - make some import or auto-copy of .prettierrc
1548
- endOfLine: 'lf',
1549
- tabWidth: 4,
1550
- singleQuote: true,
1551
- trailingComma: 'all',
1552
- arrowParens: 'always',
1553
- printWidth: 120,
1554
- htmlWhitespaceSensitivity: 'ignore',
1555
- jsxBracketSameLine: false,
1556
- bracketSpacing: true,
1557
- });
1558
- }
1559
- catch (error) {
1560
- console.error('There was an error with prettifying the markdown, using the original as the fallback', {
1561
- error: error,
1562
- html: content,
1563
- });
1564
- return content;
1565
- }
1566
- }
1567
-
1568
- /**
1569
- * Makes first letter of a string uppercase
1570
- *
1571
- */
1572
- function capitalize(word) {
1573
- return word.substring(0, 1).toUpperCase() + word.substring(1);
1574
- }
1575
-
1576
- /**
1577
- * Converts promptbook in JSON format to string format
1578
- *
1579
- * @param pipelineJson Promptbook in JSON format (.ptbk.json)
1580
- * @returns Promptbook in string format (.ptbk.md)
1581
- */
1582
- function pipelineJsonToString(pipelineJson) {
1583
- var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
1584
- var title = pipelineJson.title, promptbookUrl = pipelineJson.promptbookUrl, promptbookVersion = pipelineJson.promptbookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, promptTemplates = pipelineJson.promptTemplates;
1585
- var pipelineString = "# ".concat(title);
1586
- if (description) {
1587
- pipelineString += '\n\n';
1588
- pipelineString += description;
1589
- }
1590
- // TODO:> const commands: Array<Command>
1591
- var commands = [];
1592
- if (promptbookUrl) {
1593
- commands.push("PROMPTBOOK URL ".concat(promptbookUrl));
1594
- }
1595
- commands.push("PROMPTBOOK VERSION ".concat(promptbookVersion));
1596
- pipelineString = prettifyMarkdown(pipelineString);
1597
- try {
1598
- for (var _g = __values(parameters.filter(function (_a) {
1599
- var isInput = _a.isInput;
1600
- return isInput;
1601
- })), _h = _g.next(); !_h.done; _h = _g.next()) {
1602
- var parameter = _h.value;
1603
- commands.push("INPUT PARAMETER ".concat(promptTemplateParameterJsonToString(parameter)));
1604
- }
1605
- }
1606
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1607
- finally {
1608
- try {
1609
- if (_h && !_h.done && (_a = _g.return)) _a.call(_g);
1610
- }
1611
- finally { if (e_1) throw e_1.error; }
1612
- }
1613
- try {
1614
- for (var _j = __values(parameters.filter(function (_a) {
1615
- var isOutput = _a.isOutput;
1616
- return isOutput;
1617
- })), _k = _j.next(); !_k.done; _k = _j.next()) {
1618
- var parameter = _k.value;
1619
- commands.push("OUTPUT PARAMETER ".concat(promptTemplateParameterJsonToString(parameter)));
1620
- }
1621
- }
1622
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1623
- finally {
1624
- try {
1625
- if (_k && !_k.done && (_b = _j.return)) _b.call(_j);
1626
- }
1627
- finally { if (e_2) throw e_2.error; }
1628
- }
1629
- pipelineString += '\n\n';
1630
- pipelineString += commands.map(function (command) { return "- ".concat(command); }).join('\n');
1631
- try {
1632
- for (var promptTemplates_1 = __values(promptTemplates), promptTemplates_1_1 = promptTemplates_1.next(); !promptTemplates_1_1.done; promptTemplates_1_1 = promptTemplates_1.next()) {
1633
- var promptTemplate = promptTemplates_1_1.value;
1634
- var
1635
- /* Note: Not using:> name, */
1636
- title_1 = promptTemplate.title, description_1 = promptTemplate.description,
1637
- /* Note: dependentParameterNames, */
1638
- jokers = promptTemplate.jokers, executionType = promptTemplate.executionType, content = promptTemplate.content, postprocessing = promptTemplate.postprocessing, expectations = promptTemplate.expectations, expectFormat = promptTemplate.expectFormat, resultingParameterName = promptTemplate.resultingParameterName;
1639
- pipelineString += '\n\n';
1640
- pipelineString += "## ".concat(title_1);
1641
- if (description_1) {
1642
- pipelineString += '\n\n';
1643
- pipelineString += description_1;
1644
- }
1645
- // TODO:> const commands: Array<Command>
1646
- var commands_1 = [];
1647
- var contentLanguage = 'text';
1648
- if (executionType === 'PROMPT_TEMPLATE') {
1649
- var modelRequirements = promptTemplate.modelRequirements;
1650
- var modelName = modelRequirements.modelName, modelVariant = modelRequirements.modelVariant;
1651
- commands_1.push("EXECUTE PROMPT TEMPLATE");
1652
- if (modelVariant) {
1653
- commands_1.push("MODEL VARIANT ".concat(capitalize(modelVariant)));
1654
- }
1655
- if (modelName) {
1656
- commands_1.push("MODEL NAME `".concat(modelName, "`"));
1657
- }
1658
- }
1659
- else if (executionType === 'SIMPLE_TEMPLATE') {
1660
- commands_1.push("SIMPLE TEMPLATE");
1661
- // Note: Nothing special here
1662
- }
1663
- else if (executionType === 'SCRIPT') {
1664
- commands_1.push("EXECUTE SCRIPT");
1665
- if (promptTemplate.contentLanguage) {
1666
- contentLanguage = promptTemplate.contentLanguage;
1667
- }
1668
- else {
1669
- contentLanguage = '';
1670
- }
1671
- }
1672
- else if (executionType === 'PROMPT_DIALOG') {
1673
- commands_1.push("PROMPT DIALOG");
1674
- // Note: Nothing special here
1675
- }
1676
- if (jokers) {
1677
- try {
1678
- for (var jokers_1 = (e_4 = void 0, __values(jokers)), jokers_1_1 = jokers_1.next(); !jokers_1_1.done; jokers_1_1 = jokers_1.next()) {
1679
- var joker = jokers_1_1.value;
1680
- commands_1.push("JOKER {".concat(joker, "}"));
1681
- }
1682
- }
1683
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
1684
- finally {
1685
- try {
1686
- if (jokers_1_1 && !jokers_1_1.done && (_d = jokers_1.return)) _d.call(jokers_1);
1687
- }
1688
- finally { if (e_4) throw e_4.error; }
1689
- }
1690
- } /* not else */
1691
- if (postprocessing) {
1692
- try {
1693
- for (var postprocessing_1 = (e_5 = void 0, __values(postprocessing)), postprocessing_1_1 = postprocessing_1.next(); !postprocessing_1_1.done; postprocessing_1_1 = postprocessing_1.next()) {
1694
- var postprocessingFunctionName = postprocessing_1_1.value;
1695
- commands_1.push("POSTPROCESSING `".concat(postprocessingFunctionName, "`"));
1696
- }
1697
- }
1698
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
1699
- finally {
1700
- try {
1701
- if (postprocessing_1_1 && !postprocessing_1_1.done && (_e = postprocessing_1.return)) _e.call(postprocessing_1);
1702
- }
1703
- finally { if (e_5) throw e_5.error; }
1704
- }
1705
- } /* not else */
1706
- if (expectations) {
1707
- try {
1708
- for (var _l = (e_6 = void 0, __values(Object.entries(expectations))), _m = _l.next(); !_m.done; _m = _l.next()) {
1709
- var _o = __read(_m.value, 2), unit = _o[0], _p = _o[1], min = _p.min, max = _p.max;
1710
- if (min === max) {
1711
- commands_1.push("EXPECT EXACTLY ".concat(min, " ").concat(capitalize(unit + (min > 1 ? 's' : ''))));
1712
- }
1713
- else {
1714
- if (min !== undefined) {
1715
- commands_1.push("EXPECT MIN ".concat(min, " ").concat(capitalize(unit + (min > 1 ? 's' : ''))));
1716
- } /* not else */
1717
- if (max !== undefined) {
1718
- commands_1.push("EXPECT MAX ".concat(max, " ").concat(capitalize(unit + (max > 1 ? 's' : ''))));
1719
- }
1720
- }
1721
- }
1722
- }
1723
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
1724
- finally {
1725
- try {
1726
- if (_m && !_m.done && (_f = _l.return)) _f.call(_l);
1727
- }
1728
- finally { if (e_6) throw e_6.error; }
1729
- }
1730
- } /* not else */
1731
- if (expectFormat) {
1732
- if (expectFormat === 'JSON') {
1733
- // TODO: @deprecated remove
1734
- commands_1.push("EXPECT JSON");
1735
- }
1736
- } /* not else */
1737
- pipelineString += '\n\n';
1738
- pipelineString += commands_1.map(function (command) { return "- ".concat(command); }).join('\n');
1739
- pipelineString += '\n\n';
1740
- pipelineString += '```' + contentLanguage;
1741
- pipelineString += '\n';
1742
- pipelineString += spaceTrim__default["default"](content);
1743
- // <- TODO: !!! Escape
1744
- // <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
1745
- pipelineString += '\n';
1746
- pipelineString += '```';
1747
- pipelineString += '\n\n';
1748
- pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: !!! If the parameter here has description, add it and use promptTemplateParameterJsonToString
1749
- }
1750
- }
1751
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1752
- finally {
1753
- try {
1754
- if (promptTemplates_1_1 && !promptTemplates_1_1.done && (_c = promptTemplates_1.return)) _c.call(promptTemplates_1);
1755
- }
1756
- finally { if (e_3) throw e_3.error; }
1757
- }
1758
- return pipelineString;
1759
- }
1760
- /**
1761
- * @private internal util of pipelineJsonToString
1762
- */
1763
- function promptTemplateParameterJsonToString(promptTemplateParameterJson) {
1764
- var name = promptTemplateParameterJson.name, description = promptTemplateParameterJson.description;
1765
- var parameterString = "{".concat(name, "}");
1766
- if (description) {
1767
- parameterString = "".concat(parameterString, " ").concat(description);
1768
- }
1769
- return parameterString;
1770
- }
1771
- /**
1772
- * TODO: Escape all
1773
- */
1774
-
1775
- /**
1776
- * This error indicates that promptbook not found in the library
1777
- */
1778
- var NotFoundError = /** @class */ (function (_super) {
1779
- __extends(NotFoundError, _super);
1780
- function NotFoundError(message) {
1781
- var _this = _super.call(this, message) || this;
1782
- _this.name = 'NotFoundError';
1783
- Object.setPrototypeOf(_this, NotFoundError.prototype);
1784
- return _this;
1785
- }
1786
- return NotFoundError;
1787
- }(Error));
1788
-
1789
- /**
1790
- * This error indicates errors in referencing promptbooks between each other
1791
- */
1792
- var ReferenceError$1 = /** @class */ (function (_super) {
1793
- __extends(ReferenceError, _super);
1794
- function ReferenceError(message) {
1795
- var _this = _super.call(this, message) || this;
1796
- _this.name = 'ReferenceError';
1797
- Object.setPrototypeOf(_this, ReferenceError.prototype);
1798
- return _this;
1799
- }
1800
- return ReferenceError;
1801
- }(Error));
1802
-
1803
- /**
1804
- * Library of promptbooks that groups together promptbooks for an application.
1805
- * This implementation is a very thin wrapper around the Array / Map of promptbooks.
1806
- *
1807
- * @private use `createCollectionFromJson` instead
1808
- * @see https://github.com/webgptorg/promptbook#promptbook-collection
1809
- */
1810
- var SimplePipelineCollection = /** @class */ (function () {
1811
- /**
1812
- * Constructs a promptbook library from promptbooks
1813
- *
1814
- * @param promptbooks !!!
1815
- *
1816
- * @private Use instead `createCollectionFromJson`
1817
- * Note: During the construction logic of all promptbooks are validated
1818
- * Note: It is not recommended to use this constructor directly, use `createCollectionFromJson` *(or other variant)* instead
1819
- */
1820
- function SimplePipelineCollection() {
1821
- var e_1, _a;
1822
- var promptbooks = [];
1823
- for (var _i = 0; _i < arguments.length; _i++) {
1824
- promptbooks[_i] = arguments[_i];
1825
- }
1826
- this.library = new Map();
1827
- try {
1828
- for (var promptbooks_1 = __values(promptbooks), promptbooks_1_1 = promptbooks_1.next(); !promptbooks_1_1.done; promptbooks_1_1 = promptbooks_1.next()) {
1829
- var promptbook = promptbooks_1_1.value;
1830
- if (promptbook.promptbookUrl === undefined) {
1831
- 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 ")));
1832
- }
1833
- validatePipeline(promptbook);
1834
- // Note: [🦄]
1835
- if (this.library.has(promptbook.promptbookUrl) &&
1836
- pipelineJsonToString(promptbook) !== pipelineJsonToString(this.library.get(promptbook.promptbookUrl))) {
1837
- 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 ")));
1838
- }
1839
- this.library.set(promptbook.promptbookUrl, promptbook);
1840
- }
1841
- }
1842
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1843
- finally {
1844
- try {
1845
- if (promptbooks_1_1 && !promptbooks_1_1.done && (_a = promptbooks_1.return)) _a.call(promptbooks_1);
1846
- }
1847
- finally { if (e_1) throw e_1.error; }
1848
- }
1849
- }
1850
- /**
1851
- * Gets all promptbooks in the library
1852
- */
1853
- SimplePipelineCollection.prototype.listPipelines = function () {
1854
- return Array.from(this.library.keys());
1855
- };
1856
- /**
1857
- * Gets promptbook by its URL
1858
- *
1859
- * Note: This is not a direct fetching from the URL, but a lookup in the library
1860
- */
1861
- SimplePipelineCollection.prototype.getPipelineByUrl = function (url) {
1862
- var _this = this;
1863
- var promptbook = this.library.get(url);
1864
- if (!promptbook) {
1865
- if (this.listPipelines().length === 0) {
1866
- throw new NotFoundError(spaceTrim.spaceTrim("\n Promptbook with url \"".concat(url, "\" not found\n\n No promptbooks available\n ")));
1867
- }
1868
- 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()
1869
- .map(function (promptbookUrl) { return "- ".concat(promptbookUrl); })
1870
- .join('\n')), "\n\n "); }));
1871
- }
1872
- return promptbook;
1873
- };
1874
- /**
1875
- * Checks whether given prompt was defined in any promptbook in the library
1876
- */
1877
- SimplePipelineCollection.prototype.isResponsibleForPrompt = function (prompt) {
1878
- return true;
1879
- };
1880
- return SimplePipelineCollection;
1881
- }());
1882
-
1883
- /**
1884
- * Creates PipelineCollection from array of PipelineJson or PipelineString
1885
- *
1886
- * Note: Functions `libraryToJson` and `createCollectionFromJson` are complementary
1887
- * Note: During the construction syntax and logic of all sources are validated
1888
- *
1889
- * @param promptbookSources
1890
- * @returns PipelineCollection
1891
- */
1892
- function createCollectionFromJson() {
1893
- var promptbooks = [];
1894
- for (var _i = 0; _i < arguments.length; _i++) {
1895
- promptbooks[_i] = arguments[_i];
1896
- }
1897
- return new (SimplePipelineCollection.bind.apply(SimplePipelineCollection, __spreadArray([void 0], __read(promptbooks), false)))();
1898
- }
1899
-
1900
1900
  /* tslint:disable */
1901
1901
  function normalizeToKebabCase(sentence) {
1902
1902
  var e_1, _a;
@@ -1954,18 +1954,18 @@
1954
1954
 
1955
1955
  function prepareKnowledgeFromMarkdown(options) {
1956
1956
  return __awaiter(this, void 0, void 0, function () {
1957
- var content, llmTools, _a, isVerbose, library, prepareKnowledgeFromMarkdownPromptbook, prepareKnowledgeFromMarkdownExecutor, prepareKeywordsPromptbook, prepareKeywordsExecutor, result, outputParameters, knowledgeRaw, knowledgeTextPieces, knowledge;
1957
+ var content, llmTools, _a, isVerbose, collection, prepareKnowledgeFromMarkdownPromptbook, prepareKnowledgeFromMarkdownExecutor, prepareKeywordsPromptbook, prepareKeywordsExecutor, result, outputParameters, knowledgeRaw, knowledgeTextPieces, knowledge;
1958
1958
  var _this = this;
1959
1959
  return __generator(this, function (_b) {
1960
1960
  switch (_b.label) {
1961
1961
  case 0:
1962
1962
  content = options.content, llmTools = options.llmTools, _a = options.isVerbose, isVerbose = _a === void 0 ? false : _a;
1963
- library = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
1964
- return [4 /*yield*/, library.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md')];
1963
+ collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
1964
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md')];
1965
1965
  case 1:
1966
1966
  prepareKnowledgeFromMarkdownPromptbook = _b.sent();
1967
- prepareKnowledgeFromMarkdownExecutor = createPromptbookExecutor({
1968
- promptbook: prepareKnowledgeFromMarkdownPromptbook,
1967
+ prepareKnowledgeFromMarkdownExecutor = createPipelineExecutor({
1968
+ pipeline: prepareKnowledgeFromMarkdownPromptbook,
1969
1969
  tools: {
1970
1970
  llm: llmTools,
1971
1971
  script: [
@@ -1973,11 +1973,11 @@
1973
1973
  ],
1974
1974
  },
1975
1975
  });
1976
- return [4 /*yield*/, library.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-keywords.ptbk.md')];
1976
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-keywords.ptbk.md')];
1977
1977
  case 2:
1978
1978
  prepareKeywordsPromptbook = _b.sent();
1979
- prepareKeywordsExecutor = createPromptbookExecutor({
1980
- promptbook: prepareKeywordsPromptbook,
1979
+ prepareKeywordsExecutor = createPipelineExecutor({
1980
+ pipeline: prepareKeywordsPromptbook,
1981
1981
  tools: {
1982
1982
  llm: llmTools,
1983
1983
  script: [
@@ -2654,28 +2654,31 @@
2654
2654
  .map(function (part) { return part.trim(); })
2655
2655
  .filter(function (item) { return item !== ''; })
2656
2656
  .filter(function (item) { return !/^PTBK$/i.test(item); })
2657
+ .filter(function (item) { return !/^PIPELINE$/i.test(item); })
2657
2658
  .filter(function (item) { return !/^PROMPTBOOK$/i.test(item); })
2658
2659
  .map(removeMarkdownFormatting);
2659
2660
  if (type.startsWith('URL') ||
2660
2661
  type.startsWith('PTBK_URL') ||
2661
2662
  type.startsWith('PTBKURL') ||
2663
+ type.startsWith('PIPELINE_URL') ||
2664
+ type.startsWith('PIPELINEURL') ||
2662
2665
  type.startsWith('PROMPTBOOK_URL') ||
2663
2666
  type.startsWith('PROMPTBOOKURL') ||
2664
2667
  type.startsWith('HTTPS')) {
2665
2668
  if (!(listItemParts.length === 2 || (listItemParts.length === 1 && type.startsWith('HTTPS')))) {
2666
- throw new SyntaxError(spaceTrim.spaceTrim("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n ")));
2669
+ throw new SyntaxError(spaceTrim.spaceTrim("\n Invalid PIPELINE_URL command:\n\n - ".concat(listItem, "\n ")));
2667
2670
  }
2668
- var promptbookUrlString = listItemParts.pop();
2669
- var promptbookUrl = new URL(promptbookUrlString);
2670
- if (promptbookUrl.protocol !== 'https:') {
2671
- throw new SyntaxError(spaceTrim.spaceTrim("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n\n Protocol must be HTTPS\n ")));
2671
+ var pipelineUrlString = listItemParts.pop();
2672
+ var pipelineUrl = new URL(pipelineUrlString);
2673
+ if (pipelineUrl.protocol !== 'https:') {
2674
+ throw new SyntaxError(spaceTrim.spaceTrim("\n Invalid PIPELINE_URL command:\n\n - ".concat(listItem, "\n\n Protocol must be HTTPS\n ")));
2672
2675
  }
2673
- if (promptbookUrl.hash !== '') {
2674
- 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 ")));
2676
+ if (pipelineUrl.hash !== '') {
2677
+ 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 ")));
2675
2678
  }
2676
2679
  return {
2677
- type: 'PROMPTBOOK_URL',
2678
- promptbookUrl: promptbookUrl,
2680
+ type: 'PIPELINE_URL',
2681
+ pipelineUrl: pipelineUrl,
2679
2682
  };
2680
2683
  }
2681
2684
  else if (type.startsWith('PROMPTBOOK_VERSION') || type.startsWith('PTBK_VERSION')) {
@@ -2867,7 +2870,7 @@
2867
2870
  */
2868
2871
  }
2869
2872
  else {
2870
- 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 ")));
2873
+ 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 ")));
2871
2874
  }
2872
2875
  }
2873
2876
 
@@ -2916,7 +2919,7 @@
2916
2919
  var pipelineJson = {
2917
2920
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2918
2921
  title: undefined /* <- Note: Putting here placeholder to keep `title` on top at final JSON */,
2919
- promptbookUrl: undefined /* <- Note: Putting here placeholder to keep `promptbookUrl` on top at final JSON */,
2922
+ pipelineUrl: undefined /* <- Note: Putting here placeholder to keep `pipelineUrl` on top at final JSON */,
2920
2923
  promptbookVersion: PROMPTBOOK_VERSION,
2921
2924
  description: undefined /* <- Note: Putting here placeholder to keep `description` on top at final JSON */,
2922
2925
  parameters: [],
@@ -2979,8 +2982,8 @@
2979
2982
  var listItem = listItems_1_1.value;
2980
2983
  var command = parseCommand(listItem);
2981
2984
  switch (command.type) {
2982
- case 'PROMPTBOOK_URL':
2983
- pipelineJson.promptbookUrl = command.promptbookUrl.href;
2985
+ case 'PIPELINE_URL':
2986
+ pipelineJson.pipelineUrl = command.pipelineUrl.href;
2984
2987
  break;
2985
2988
  case 'PROMPTBOOK_VERSION':
2986
2989
  pipelineJson.promptbookVersion = command.promptbookVersion;
@@ -3206,7 +3209,7 @@
3206
3209
  */
3207
3210
 
3208
3211
  /**
3209
- * This error indicates that the promptbook library cannot be propperly loaded
3212
+ * This error indicates that the pipeline collection cannot be propperly loaded
3210
3213
  */
3211
3214
  var CollectionError = /** @class */ (function (_super) {
3212
3215
  __extends(CollectionError, _super);
@@ -3242,7 +3245,7 @@
3242
3245
  * `createCollectionFromUrl` or `createCollectionFromDirectory`
3243
3246
  * Consider using those functions instead of this one
3244
3247
  *
3245
- * Note: The function does NOT return promise it returns the library directly which waits for the sources to be resolved
3248
+ * Note: The function does NOT return promise it returns the collection directly which waits for the sources to be resolved
3246
3249
  * when error occurs in given promise or factory function, it is thrown during `listPipelines` or `getPipelineByUrl` call
3247
3250
  *
3248
3251
  * Note: Consider using `createCollectionFromDirectory` or `createCollectionFromUrl`
@@ -3252,7 +3255,7 @@
3252
3255
  * @deprecated Do not use, it will became internal tool for other constructor functions
3253
3256
  */
3254
3257
  function createCollectionFromPromise(promptbookSourcesPromiseOrFactory) {
3255
- var library;
3258
+ var collection;
3256
3259
  function forSources() {
3257
3260
  return __awaiter(this, void 0, void 0, function () {
3258
3261
  var promptbookSources;
@@ -3266,7 +3269,7 @@
3266
3269
  return [4 /*yield*/, promptbookSourcesPromiseOrFactory];
3267
3270
  case 1:
3268
3271
  promptbookSources = _a.sent();
3269
- library = createCollectionFromJson.apply(void 0, __spreadArray([], __read(promptbookSources), false));
3272
+ collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(promptbookSources), false));
3270
3273
  return [2 /*return*/];
3271
3274
  }
3272
3275
  });
@@ -3279,7 +3282,7 @@
3279
3282
  case 0: return [4 /*yield*/, forSources()];
3280
3283
  case 1:
3281
3284
  _a.sent();
3282
- return [2 /*return*/, /* not await */ library.listPipelines()];
3285
+ return [2 /*return*/, /* not await */ collection.listPipelines()];
3283
3286
  }
3284
3287
  });
3285
3288
  });
@@ -3291,7 +3294,7 @@
3291
3294
  case 0: return [4 /*yield*/, forSources()];
3292
3295
  case 1:
3293
3296
  _a.sent();
3294
- return [2 /*return*/, /* not await */ library.getPipelineByUrl(url)];
3297
+ return [2 /*return*/, /* not await */ collection.getPipelineByUrl(url)];
3295
3298
  }
3296
3299
  });
3297
3300
  });
@@ -3303,7 +3306,7 @@
3303
3306
  case 0: return [4 /*yield*/, forSources()];
3304
3307
  case 1:
3305
3308
  _a.sent();
3306
- return [2 /*return*/, /* not await */ library.isResponsibleForPrompt(prompt)];
3309
+ return [2 /*return*/, /* not await */ collection.isResponsibleForPrompt(prompt)];
3307
3310
  }
3308
3311
  });
3309
3312
  });
@@ -3321,12 +3324,12 @@
3321
3324
  * Note: Works only in Node.js environment because it reads the file system
3322
3325
  *
3323
3326
  * @param path - path to the directory with promptbooks
3324
- * @param options - Misc options for the library
3327
+ * @param options - Misc options for the collection
3325
3328
  * @returns PipelineCollection
3326
3329
  */
3327
3330
  function createCollectionFromDirectory(path$1, options) {
3328
3331
  return __awaiter(this, void 0, void 0, function () {
3329
- var makedLibraryFilePath, makedLibraryFileExists, _a, _b, isRecursive, _c, isVerbose, _d, isLazyLoaded, _e, isCrashOnError, library;
3332
+ var makedLibraryFilePath, makedLibraryFileExists, _a, _b, isRecursive, _c, isVerbose, _d, isLazyLoaded, _e, isCrashOnError, collection;
3330
3333
  var _this = this;
3331
3334
  return __generator(this, function (_f) {
3332
3335
  switch (_f.label) {
@@ -3334,28 +3337,28 @@
3334
3337
  if (!isRunningInNode()) {
3335
3338
  throw new Error('Function `createCollectionFromDirectory` can only be run in Node.js environment because it reads the file system.');
3336
3339
  }
3337
- makedLibraryFilePath = path.join(path$1, "".concat(PROMPTBOOK_MAKED_BASE_FILENAME, ".json"));
3340
+ makedLibraryFilePath = path.join(path$1, "".concat(PIPELINE_COLLECTION_BASE_FILENAME, ".json"));
3338
3341
  return [4 /*yield*/, promises.access(makedLibraryFilePath, promises.constants.R_OK)
3339
3342
  .then(function () { return true; })
3340
3343
  .catch(function () { return false; })];
3341
3344
  case 1:
3342
3345
  makedLibraryFileExists = _f.sent();
3343
3346
  if (!makedLibraryFileExists) {
3344
- console.info(colors__default["default"].yellow("Tip: Prebuild your promptbook library (file with supposed prebuild ".concat(makedLibraryFilePath, " not found) with CLI util \"promptbook make\" to speed up the library creation.")));
3347
+ console.info(colors__default["default"].yellow("Tip: Prebuild your pipeline collection (file with supposed prebuild ".concat(makedLibraryFilePath, " not found) with CLI util \"promptbook make\" to speed up the collection creation.")));
3345
3348
  }
3346
3349
  else {
3347
- colors__default["default"].green("(In future, not implemented yet) Using your prebuild promptbook library ".concat(makedLibraryFilePath));
3350
+ colors__default["default"].green("(In future, not implemented yet) Using your prebuild pipeline collection ".concat(makedLibraryFilePath));
3348
3351
  // TODO: !! Implement;
3349
3352
  }
3350
3353
  _a = options || {}, _b = _a.isRecursive, isRecursive = _b === void 0 ? true : _b, _c = _a.isVerbose, isVerbose = _c === void 0 ? false : _c, _d = _a.isLazyLoaded, isLazyLoaded = _d === void 0 ? false : _d, _e = _a.isCrashOnError, isCrashOnError = _e === void 0 ? true : _e;
3351
- library = createCollectionFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
3354
+ collection = createCollectionFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
3352
3355
  var fileNames, promptbooks, _loop_1, fileNames_1, fileNames_1_1, fileName, e_1_1;
3353
3356
  var e_1, _a;
3354
3357
  return __generator(this, function (_b) {
3355
3358
  switch (_b.label) {
3356
3359
  case 0:
3357
3360
  if (isVerbose) {
3358
- console.info("Creating promptbook library from path ".concat(path$1.split('\\').join('/')));
3361
+ console.info("Creating pipeline collection from path ".concat(path$1.split('\\').join('/')));
3359
3362
  }
3360
3363
  return [4 /*yield*/, listAllFiles(path$1, isRecursive)];
3361
3364
  case 1:
@@ -3395,7 +3398,7 @@
3395
3398
  case 6:
3396
3399
  // ---
3397
3400
  if (promptbook !== null) {
3398
- if (!promptbook.promptbookUrl) {
3401
+ if (!promptbook.pipelineUrl) {
3399
3402
  if (isVerbose) {
3400
3403
  console.info("Not loading ".concat(fileName.split('\\').join('/'), " - missing URL"));
3401
3404
  }
@@ -3419,7 +3422,7 @@
3419
3422
  if (!(error_1 instanceof Error)) {
3420
3423
  throw error_1;
3421
3424
  }
3422
- wrappedErrorMessage = spaceTrim__default["default"](function (block) { return "\n Error during loading promptbook from file ".concat(fileName.split('\\').join('/'), ":\n\n ").concat(block(error_1.message), "\n\n "); });
3425
+ wrappedErrorMessage = spaceTrim__default["default"](function (block) { return "\n Error during loading pipeline from file ".concat(fileName.split('\\').join('/'), ":\n\n ").concat(block(error_1.message), "\n\n "); });
3423
3426
  if (isCrashOnError) {
3424
3427
  throw new CollectionError(wrappedErrorMessage);
3425
3428
  }
@@ -3460,11 +3463,11 @@
3460
3463
  });
3461
3464
  }); });
3462
3465
  if (!(isLazyLoaded === false)) return [3 /*break*/, 3];
3463
- return [4 /*yield*/, library.listPipelines()];
3466
+ return [4 /*yield*/, collection.listPipelines()];
3464
3467
  case 2:
3465
3468
  _f.sent();
3466
3469
  _f.label = 3;
3467
- case 3: return [2 /*return*/, library];
3470
+ case 3: return [2 /*return*/, collection];
3468
3471
  }
3469
3472
  });
3470
3473
  });