@promptbook/cli 0.61.0-12 → 0.61.0-14

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 (125) hide show
  1. package/esm/index.es.js +174 -64
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/execute-javascript.index.d.ts +1 -1
  4. package/esm/typings/src/_packages/types.index.d.ts +6 -3
  5. package/esm/typings/src/_packages/utils.index.d.ts +1 -1
  6. package/esm/typings/src/commands/MODEL/ModelCommand.d.ts +2 -2
  7. package/esm/typings/src/config.d.ts +5 -1
  8. package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +13 -0
  9. package/esm/typings/src/conversion/validation/_importPipeline.d.ts +10 -1
  10. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +1 -1
  11. package/esm/typings/src/errors/LimitReachedError.d.ts +7 -0
  12. package/esm/typings/src/execution/LlmExecutionTools.d.ts +7 -7
  13. package/esm/typings/src/execution/PipelineExecutor.d.ts +1 -1
  14. package/esm/typings/src/execution/PromptResult.d.ts +14 -56
  15. package/esm/typings/src/execution/PromptResultUsage.d.ts +26 -0
  16. package/esm/typings/src/execution/UncertainNumber.d.ts +18 -0
  17. package/esm/typings/src/execution/utils/addUsage.d.ts +58 -2
  18. package/esm/typings/src/execution/utils/computeUsageCounts.d.ts +1 -1
  19. package/esm/typings/src/execution/utils/uncertainNumber.d.ts +1 -1
  20. package/esm/typings/src/execution/utils/usageToWorktime.d.ts +2 -2
  21. package/esm/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +10 -2
  22. package/esm/typings/src/llm-providers/_common/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +2 -1
  23. package/esm/typings/src/llm-providers/_common/utils/count-total-cost/LlmExecutionToolsWithTotalCost.d.ts +1 -1
  24. package/esm/typings/src/llm-providers/_common/utils/count-total-cost/limitTotalCost.d.ts +32 -0
  25. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +2 -2
  26. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +4 -4
  27. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +4 -4
  28. package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +6 -6
  29. package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +9 -7
  30. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +6 -6
  31. package/esm/typings/src/llm-providers/openai/computeOpenaiUsage.d.ts +1 -1
  32. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +9 -7
  33. package/esm/typings/src/scripting/javascript/utils/unknownToString.d.ts +2 -1
  34. package/esm/typings/src/types/ModelRequirements.d.ts +53 -14
  35. package/esm/typings/src/types/ModelVariant.d.ts +14 -0
  36. package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +2 -4
  37. package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -1
  38. package/esm/typings/src/types/Prompt.d.ts +45 -1
  39. package/esm/typings/src/types/typeAliases.d.ts +11 -0
  40. package/esm/typings/src/utils/deepClone.d.ts +9 -0
  41. package/esm/typings/src/utils/deepFreeze.d.ts +13 -0
  42. package/esm/typings/src/utils/normalization/parseKeywords.d.ts +2 -1
  43. package/{umd/typings/src/utils/organization/TODO.d.ts → esm/typings/src/utils/organization/TODO_any.d.ts} +1 -1
  44. package/esm/typings/src/utils/organization/TODO_object.d.ts +6 -0
  45. package/esm/typings/src/utils/organization/TODO_unknown.d.ts +6 -0
  46. package/esm/typings/src/utils/organization/just.d.ts +4 -1
  47. package/esm/typings/src/utils/organization/keepUnused.d.ts +16 -0
  48. package/esm/typings/src/utils/organization/really_any.d.ts +1 -1
  49. package/esm/typings/src/utils/organization/really_unknown.d.ts +6 -0
  50. package/esm/typings/src/utils/validators/email/isValidEmail.d.ts +2 -1
  51. package/esm/typings/src/utils/validators/filePath/isValidFilePath.d.ts +2 -1
  52. package/esm/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +2 -1
  53. package/esm/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.d.ts +2 -1
  54. package/esm/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.d.ts +2 -1
  55. package/esm/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -1
  56. package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +2 -1
  57. package/esm/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -1
  58. package/esm/typings/src/version.d.ts +0 -3
  59. package/package.json +2 -2
  60. package/umd/index.umd.js +174 -64
  61. package/umd/index.umd.js.map +1 -1
  62. package/umd/typings/src/_packages/execute-javascript.index.d.ts +1 -1
  63. package/umd/typings/src/_packages/types.index.d.ts +6 -3
  64. package/umd/typings/src/_packages/utils.index.d.ts +1 -1
  65. package/umd/typings/src/commands/MODEL/ModelCommand.d.ts +2 -2
  66. package/umd/typings/src/config.d.ts +5 -1
  67. package/umd/typings/src/conversion/utils/stringifyPipelineJson.d.ts +13 -0
  68. package/umd/typings/src/conversion/validation/_importPipeline.d.ts +10 -1
  69. package/umd/typings/src/conversion/validation/validatePipeline.d.ts +1 -1
  70. package/umd/typings/src/errors/LimitReachedError.d.ts +7 -0
  71. package/umd/typings/src/execution/LlmExecutionTools.d.ts +7 -7
  72. package/umd/typings/src/execution/PipelineExecutor.d.ts +1 -1
  73. package/umd/typings/src/execution/PromptResult.d.ts +14 -56
  74. package/umd/typings/src/execution/PromptResultUsage.d.ts +26 -0
  75. package/umd/typings/src/execution/UncertainNumber.d.ts +18 -0
  76. package/umd/typings/src/execution/utils/addUsage.d.ts +58 -2
  77. package/umd/typings/src/execution/utils/computeUsageCounts.d.ts +1 -1
  78. package/umd/typings/src/execution/utils/uncertainNumber.d.ts +1 -1
  79. package/umd/typings/src/execution/utils/usageToWorktime.d.ts +2 -2
  80. package/umd/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +10 -2
  81. package/umd/typings/src/llm-providers/_common/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +2 -1
  82. package/umd/typings/src/llm-providers/_common/utils/count-total-cost/LlmExecutionToolsWithTotalCost.d.ts +1 -1
  83. package/umd/typings/src/llm-providers/_common/utils/count-total-cost/limitTotalCost.d.ts +32 -0
  84. package/umd/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +2 -2
  85. package/umd/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +4 -4
  86. package/umd/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +4 -4
  87. package/umd/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +6 -6
  88. package/umd/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +9 -7
  89. package/umd/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +6 -6
  90. package/umd/typings/src/llm-providers/openai/computeOpenaiUsage.d.ts +1 -1
  91. package/umd/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +9 -7
  92. package/umd/typings/src/scripting/javascript/utils/unknownToString.d.ts +2 -1
  93. package/umd/typings/src/types/ModelRequirements.d.ts +53 -14
  94. package/umd/typings/src/types/ModelVariant.d.ts +14 -0
  95. package/umd/typings/src/types/PipelineJson/PersonaJson.d.ts +2 -4
  96. package/umd/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -1
  97. package/umd/typings/src/types/Prompt.d.ts +45 -1
  98. package/umd/typings/src/types/typeAliases.d.ts +11 -0
  99. package/umd/typings/src/utils/deepClone.d.ts +9 -0
  100. package/umd/typings/src/utils/deepFreeze.d.ts +13 -0
  101. package/umd/typings/src/utils/normalization/parseKeywords.d.ts +2 -1
  102. package/{esm/typings/src/utils/organization/TODO.d.ts → umd/typings/src/utils/organization/TODO_any.d.ts} +1 -1
  103. package/umd/typings/src/utils/organization/TODO_object.d.ts +6 -0
  104. package/umd/typings/src/utils/organization/TODO_unknown.d.ts +6 -0
  105. package/umd/typings/src/utils/organization/just.d.ts +4 -1
  106. package/umd/typings/src/utils/organization/keepUnused.d.ts +16 -0
  107. package/umd/typings/src/utils/organization/really_any.d.ts +1 -1
  108. package/umd/typings/src/utils/organization/really_unknown.d.ts +6 -0
  109. package/umd/typings/src/utils/validators/email/isValidEmail.d.ts +2 -1
  110. package/umd/typings/src/utils/validators/filePath/isValidFilePath.d.ts +2 -1
  111. package/umd/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +2 -1
  112. package/umd/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.d.ts +2 -1
  113. package/umd/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.d.ts +2 -1
  114. package/umd/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -1
  115. package/umd/typings/src/utils/validators/url/isValidUrl.d.ts +2 -1
  116. package/umd/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -1
  117. package/umd/typings/src/version.d.ts +0 -3
  118. package/esm/typings/src/utils/organization/keepImported.d.ts +0 -12
  119. package/esm/typings/src/utils/organization/notUsing.d.ts +0 -12
  120. package/umd/typings/src/utils/organization/keepImported.d.ts +0 -12
  121. package/umd/typings/src/utils/organization/notUsing.d.ts +0 -12
  122. /package/esm/typings/src/{execution/addPromptResultUsage.test.d.ts → conversion/utils/stringifyPipelineJson.test.d.ts} +0 -0
  123. /package/esm/typings/src/{utils/postprocessing → postprocessing/utils}/extractBlock.d.ts +0 -0
  124. /package/umd/typings/src/{execution/addPromptResultUsage.test.d.ts → conversion/utils/stringifyPipelineJson.test.d.ts} +0 -0
  125. /package/umd/typings/src/{utils/postprocessing → postprocessing/utils}/extractBlock.d.ts +0 -0
package/esm/index.es.js CHANGED
@@ -150,11 +150,8 @@ new Function("\n try {\n if (typeof WorkerGlobalScope !== 'undefined'
150
150
  /**
151
151
  * The version of the Promptbook library
152
152
  */
153
- var PROMPTBOOK_VERSION = '0.61.0-11';
153
+ var PROMPTBOOK_VERSION = '0.61.0-13';
154
154
  // TODO: !!!! List here all the versions and annotate + put into script
155
- /**
156
- * TODO: [🔼] !!! Export via `@promptbook/code`
157
- */
158
155
 
159
156
  /**
160
157
  * Initializes testing `hello` command for Promptbook CLI utilities
@@ -214,6 +211,39 @@ function collectionToJson(collection) {
214
211
  * TODO: [🧠] Maybe clear `sourceFile` or clear when exposing through API or remote server
215
212
  */
216
213
 
214
+ /**
215
+ * @@@
216
+ *
217
+ * @returns The same object as the input, but deeply frozen
218
+ *
219
+ * Note: This function mutates the object
220
+ */
221
+ function deepFreeze(objectValue) {
222
+ var e_1, _a;
223
+ var propertyNames = Object.getOwnPropertyNames(objectValue);
224
+ try {
225
+ for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
226
+ var propertyName = propertyNames_1_1.value;
227
+ var value = objectValue[propertyName];
228
+ if (value && typeof value === 'object') {
229
+ deepFreeze(value);
230
+ }
231
+ }
232
+ }
233
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
234
+ finally {
235
+ try {
236
+ if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
237
+ }
238
+ finally { if (e_1) throw e_1.error; }
239
+ }
240
+ return Object.freeze(objectValue);
241
+ }
242
+ /**
243
+ * TODO: [🔼] Export from `@promptbook/utils`
244
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
245
+ */
246
+
217
247
  /**
218
248
  * The maximum number of iterations for a loops
219
249
  */
@@ -233,47 +263,78 @@ var PIPELINE_COLLECTION_BASE_FILENAME = "index";
233
263
  /**
234
264
  * The names of the parameters that are reserved for special purposes
235
265
  */
236
- var RESERVED_PARAMETER_NAMES = [
266
+ var RESERVED_PARAMETER_NAMES = deepFreeze([
237
267
  'context',
238
268
  // <- TODO: Add more like 'date', 'modelName',...
239
269
  // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
240
- ];
270
+ ]);
271
+ /**
272
+ * Nonce which is used for replacing things in strings
273
+ */
274
+ var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
241
275
  /*
242
276
  TODO: !!! Just testing false-negative detection of [🟡][🟢][🔵][⚪] leak
243
277
  */
244
278
  // [🟡][🟢][🔵][⚪]
245
279
 
280
+ /**
281
+ * @@@
282
+ */
283
+ function deepClone(objectValue) {
284
+ return JSON.parse(JSON.stringify(objectValue));
285
+ /*
286
+ TODO: [🧠] Is there a better implementation?
287
+ > const propertyNames = Object.getOwnPropertyNames(objectValue);
288
+ > for (const propertyName of propertyNames) {
289
+ > const value = (objectValue as really_any)[propertyName];
290
+ > if (value && typeof value === 'object') {
291
+ > deepClone(value);
292
+ > }
293
+ > }
294
+ > return Object.assign({}, objectValue);
295
+ */
296
+ }
297
+ /**
298
+ * TODO: [🔼] Export from `@promptbook/utils`
299
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
300
+ */
301
+
302
+ /**
303
+ * @@@
304
+ *
305
+ * TODO: [🔼] Export with addUsage
306
+ */
307
+ var ZERO_USAGE = deepFreeze({
308
+ price: { value: 0 },
309
+ input: {
310
+ tokensCount: { value: 0 },
311
+ charactersCount: { value: 0 },
312
+ wordsCount: { value: 0 },
313
+ sentencesCount: { value: 0 },
314
+ linesCount: { value: 0 },
315
+ paragraphsCount: { value: 0 },
316
+ pagesCount: { value: 0 },
317
+ },
318
+ output: {
319
+ tokensCount: { value: 0 },
320
+ charactersCount: { value: 0 },
321
+ wordsCount: { value: 0 },
322
+ sentencesCount: { value: 0 },
323
+ linesCount: { value: 0 },
324
+ paragraphsCount: { value: 0 },
325
+ pagesCount: { value: 0 },
326
+ },
327
+ });
246
328
  /**
247
329
  * Function `addUsage` will add multiple usages into one
248
330
  *
249
- * Note: If you provide 0 values, it returns void usage
331
+ * Note: If you provide 0 values, it returns ZERO_USAGE
250
332
  */
251
333
  function addUsage() {
252
334
  var usageItems = [];
253
335
  for (var _i = 0; _i < arguments.length; _i++) {
254
336
  usageItems[_i] = arguments[_i];
255
337
  }
256
- var initialStructure = {
257
- price: { value: 0 },
258
- input: {
259
- tokensCount: { value: 0 },
260
- charactersCount: { value: 0 },
261
- wordsCount: { value: 0 },
262
- sentencesCount: { value: 0 },
263
- linesCount: { value: 0 },
264
- paragraphsCount: { value: 0 },
265
- pagesCount: { value: 0 },
266
- },
267
- output: {
268
- tokensCount: { value: 0 },
269
- charactersCount: { value: 0 },
270
- wordsCount: { value: 0 },
271
- sentencesCount: { value: 0 },
272
- linesCount: { value: 0 },
273
- paragraphsCount: { value: 0 },
274
- pagesCount: { value: 0 },
275
- },
276
- };
277
338
  return usageItems.reduce(function (acc, item) {
278
339
  var e_1, _a, e_2, _b;
279
340
  var _c;
@@ -331,7 +392,7 @@ function addUsage() {
331
392
  finally { if (e_2) throw e_2.error; }
332
393
  }
333
394
  return acc;
334
- }, initialStructure);
395
+ }, deepClone(ZERO_USAGE));
335
396
  }
336
397
 
337
398
  /**
@@ -408,7 +469,7 @@ function forEachAsync(array, options, callbackfunction) {
408
469
  });
409
470
  }
410
471
 
411
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-11",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"],blockType:"PROMPT_TEMPLATE",personaName:null,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"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-11",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.61.0-11",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"],blockType:"PROMPT_TEMPLATE",personaName:null,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"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-11",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.61.0-11",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],blockType:"PROMPT_TEMPLATE",expectations:{words:{min:1,max:8}},personaName:null,modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {content}",resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-11",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.61.0-11",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],promptTemplates:[{name:"make-model-requirements",title:"Make modelRequirements",dependentParameterNames:["availableModelNames","personaDescription"],blockType:"PROMPT_TEMPLATE",expectFormat:"JSON",personaName:null,modelRequirements:{modelVariant:"CHAT",modelName:"gpt-4-turbo"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n### Option `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Option `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Option `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-11",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
472
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-13",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"],blockType:"PROMPT_TEMPLATE",personaName:null,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"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-13",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.61.0-13",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"],blockType:"PROMPT_TEMPLATE",personaName:null,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"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-13",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.61.0-13",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],blockType:"PROMPT_TEMPLATE",expectations:{words:{min:1,max:8}},personaName:null,modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {content}",resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-13",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.61.0-13",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],promptTemplates:[{name:"make-model-requirements",title:"Make modelRequirements",dependentParameterNames:["availableModelNames","personaDescription"],blockType:"PROMPT_TEMPLATE",expectFormat:"JSON",personaName:null,modelRequirements:{modelVariant:"CHAT",modelName:"gpt-4-turbo"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n### Option `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Option `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Option `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-13",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
412
473
 
413
474
  /**
414
475
  * Prettify the html code
@@ -988,6 +1049,7 @@ function validatePipeline(pipeline) {
988
1049
  var loopLimit = LOOP_LIMIT;
989
1050
  var _loop_2 = function () {
990
1051
  if (loopLimit-- < 0) {
1052
+ // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
991
1053
  throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `validatePipeline`');
992
1054
  }
993
1055
  var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
@@ -1023,7 +1085,7 @@ function validatePipeline(pipeline) {
1023
1085
  * > * It checks:
1024
1086
  * > * - it has a valid structure
1025
1087
  * > * - ...
1026
- * > ex port function validatePipeline(promptbook: unknown): asserts promptbook is PipelineJson {
1088
+ * > ex port function validatePipeline(promptbook: really_unknown): asserts promptbook is PipelineJson {
1027
1089
  */
1028
1090
  /**
1029
1091
  * TODO: [🧠][🐣] !!!! Validate that all samples match expectations
@@ -1937,6 +1999,20 @@ function checkExpectations(expectations, value) {
1937
1999
  * TODO: [💝] Unite object for expecting amount and format
1938
2000
  */
1939
2001
 
2002
+ /**
2003
+ * This error type indicates that some limit was reached
2004
+ */
2005
+ var LimitReachedError = /** @class */ (function (_super) {
2006
+ __extends(LimitReachedError, _super);
2007
+ function LimitReachedError(message) {
2008
+ var _this = _super.call(this, message) || this;
2009
+ _this.name = 'LimitReachedError';
2010
+ Object.setPrototypeOf(_this, LimitReachedError.prototype);
2011
+ return _this;
2012
+ }
2013
+ return LimitReachedError;
2014
+ }(Error));
2015
+
1940
2016
  /**
1941
2017
  * Replaces parameters in template with values from parameters object
1942
2018
  *
@@ -1953,7 +2029,7 @@ function replaceParameters(template, parameters) {
1953
2029
  var loopLimit = LOOP_LIMIT;
1954
2030
  var _loop_1 = function () {
1955
2031
  if (loopLimit-- < 0) {
1956
- throw new UnexpectedError('Loop limit reached during parameters replacement in `replaceParameters`');
2032
+ throw new LimitReachedError('Loop limit reached during parameters replacement in `replaceParameters`');
1957
2033
  }
1958
2034
  var precol = match.groups.precol;
1959
2035
  var parameterName = match.groups.parameterName;
@@ -2441,6 +2517,7 @@ function createPipelineExecutor(options) {
2441
2517
  switch (_e.label) {
2442
2518
  case 0:
2443
2519
  if (loopLimit-- < 0) {
2520
+ // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
2444
2521
  throw new UnexpectedError('Loop limit reached during resolving parameters pipeline execution');
2445
2522
  }
2446
2523
  currentTemplate = unresovedTemplates.find(function (template) {
@@ -2487,7 +2564,7 @@ function createPipelineExecutor(options) {
2487
2564
  }
2488
2565
  usage_1 = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
2489
2566
  var result = _a.result;
2490
- return (result === null || result === void 0 ? void 0 : result.usage) || addUsage();
2567
+ return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
2491
2568
  })), false));
2492
2569
  return [2 /*return*/, {
2493
2570
  isSuccessful: false,
@@ -2516,7 +2593,7 @@ function createPipelineExecutor(options) {
2516
2593
  }
2517
2594
  usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
2518
2595
  var result = _a.result;
2519
- return (result === null || result === void 0 ? void 0 : result.usage) || addUsage();
2596
+ return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
2520
2597
  })), false));
2521
2598
  return [2 /*return*/, {
2522
2599
  isSuccessful: true,
@@ -2842,7 +2919,7 @@ function preparePipeline(pipeline, options) {
2842
2919
  id: 1,
2843
2920
  // TODO: [🍥]> date: $currentDate(),
2844
2921
  promptbookVersion: PROMPTBOOK_VERSION,
2845
- modelUsage: addUsage(),
2922
+ modelUsage: ZERO_USAGE,
2846
2923
  };
2847
2924
  preparations = [
2848
2925
  // ...preparations
@@ -3477,16 +3554,12 @@ var jokerCommandParser = {
3477
3554
  },
3478
3555
  };
3479
3556
 
3480
- var MODEL_VARIANTS = ['COMPLETION', 'CHAT', 'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */];
3481
3557
  /**
3482
- * TODO: [🧠][🈁] `seed` should maybe be somewhere else (not in `ModelRequirements`) (simmilar that `user` identification is not here)
3483
- * TODO: [🧠][💱] Add more model options: `stop_token`, `logit_bias`, `logprobs` (`top_logprobs`), `top_k`, `top_p`, `presence_penalty`, `frequency_penalty`, `bestOf`, `logitBias`, `logitBiasType`,...
3484
- * [💱] Probbably keep using just `temperature` in Promptbook (not `top_k` and `top_p`)
3485
- * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
3486
- * TODO: Maybe figure out better word than "variant"
3487
- * TODO: Add here more requirement options like max context size, max tokens, etc.
3488
- * TODO: [💕][🧠] Just selecting gpt3 or gpt4 level of model
3558
+ * @@@
3559
+ *
3560
+ * @private for `ModelVariant` and `modelCommandParser`
3489
3561
  */
3562
+ var MODEL_VARIANTS = ['COMPLETION', 'CHAT', 'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */];
3490
3563
 
3491
3564
  /**
3492
3565
  * Parses the model command
@@ -5655,8 +5728,11 @@ var AnthropicClaudeExecutionTools = /** @class */ (function () {
5655
5728
  rawRequest = {
5656
5729
  model: modelRequirements.modelName || this.getDefaultChatModel().modelName,
5657
5730
  max_tokens: modelRequirements.maxTokens || 4096,
5658
- // <- TODO: Make some global max cap for maxTokens
5659
- // <- TODO: !!!!! Use here `systemMessage`, `temperature` and `seed`
5731
+ // <- TODO: [🌾] Make some global max cap for maxTokens
5732
+ temperature: modelRequirements.temperature,
5733
+ system: modelRequirements.systemMessage,
5734
+ // <- TODO: [🈁] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
5735
+ // <- Note: [🧆]
5660
5736
  messages: [
5661
5737
  {
5662
5738
  role: 'user',
@@ -5725,7 +5801,7 @@ var AnthropicClaudeExecutionTools = /** @class */ (function () {
5725
5801
  const modelSettings = {
5726
5802
  model: rawResponse.model || model,
5727
5803
  max_tokens: modelRequirements.maxTokens || 2000, // <- Note: 2000 is for lagacy reasons
5728
- // <- TODO: Make some global max cap for maxTokens
5804
+ // <- TODO: [🌾] Make some global max cap for maxTokens
5729
5805
  // <- TODO: Use here `systemMessage`, `temperature` and `seed`
5730
5806
  };
5731
5807
 
@@ -5781,13 +5857,13 @@ var AnthropicClaudeExecutionTools = /** @class */ (function () {
5781
5857
  AnthropicClaudeExecutionTools.prototype.getDefaultModel = function (defaultModelName) {
5782
5858
  var model = ANTHROPIC_CLAUDE_MODELS.find(function (_a) {
5783
5859
  var modelName = _a.modelName;
5784
- return modelName === defaultModelName;
5860
+ return modelName.startsWith(defaultModelName);
5785
5861
  });
5786
5862
  if (model === undefined) {
5787
5863
  throw new UnexpectedError(spaceTrim(function (block) {
5788
- return "\n Cannot find model in OpenAI models with name ".concat(defaultModelName, " which should be used as default.\n\n Available models:\n ").concat(block(ANTHROPIC_CLAUDE_MODELS.map(function (_a) {
5864
+ return "\n Cannot find model in OpenAI models with name \"".concat(defaultModelName, "\" which should be used as default.\n\n Available models:\n ").concat(block(ANTHROPIC_CLAUDE_MODELS.map(function (_a) {
5789
5865
  var modelName = _a.modelName;
5790
- return "- ".concat(modelName);
5866
+ return "- \"".concat(modelName, "\"");
5791
5867
  }).join('\n')), "\n\n ");
5792
5868
  }));
5793
5869
  }
@@ -6254,20 +6330,29 @@ var OpenAiExecutionTools = /** @class */ (function () {
6254
6330
  modelSettings = {
6255
6331
  model: model,
6256
6332
  max_tokens: modelRequirements.maxTokens,
6257
- // <- TODO: Make some global max cap for maxTokens
6258
- // <- TODO: !!!!! Use here `systemMessage`, `temperature` and `seed`
6333
+ // <- TODO: [🌾] Make some global max cap for maxTokens
6334
+ temperature: modelRequirements.temperature,
6335
+ // <- TODO: [🈁] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
6336
+ // <- Note: [🧆]
6259
6337
  };
6260
6338
  if (expectFormat === 'JSON') {
6261
6339
  modelSettings.response_format = {
6262
6340
  type: 'json_object',
6263
6341
  };
6264
6342
  }
6265
- rawRequest = __assign(__assign({}, modelSettings), { messages: [
6343
+ rawRequest = __assign(__assign({}, modelSettings), { messages: __spreadArray(__spreadArray([], __read((modelRequirements.systemMessage === undefined
6344
+ ? []
6345
+ : [
6346
+ {
6347
+ role: 'system',
6348
+ content: modelRequirements.systemMessage,
6349
+ },
6350
+ ])), false), [
6266
6351
  {
6267
6352
  role: 'user',
6268
6353
  content: content,
6269
6354
  },
6270
- ], user: this.options.user });
6355
+ ], false), user: this.options.user });
6271
6356
  start = getCurrentIsoDate();
6272
6357
  if (this.options.isVerbose) {
6273
6358
  console.info(colors.bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
@@ -6327,9 +6412,11 @@ var OpenAiExecutionTools = /** @class */ (function () {
6327
6412
  model = modelRequirements.modelName || this.getDefaultCompletionModel().modelName;
6328
6413
  modelSettings = {
6329
6414
  model: model,
6330
- max_tokens: modelRequirements.maxTokens || 2000, // <- Note: 2000 is for lagacy reasons
6331
- // <- TODO: Make some global max cap for maxTokens
6332
- // <- TODO: !!!!! Use here `systemMessage`, `temperature` and `seed`
6415
+ max_tokens: modelRequirements.maxTokens || 2000,
6416
+ // <- TODO: [🌾] Make some global max cap for maxTokens
6417
+ temperature: modelRequirements.temperature,
6418
+ // <- TODO: [🈁] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
6419
+ // <- Note: [🧆]
6333
6420
  };
6334
6421
  rawRequest = __assign(__assign({}, modelSettings), { prompt: content, user: this.options.user });
6335
6422
  start = getCurrentIsoDate();
@@ -6434,9 +6521,9 @@ var OpenAiExecutionTools = /** @class */ (function () {
6434
6521
  });
6435
6522
  if (model === undefined) {
6436
6523
  throw new UnexpectedError(spaceTrim(function (block) {
6437
- return "\n Cannot find model in OpenAI models with name ".concat(defaultModelName, " which should be used as default.\n\n Available models:\n ").concat(block(OPENAI_MODELS.map(function (_a) {
6524
+ return "\n Cannot find model in OpenAI models with name \"".concat(defaultModelName, "\" which should be used as default.\n\n Available models:\n ").concat(block(OPENAI_MODELS.map(function (_a) {
6438
6525
  var modelName = _a.modelName;
6439
- return "- ".concat(modelName);
6526
+ return "- \"".concat(modelName, "\"");
6440
6527
  }).join('\n')), "\n\n ");
6441
6528
  }));
6442
6529
  }
@@ -6486,7 +6573,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
6486
6573
  /**
6487
6574
  * @@@
6488
6575
  *
6489
- * Note: This function is not cached, every call creates new instance of LlmExecutionTools
6576
+ * Note: This function is not cached, every call creates new instance of `LlmExecutionTools`
6490
6577
  *
6491
6578
  * It looks for environment variables:
6492
6579
  * - `process.env.OPENAI_API_KEY`
@@ -6494,20 +6581,22 @@ var OpenAiExecutionTools = /** @class */ (function () {
6494
6581
  *
6495
6582
  * @returns @@@
6496
6583
  */
6497
- function createLlmToolsFromEnv() {
6584
+ function createLlmToolsFromEnv(options) {
6585
+ if (options === void 0) { options = {}; }
6498
6586
  if (!isRunningInNode()) {
6499
6587
  throw new EnvironmentMismatchError('Function `createLlmToolsFromEnv` works only in Node.js environment');
6500
6588
  }
6589
+ var _a = options.isVerbose, isVerbose = _a === void 0 ? false : _a;
6501
6590
  var llmTools = [];
6502
6591
  if (typeof process.env.OPENAI_API_KEY === 'string') {
6503
6592
  llmTools.push(new OpenAiExecutionTools({
6504
- isVerbose: true,
6593
+ isVerbose: isVerbose,
6505
6594
  apiKey: process.env.OPENAI_API_KEY,
6506
6595
  }));
6507
6596
  }
6508
6597
  if (typeof process.env.ANTHROPIC_CLAUDE_API_KEY === 'string') {
6509
6598
  llmTools.push(new AnthropicClaudeExecutionTools({
6510
- isVerbose: true,
6599
+ isVerbose: isVerbose,
6511
6600
  apiKey: process.env.ANTHROPIC_CLAUDE_API_KEY,
6512
6601
  }));
6513
6602
  }
@@ -6712,6 +6801,27 @@ function getLlmToolsForCli() {
6712
6801
  * Note: [🟡] This code should never be published outside of `@promptbook/cli`
6713
6802
  */
6714
6803
 
6804
+ /**
6805
+ * Stringify the PipelineJson with proper formatting
6806
+ *
6807
+ * Note: [0] It can be used for more JSON types like whole collection of pipelines, single knowledge piece, etc.
6808
+ * Note: In contrast to JSON.stringify, this function ensures that **embedding index** is on single line
6809
+ */
6810
+ function stringifyPipelineJson(pipeline) {
6811
+ var pipelineJsonStringified = JSON.stringify(pipeline, null, 4);
6812
+ for (var i = 0; i < LOOP_LIMIT; i++) {
6813
+ pipelineJsonStringified = pipelineJsonStringified.replace(/(-?0\.\d+),[\n\s]+(-?0\.\d+)/gms, "$1".concat(REPLACING_NONCE, "$2"));
6814
+ }
6815
+ pipelineJsonStringified = pipelineJsonStringified.split(REPLACING_NONCE).join(', ');
6816
+ pipelineJsonStringified += '\n';
6817
+ return pipelineJsonStringified;
6818
+ }
6819
+ /**
6820
+ * TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
6821
+ * TODO: [🔼] Export alongside pipelineStringToJson
6822
+ * TODO: [🧠] Maybe more elegant solution than replacing via regex
6823
+ */
6824
+
6715
6825
  /**
6716
6826
  * Initializes `make` command for Promptbook CLI utilities
6717
6827
  *
@@ -6818,7 +6928,7 @@ function initializeMakeCommand(program) {
6818
6928
  case 16: return [4 /*yield*/, collectionToJson(collection)];
6819
6929
  case 17:
6820
6930
  collectionJson = _f.sent();
6821
- collectionJsonString = JSON.stringify(collectionJson);
6931
+ collectionJsonString = stringifyPipelineJson(collectionJson);
6822
6932
  saveFile = function (extension, content) { return __awaiter(_this, void 0, void 0, function () {
6823
6933
  var filePath;
6824
6934
  return __generator(this, function (_a) {
@@ -6843,7 +6953,7 @@ function initializeMakeCommand(program) {
6843
6953
  });
6844
6954
  }); };
6845
6955
  if (!formats.includes('json')) return [3 /*break*/, 19];
6846
- return [4 /*yield*/, saveFile('json', collectionJsonString + '\n')];
6956
+ return [4 /*yield*/, saveFile('json', collectionJsonString)];
6847
6957
  case 18:
6848
6958
  _f.sent();
6849
6959
  _f.label = 19;