@promptbook/node 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 +107 -34
  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 +107 -34
  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
@@ -124,6 +124,39 @@ function __spreadArray(to, from, pack) {
124
124
  return to.concat(ar || Array.prototype.slice.call(from));
125
125
  }
126
126
 
127
+ /**
128
+ * @@@
129
+ *
130
+ * @returns The same object as the input, but deeply frozen
131
+ *
132
+ * Note: This function mutates the object
133
+ */
134
+ function deepFreeze(objectValue) {
135
+ var e_1, _a;
136
+ var propertyNames = Object.getOwnPropertyNames(objectValue);
137
+ try {
138
+ for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
139
+ var propertyName = propertyNames_1_1.value;
140
+ var value = objectValue[propertyName];
141
+ if (value && typeof value === 'object') {
142
+ deepFreeze(value);
143
+ }
144
+ }
145
+ }
146
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
147
+ finally {
148
+ try {
149
+ if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
150
+ }
151
+ finally { if (e_1) throw e_1.error; }
152
+ }
153
+ return Object.freeze(objectValue);
154
+ }
155
+ /**
156
+ * TODO: [🔼] Export from `@promptbook/utils`
157
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
158
+ */
159
+
127
160
  /**
128
161
  * The maximum number of iterations for a loops
129
162
  */
@@ -139,47 +172,74 @@ var PIPELINE_COLLECTION_BASE_FILENAME = "index";
139
172
  /**
140
173
  * The names of the parameters that are reserved for special purposes
141
174
  */
142
- var RESERVED_PARAMETER_NAMES = [
175
+ var RESERVED_PARAMETER_NAMES = deepFreeze([
143
176
  'context',
144
177
  // <- TODO: Add more like 'date', 'modelName',...
145
178
  // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
146
- ];
179
+ ]);
147
180
  /*
148
181
  TODO: !!! Just testing false-negative detection of [🟡][🟢][🔵][⚪] leak
149
182
  */
150
183
  // [🟡][🟢][🔵][⚪]
151
184
 
185
+ /**
186
+ * @@@
187
+ */
188
+ function deepClone(objectValue) {
189
+ return JSON.parse(JSON.stringify(objectValue));
190
+ /*
191
+ TODO: [🧠] Is there a better implementation?
192
+ > const propertyNames = Object.getOwnPropertyNames(objectValue);
193
+ > for (const propertyName of propertyNames) {
194
+ > const value = (objectValue as really_any)[propertyName];
195
+ > if (value && typeof value === 'object') {
196
+ > deepClone(value);
197
+ > }
198
+ > }
199
+ > return Object.assign({}, objectValue);
200
+ */
201
+ }
202
+ /**
203
+ * TODO: [🔼] Export from `@promptbook/utils`
204
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
205
+ */
206
+
207
+ /**
208
+ * @@@
209
+ *
210
+ * TODO: [🔼] Export with addUsage
211
+ */
212
+ var ZERO_USAGE = deepFreeze({
213
+ price: { value: 0 },
214
+ input: {
215
+ tokensCount: { value: 0 },
216
+ charactersCount: { value: 0 },
217
+ wordsCount: { value: 0 },
218
+ sentencesCount: { value: 0 },
219
+ linesCount: { value: 0 },
220
+ paragraphsCount: { value: 0 },
221
+ pagesCount: { value: 0 },
222
+ },
223
+ output: {
224
+ tokensCount: { value: 0 },
225
+ charactersCount: { value: 0 },
226
+ wordsCount: { value: 0 },
227
+ sentencesCount: { value: 0 },
228
+ linesCount: { value: 0 },
229
+ paragraphsCount: { value: 0 },
230
+ pagesCount: { value: 0 },
231
+ },
232
+ });
152
233
  /**
153
234
  * Function `addUsage` will add multiple usages into one
154
235
  *
155
- * Note: If you provide 0 values, it returns void usage
236
+ * Note: If you provide 0 values, it returns ZERO_USAGE
156
237
  */
157
238
  function addUsage() {
158
239
  var usageItems = [];
159
240
  for (var _i = 0; _i < arguments.length; _i++) {
160
241
  usageItems[_i] = arguments[_i];
161
242
  }
162
- var initialStructure = {
163
- price: { value: 0 },
164
- input: {
165
- tokensCount: { value: 0 },
166
- charactersCount: { value: 0 },
167
- wordsCount: { value: 0 },
168
- sentencesCount: { value: 0 },
169
- linesCount: { value: 0 },
170
- paragraphsCount: { value: 0 },
171
- pagesCount: { value: 0 },
172
- },
173
- output: {
174
- tokensCount: { value: 0 },
175
- charactersCount: { value: 0 },
176
- wordsCount: { value: 0 },
177
- sentencesCount: { value: 0 },
178
- linesCount: { value: 0 },
179
- paragraphsCount: { value: 0 },
180
- pagesCount: { value: 0 },
181
- },
182
- };
183
243
  return usageItems.reduce(function (acc, item) {
184
244
  var e_1, _a, e_2, _b;
185
245
  var _c;
@@ -237,7 +297,7 @@ function addUsage() {
237
297
  finally { if (e_2) throw e_2.error; }
238
298
  }
239
299
  return acc;
240
- }, initialStructure);
300
+ }, deepClone(ZERO_USAGE));
241
301
  }
242
302
 
243
303
  /**
@@ -314,7 +374,7 @@ function forEachAsync(array, options, callbackfunction) {
314
374
  });
315
375
  }
316
376
 
317
- 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"}];
377
+ 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"}];
318
378
 
319
379
  /**
320
380
  * Prettify the html code
@@ -894,6 +954,7 @@ function validatePipeline(pipeline) {
894
954
  var loopLimit = LOOP_LIMIT;
895
955
  var _loop_2 = function () {
896
956
  if (loopLimit-- < 0) {
957
+ // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
897
958
  throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `validatePipeline`');
898
959
  }
899
960
  var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
@@ -1736,11 +1797,8 @@ function arrayableToArray(input) {
1736
1797
  /**
1737
1798
  * The version of the Promptbook library
1738
1799
  */
1739
- var PROMPTBOOK_VERSION = '0.61.0-11';
1800
+ var PROMPTBOOK_VERSION = '0.61.0-12';
1740
1801
  // TODO: !!!! List here all the versions and annotate + put into script
1741
- /**
1742
- * TODO: [🔼] !!! Export via `@promptbook/code`
1743
- */
1744
1802
 
1745
1803
  /**
1746
1804
  * Counts number of characters in the text
@@ -1852,6 +1910,20 @@ function checkExpectations(expectations, value) {
1852
1910
  * TODO: [💝] Unite object for expecting amount and format
1853
1911
  */
1854
1912
 
1913
+ /**
1914
+ * This error type indicates that some limit was reached
1915
+ */
1916
+ var LimitReachedError = /** @class */ (function (_super) {
1917
+ __extends(LimitReachedError, _super);
1918
+ function LimitReachedError(message) {
1919
+ var _this = _super.call(this, message) || this;
1920
+ _this.name = 'LimitReachedError';
1921
+ Object.setPrototypeOf(_this, LimitReachedError.prototype);
1922
+ return _this;
1923
+ }
1924
+ return LimitReachedError;
1925
+ }(Error));
1926
+
1855
1927
  /**
1856
1928
  * Replaces parameters in template with values from parameters object
1857
1929
  *
@@ -1868,7 +1940,7 @@ function replaceParameters(template, parameters) {
1868
1940
  var loopLimit = LOOP_LIMIT;
1869
1941
  var _loop_1 = function () {
1870
1942
  if (loopLimit-- < 0) {
1871
- throw new UnexpectedError('Loop limit reached during parameters replacement in `replaceParameters`');
1943
+ throw new LimitReachedError('Loop limit reached during parameters replacement in `replaceParameters`');
1872
1944
  }
1873
1945
  var precol = match.groups.precol;
1874
1946
  var parameterName = match.groups.parameterName;
@@ -2356,6 +2428,7 @@ function createPipelineExecutor(options) {
2356
2428
  switch (_e.label) {
2357
2429
  case 0:
2358
2430
  if (loopLimit-- < 0) {
2431
+ // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
2359
2432
  throw new UnexpectedError('Loop limit reached during resolving parameters pipeline execution');
2360
2433
  }
2361
2434
  currentTemplate = unresovedTemplates.find(function (template) {
@@ -2402,7 +2475,7 @@ function createPipelineExecutor(options) {
2402
2475
  }
2403
2476
  usage_1 = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
2404
2477
  var result = _a.result;
2405
- return (result === null || result === void 0 ? void 0 : result.usage) || addUsage();
2478
+ return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
2406
2479
  })), false));
2407
2480
  return [2 /*return*/, {
2408
2481
  isSuccessful: false,
@@ -2431,7 +2504,7 @@ function createPipelineExecutor(options) {
2431
2504
  }
2432
2505
  usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
2433
2506
  var result = _a.result;
2434
- return (result === null || result === void 0 ? void 0 : result.usage) || addUsage();
2507
+ return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
2435
2508
  })), false));
2436
2509
  return [2 /*return*/, {
2437
2510
  isSuccessful: true,
@@ -2757,7 +2830,7 @@ function preparePipeline(pipeline, options) {
2757
2830
  id: 1,
2758
2831
  // TODO: [🍥]> date: $currentDate(),
2759
2832
  promptbookVersion: PROMPTBOOK_VERSION,
2760
- modelUsage: addUsage(),
2833
+ modelUsage: ZERO_USAGE,
2761
2834
  };
2762
2835
  preparations = [
2763
2836
  // ...preparations