@promptbook/cli 0.61.0-12 → 0.61.0-13

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 (35) hide show
  1. package/esm/index.es.js +110 -37
  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/utils.index.d.ts +1 -1
  5. package/esm/typings/src/config.d.ts +1 -1
  6. package/esm/typings/src/errors/LimitReachedError.d.ts +7 -0
  7. package/esm/typings/src/execution/utils/addUsage.d.ts +57 -1
  8. package/esm/typings/src/llm-providers/_common/utils/count-total-cost/limitTotalCost.d.ts +32 -0
  9. package/esm/typings/src/utils/deepClone.d.ts +9 -0
  10. package/esm/typings/src/utils/deepFreeze.d.ts +13 -0
  11. package/esm/typings/src/utils/organization/just.d.ts +4 -1
  12. package/esm/typings/src/utils/organization/keepUnused.d.ts +16 -0
  13. package/esm/typings/src/version.d.ts +0 -3
  14. package/package.json +2 -2
  15. package/umd/index.umd.js +110 -37
  16. package/umd/index.umd.js.map +1 -1
  17. package/umd/typings/src/_packages/execute-javascript.index.d.ts +1 -1
  18. package/umd/typings/src/_packages/utils.index.d.ts +1 -1
  19. package/umd/typings/src/config.d.ts +1 -1
  20. package/umd/typings/src/errors/LimitReachedError.d.ts +7 -0
  21. package/umd/typings/src/execution/utils/addUsage.d.ts +57 -1
  22. package/umd/typings/src/llm-providers/_common/utils/count-total-cost/limitTotalCost.d.ts +32 -0
  23. package/umd/typings/src/utils/deepClone.d.ts +9 -0
  24. package/umd/typings/src/utils/deepFreeze.d.ts +13 -0
  25. package/umd/typings/src/utils/organization/just.d.ts +4 -1
  26. package/umd/typings/src/utils/organization/keepUnused.d.ts +16 -0
  27. package/umd/typings/src/version.d.ts +0 -3
  28. package/esm/typings/src/execution/addPromptResultUsage.test.d.ts +0 -1
  29. package/esm/typings/src/utils/organization/keepImported.d.ts +0 -12
  30. package/esm/typings/src/utils/organization/notUsing.d.ts +0 -12
  31. package/umd/typings/src/execution/addPromptResultUsage.test.d.ts +0 -1
  32. package/umd/typings/src/utils/organization/keepImported.d.ts +0 -12
  33. package/umd/typings/src/utils/organization/notUsing.d.ts +0 -12
  34. /package/esm/typings/src/{utils/postprocessing → postprocessing/utils}/extractBlock.d.ts +0 -0
  35. /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-12';
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,74 @@ 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
+ ]);
241
271
  /*
242
272
  TODO: !!! Just testing false-negative detection of [🟡][🟢][🔵][⚪] leak
243
273
  */
244
274
  // [🟡][🟢][🔵][⚪]
245
275
 
276
+ /**
277
+ * @@@
278
+ */
279
+ function deepClone(objectValue) {
280
+ return JSON.parse(JSON.stringify(objectValue));
281
+ /*
282
+ TODO: [🧠] Is there a better implementation?
283
+ > const propertyNames = Object.getOwnPropertyNames(objectValue);
284
+ > for (const propertyName of propertyNames) {
285
+ > const value = (objectValue as really_any)[propertyName];
286
+ > if (value && typeof value === 'object') {
287
+ > deepClone(value);
288
+ > }
289
+ > }
290
+ > return Object.assign({}, objectValue);
291
+ */
292
+ }
293
+ /**
294
+ * TODO: [🔼] Export from `@promptbook/utils`
295
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
296
+ */
297
+
298
+ /**
299
+ * @@@
300
+ *
301
+ * TODO: [🔼] Export with addUsage
302
+ */
303
+ var ZERO_USAGE = deepFreeze({
304
+ price: { value: 0 },
305
+ input: {
306
+ tokensCount: { value: 0 },
307
+ charactersCount: { value: 0 },
308
+ wordsCount: { value: 0 },
309
+ sentencesCount: { value: 0 },
310
+ linesCount: { value: 0 },
311
+ paragraphsCount: { value: 0 },
312
+ pagesCount: { value: 0 },
313
+ },
314
+ output: {
315
+ tokensCount: { value: 0 },
316
+ charactersCount: { value: 0 },
317
+ wordsCount: { value: 0 },
318
+ sentencesCount: { value: 0 },
319
+ linesCount: { value: 0 },
320
+ paragraphsCount: { value: 0 },
321
+ pagesCount: { value: 0 },
322
+ },
323
+ });
246
324
  /**
247
325
  * Function `addUsage` will add multiple usages into one
248
326
  *
249
- * Note: If you provide 0 values, it returns void usage
327
+ * Note: If you provide 0 values, it returns ZERO_USAGE
250
328
  */
251
329
  function addUsage() {
252
330
  var usageItems = [];
253
331
  for (var _i = 0; _i < arguments.length; _i++) {
254
332
  usageItems[_i] = arguments[_i];
255
333
  }
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
334
  return usageItems.reduce(function (acc, item) {
278
335
  var e_1, _a, e_2, _b;
279
336
  var _c;
@@ -331,7 +388,7 @@ function addUsage() {
331
388
  finally { if (e_2) throw e_2.error; }
332
389
  }
333
390
  return acc;
334
- }, initialStructure);
391
+ }, deepClone(ZERO_USAGE));
335
392
  }
336
393
 
337
394
  /**
@@ -408,7 +465,7 @@ function forEachAsync(array, options, callbackfunction) {
408
465
  });
409
466
  }
410
467
 
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"}];
468
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-12",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-12",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-12",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-12",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-12",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-12",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-12",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-12",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
469
 
413
470
  /**
414
471
  * Prettify the html code
@@ -988,6 +1045,7 @@ function validatePipeline(pipeline) {
988
1045
  var loopLimit = LOOP_LIMIT;
989
1046
  var _loop_2 = function () {
990
1047
  if (loopLimit-- < 0) {
1048
+ // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
991
1049
  throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `validatePipeline`');
992
1050
  }
993
1051
  var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
@@ -1937,6 +1995,20 @@ function checkExpectations(expectations, value) {
1937
1995
  * TODO: [💝] Unite object for expecting amount and format
1938
1996
  */
1939
1997
 
1998
+ /**
1999
+ * This error type indicates that some limit was reached
2000
+ */
2001
+ var LimitReachedError = /** @class */ (function (_super) {
2002
+ __extends(LimitReachedError, _super);
2003
+ function LimitReachedError(message) {
2004
+ var _this = _super.call(this, message) || this;
2005
+ _this.name = 'LimitReachedError';
2006
+ Object.setPrototypeOf(_this, LimitReachedError.prototype);
2007
+ return _this;
2008
+ }
2009
+ return LimitReachedError;
2010
+ }(Error));
2011
+
1940
2012
  /**
1941
2013
  * Replaces parameters in template with values from parameters object
1942
2014
  *
@@ -1953,7 +2025,7 @@ function replaceParameters(template, parameters) {
1953
2025
  var loopLimit = LOOP_LIMIT;
1954
2026
  var _loop_1 = function () {
1955
2027
  if (loopLimit-- < 0) {
1956
- throw new UnexpectedError('Loop limit reached during parameters replacement in `replaceParameters`');
2028
+ throw new LimitReachedError('Loop limit reached during parameters replacement in `replaceParameters`');
1957
2029
  }
1958
2030
  var precol = match.groups.precol;
1959
2031
  var parameterName = match.groups.parameterName;
@@ -2441,6 +2513,7 @@ function createPipelineExecutor(options) {
2441
2513
  switch (_e.label) {
2442
2514
  case 0:
2443
2515
  if (loopLimit-- < 0) {
2516
+ // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
2444
2517
  throw new UnexpectedError('Loop limit reached during resolving parameters pipeline execution');
2445
2518
  }
2446
2519
  currentTemplate = unresovedTemplates.find(function (template) {
@@ -2487,7 +2560,7 @@ function createPipelineExecutor(options) {
2487
2560
  }
2488
2561
  usage_1 = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
2489
2562
  var result = _a.result;
2490
- return (result === null || result === void 0 ? void 0 : result.usage) || addUsage();
2563
+ return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
2491
2564
  })), false));
2492
2565
  return [2 /*return*/, {
2493
2566
  isSuccessful: false,
@@ -2516,7 +2589,7 @@ function createPipelineExecutor(options) {
2516
2589
  }
2517
2590
  usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
2518
2591
  var result = _a.result;
2519
- return (result === null || result === void 0 ? void 0 : result.usage) || addUsage();
2592
+ return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
2520
2593
  })), false));
2521
2594
  return [2 /*return*/, {
2522
2595
  isSuccessful: true,
@@ -2842,7 +2915,7 @@ function preparePipeline(pipeline, options) {
2842
2915
  id: 1,
2843
2916
  // TODO: [🍥]> date: $currentDate(),
2844
2917
  promptbookVersion: PROMPTBOOK_VERSION,
2845
- modelUsage: addUsage(),
2918
+ modelUsage: ZERO_USAGE,
2846
2919
  };
2847
2920
  preparations = [
2848
2921
  // ...preparations
@@ -5656,7 +5729,7 @@ var AnthropicClaudeExecutionTools = /** @class */ (function () {
5656
5729
  model: modelRequirements.modelName || this.getDefaultChatModel().modelName,
5657
5730
  max_tokens: modelRequirements.maxTokens || 4096,
5658
5731
  // <- TODO: Make some global max cap for maxTokens
5659
- // <- TODO: !!!!! Use here `systemMessage`, `temperature` and `seed`
5732
+ // <- TODO: !!!!!! Use here `systemMessage`, `temperature` and `seed`
5660
5733
  messages: [
5661
5734
  {
5662
5735
  role: 'user',
@@ -6255,7 +6328,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
6255
6328
  model: model,
6256
6329
  max_tokens: modelRequirements.maxTokens,
6257
6330
  // <- TODO: Make some global max cap for maxTokens
6258
- // <- TODO: !!!!! Use here `systemMessage`, `temperature` and `seed`
6331
+ // <- TODO: !!!!!! Use here `systemMessage`, `temperature` and `seed`
6259
6332
  };
6260
6333
  if (expectFormat === 'JSON') {
6261
6334
  modelSettings.response_format = {
@@ -6329,7 +6402,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
6329
6402
  model: model,
6330
6403
  max_tokens: modelRequirements.maxTokens || 2000, // <- Note: 2000 is for lagacy reasons
6331
6404
  // <- TODO: Make some global max cap for maxTokens
6332
- // <- TODO: !!!!! Use here `systemMessage`, `temperature` and `seed`
6405
+ // <- TODO: !!!!!! Use here `systemMessage`, `temperature` and `seed`
6333
6406
  };
6334
6407
  rawRequest = __assign(__assign({}, modelSettings), { prompt: content, user: this.options.user });
6335
6408
  start = getCurrentIsoDate();