@promptbook/core 0.70.0-1 β†’ 0.72.0-0

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 (51) hide show
  1. package/README.md +21 -57
  2. package/esm/index.es.js +260 -277
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/promptbook-collection/index.d.ts +0 -3
  5. package/esm/typings/src/_packages/core.index.d.ts +4 -2
  6. package/esm/typings/src/_packages/openai.index.d.ts +4 -0
  7. package/esm/typings/src/_packages/types.index.d.ts +2 -0
  8. package/esm/typings/src/cli/cli-commands/make.d.ts +1 -1
  9. package/esm/typings/src/collection/constructors/createCollectionFromUrl.d.ts +1 -1
  10. package/esm/typings/src/commands/FOREACH/ForeachCommand.d.ts +1 -6
  11. package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +1 -2
  12. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +1 -16
  13. package/esm/typings/src/config.d.ts +2 -2
  14. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +1 -1
  15. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +5 -5
  16. package/esm/typings/src/execution/createPipelineExecutor.d.ts +1 -1
  17. package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +1 -1
  18. package/esm/typings/src/execution/utils/addUsage.d.ts +0 -56
  19. package/esm/typings/src/execution/utils/usage-constants.d.ts +127 -0
  20. package/esm/typings/src/knowledge/dialogs/callback/CallbackInterfaceTools.d.ts +1 -1
  21. package/esm/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +1 -1
  22. package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +1 -1
  23. package/esm/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +1 -1
  24. package/esm/typings/src/llm-providers/_common/utils/cache/CacheItem.d.ts +1 -1
  25. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +3 -2
  26. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  27. package/esm/typings/src/llm-providers/anthropic-claude/createAnthropicClaudeExecutionTools.d.ts +2 -2
  28. package/esm/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +2 -2
  29. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +3 -2
  30. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
  31. package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
  32. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +37 -0
  33. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +14 -0
  34. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +3 -2
  35. package/esm/typings/src/llm-providers/openai/playground/playground.d.ts +1 -1
  36. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
  37. package/esm/typings/src/personas/preparePersona.d.ts +1 -1
  38. package/esm/typings/src/prepare/isPipelinePrepared.d.ts +1 -1
  39. package/esm/typings/src/prepare/prepareTemplates.d.ts +1 -1
  40. package/esm/typings/src/scripting/javascript/JavascriptEvalExecutionTools.d.ts +1 -1
  41. package/esm/typings/src/scripting/python/PythonExecutionTools.d.ts +1 -1
  42. package/esm/typings/src/scripting/typescript/TypescriptExecutionTools.d.ts +1 -1
  43. package/esm/typings/src/storage/files-storage/FilesStorage.d.ts +1 -1
  44. package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +1 -1
  45. package/esm/typings/src/types/typeAliases.d.ts +1 -1
  46. package/esm/typings/src/utils/serialization/checkSerializableAsJson.d.ts +1 -1
  47. package/esm/typings/src/utils/serialization/isSerializableAsJson.d.ts +1 -1
  48. package/package.json +1 -1
  49. package/umd/index.umd.js +260 -276
  50. package/umd/index.umd.js.map +1 -1
  51. package/esm/typings/src/personas/preparePersona.test.d.ts +0 -1
package/umd/index.umd.js CHANGED
@@ -16,8 +16,8 @@
16
16
  /**
17
17
  * The version of the Promptbook library
18
18
  */
19
- var PROMPTBOOK_VERSION = '0.70.0-0';
20
- // TODO: !!!! List here all the versions and annotate + put into script
19
+ var PROMPTBOOK_VERSION = '0.68.5';
20
+ // TODO:[main] !!!! List here all the versions and annotate + put into script
21
21
 
22
22
  /*! *****************************************************************************
23
23
  Copyright (c) Microsoft Corporation.
@@ -229,7 +229,7 @@
229
229
  commands.push("PIPELINE URL ".concat(pipelineUrl));
230
230
  }
231
231
  commands.push("PROMPTBOOK VERSION ".concat(promptbookVersion));
232
- // TODO: !!! This increase size of the bundle and is probbably not necessary
232
+ // TODO:[main] !!! This increase size of the bundle and is probbably not necessary
233
233
  pipelineString = prettifyMarkdown(pipelineString);
234
234
  try {
235
235
  for (var _g = __values(parameters.filter(function (_a) {
@@ -377,12 +377,12 @@
377
377
  pipelineString += '```' + contentLanguage;
378
378
  pipelineString += '\n';
379
379
  pipelineString += spaceTrim__default["default"](content);
380
- // <- TODO: !!! Escape
380
+ // <- TODO:[main] !!! Escape
381
381
  // <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
382
382
  pipelineString += '\n';
383
383
  pipelineString += '```';
384
384
  pipelineString += '\n\n';
385
- pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: !!! If the parameter here has description, add it and use templateParameterJsonToString
385
+ pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO:[main] !!! If the parameter here has description, add it and use templateParameterJsonToString
386
386
  }
387
387
  }
388
388
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
@@ -602,7 +602,7 @@
602
602
  }
603
603
  /**
604
604
  * TODO: [🧠][πŸ›£] More elegant way to tracking than passing `name`
605
- * TODO: [🧠] !!! In-memory cache of same values to prevent multiple checks
605
+ * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
606
606
  * Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
607
607
  */
608
608
 
@@ -673,14 +673,14 @@
673
673
  var MAX_FILENAME_LENGTH = 30;
674
674
  /**
675
675
  * @@@
676
- * TODO: [🐝] !!! Use
676
+ * TODO: [🐝][main] !!! Use
677
677
  *
678
678
  * @public exported from `@promptbook/core`
679
679
  */
680
680
  var MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH = 3;
681
681
  /**
682
682
  * @@@
683
- * TODO: [🐝] !!! Use
683
+ * TODO: [🐝][main] !!! Use
684
684
  *
685
685
  * @public exported from `@promptbook/core`
686
686
  */
@@ -835,7 +835,7 @@
835
835
  if ( /* version === '1.0.0' || */version === '2.0.0' || version === '3.0.0') {
836
836
  return false;
837
837
  }
838
- // <- TODO: !!! Check isValidPromptbookVersion against PROMPTBOOK_VERSIONS
838
+ // <- TODO:[main] !!! Check isValidPromptbookVersion against PROMPTBOOK_VERSIONS
839
839
  return true;
840
840
  }
841
841
 
@@ -984,7 +984,7 @@
984
984
  // <- Note: [🚲]
985
985
  throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
986
986
  }
987
- if (!isValidPromptbookVersion(pipeline.promptbookVersion)) {
987
+ if (pipeline.promptbookVersion !== undefined && !isValidPromptbookVersion(pipeline.promptbookVersion)) {
988
988
  // <- Note: [🚲]
989
989
  throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.promptbookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
990
990
  }
@@ -1179,11 +1179,11 @@
1179
1179
  * > ex port function validatePipeline(promptbook: really_unknown): asserts promptbook is PipelineJson {
1180
1180
  */
1181
1181
  /**
1182
- * TODO: [🐣] !!!! Validate that all samples match expectations
1183
- * TODO: [🐣][🐝] !!!! Validate that knowledge is valid (non-void)
1184
- * TODO: [🐣] !!!! Validate that persona can be used only with CHAT variant
1185
- * TODO: [🐣] !!!! Validate that parameter with reserved name not used RESERVED_PARAMETER_NAMES
1186
- * TODO: [🐣] !!!! Validate that reserved parameter is not used as joker
1182
+ * TODO: [🐣][main] !!!! Validate that all samples match expectations
1183
+ * TODO: [🐣][🐝][main] !!!! Validate that knowledge is valid (non-void)
1184
+ * TODO: [🐣][main] !!!! Validate that persona can be used only with CHAT variant
1185
+ * TODO: [🐣][main] !!!! Validate that parameter with reserved name not used RESERVED_PARAMETER_NAMES
1186
+ * TODO: [🐣][main] !!!! Validate that reserved parameter is not used as joker
1187
1187
  * TODO: [🧠] Validation not only logic itself but imports around - files and websites and rerefenced pipelines exists
1188
1188
  * TODO: [πŸ› ] Actions, instruments (and maybe knowledge) => Functions and tools
1189
1189
  */
@@ -1497,7 +1497,7 @@
1497
1497
  });
1498
1498
  }
1499
1499
  /**
1500
- * TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
1500
+ * TODO:[main] !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
1501
1501
  */
1502
1502
 
1503
1503
  /**
@@ -1598,127 +1598,6 @@
1598
1598
  // <- [πŸ…±]
1599
1599
  ];
1600
1600
 
1601
- /**
1602
- * @@@
1603
- *
1604
- * @public exported from `@promptbook/utils`
1605
- */
1606
- function deepClone(objectValue) {
1607
- return JSON.parse(JSON.stringify(objectValue));
1608
- /*
1609
- TODO: [🧠] Is there a better implementation?
1610
- > const propertyNames = Object.getOwnPropertyNames(objectValue);
1611
- > for (const propertyName of propertyNames) {
1612
- > const value = (objectValue as really_any)[propertyName];
1613
- > if (value && typeof value === 'object') {
1614
- > deepClone(value);
1615
- > }
1616
- > }
1617
- > return Object.assign({}, objectValue);
1618
- */
1619
- }
1620
- /**
1621
- * TODO: [🧠] Is there a way how to meaningfully test this utility
1622
- */
1623
-
1624
- /**
1625
- * @@@
1626
- *
1627
- * @public exported from `@promptbook/core`
1628
- */
1629
- var ZERO_USAGE = $deepFreeze({
1630
- price: { value: 0 },
1631
- input: {
1632
- tokensCount: { value: 0 },
1633
- charactersCount: { value: 0 },
1634
- wordsCount: { value: 0 },
1635
- sentencesCount: { value: 0 },
1636
- linesCount: { value: 0 },
1637
- paragraphsCount: { value: 0 },
1638
- pagesCount: { value: 0 },
1639
- },
1640
- output: {
1641
- tokensCount: { value: 0 },
1642
- charactersCount: { value: 0 },
1643
- wordsCount: { value: 0 },
1644
- sentencesCount: { value: 0 },
1645
- linesCount: { value: 0 },
1646
- paragraphsCount: { value: 0 },
1647
- pagesCount: { value: 0 },
1648
- },
1649
- });
1650
- /**
1651
- * Function `addUsage` will add multiple usages into one
1652
- *
1653
- * Note: If you provide 0 values, it returns ZERO_USAGE
1654
- *
1655
- * @public exported from `@promptbook/core`
1656
- */
1657
- function addUsage() {
1658
- var usageItems = [];
1659
- for (var _i = 0; _i < arguments.length; _i++) {
1660
- usageItems[_i] = arguments[_i];
1661
- }
1662
- return usageItems.reduce(function (acc, item) {
1663
- var e_1, _a, e_2, _b;
1664
- var _c;
1665
- acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
1666
- try {
1667
- for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
1668
- var key = _e.value;
1669
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1670
- //@ts-ignore
1671
- if (item.input[key]) {
1672
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1673
- //@ts-ignore
1674
- acc.input[key].value += item.input[key].value || 0;
1675
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1676
- //@ts-ignore
1677
- if (item.input[key].isUncertain) {
1678
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1679
- //@ts-ignore
1680
- acc.input[key].isUncertain = true;
1681
- }
1682
- }
1683
- }
1684
- }
1685
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1686
- finally {
1687
- try {
1688
- if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
1689
- }
1690
- finally { if (e_1) throw e_1.error; }
1691
- }
1692
- try {
1693
- for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
1694
- var key = _g.value;
1695
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1696
- //@ts-ignore
1697
- if (item.output[key]) {
1698
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1699
- //@ts-ignore
1700
- acc.output[key].value += item.output[key].value || 0;
1701
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1702
- //@ts-ignore
1703
- if (item.output[key].isUncertain) {
1704
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1705
- //@ts-ignore
1706
- acc.output[key].isUncertain = true;
1707
- }
1708
- }
1709
- }
1710
- }
1711
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1712
- finally {
1713
- try {
1714
- if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
1715
- }
1716
- finally { if (e_2) throw e_2.error; }
1717
- }
1718
- return acc;
1719
- }, deepClone(ZERO_USAGE));
1720
- }
1721
-
1722
1601
  /**
1723
1602
  * Async version of Array.forEach
1724
1603
  *
@@ -1794,7 +1673,60 @@
1794
1673
  });
1795
1674
  }
1796
1675
 
1797
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.70.0-0",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.70.0-0",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.70.0-0",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.70.0-0",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}],templates:[{templateType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",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- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `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### Key `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",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
1676
+ /**
1677
+ * Represents the usage with no resources consumed
1678
+ *
1679
+ * @public exported from `@promptbook/core`
1680
+ */
1681
+ var ZERO_USAGE = $deepFreeze({
1682
+ price: { value: 0 },
1683
+ input: {
1684
+ tokensCount: { value: 0 },
1685
+ charactersCount: { value: 0 },
1686
+ wordsCount: { value: 0 },
1687
+ sentencesCount: { value: 0 },
1688
+ linesCount: { value: 0 },
1689
+ paragraphsCount: { value: 0 },
1690
+ pagesCount: { value: 0 },
1691
+ },
1692
+ output: {
1693
+ tokensCount: { value: 0 },
1694
+ charactersCount: { value: 0 },
1695
+ wordsCount: { value: 0 },
1696
+ sentencesCount: { value: 0 },
1697
+ linesCount: { value: 0 },
1698
+ paragraphsCount: { value: 0 },
1699
+ pagesCount: { value: 0 },
1700
+ },
1701
+ });
1702
+ /**
1703
+ * Represents the usage with unknown resources consumed
1704
+ *
1705
+ * @public exported from `@promptbook/core`
1706
+ */
1707
+ var UNCERTAIN_USAGE = $deepFreeze({
1708
+ price: { value: 0, isUncertain: true },
1709
+ input: {
1710
+ tokensCount: { value: 0, isUncertain: true },
1711
+ charactersCount: { value: 0, isUncertain: true },
1712
+ wordsCount: { value: 0, isUncertain: true },
1713
+ sentencesCount: { value: 0, isUncertain: true },
1714
+ linesCount: { value: 0, isUncertain: true },
1715
+ paragraphsCount: { value: 0, isUncertain: true },
1716
+ pagesCount: { value: 0, isUncertain: true },
1717
+ },
1718
+ output: {
1719
+ tokensCount: { value: 0, isUncertain: true },
1720
+ charactersCount: { value: 0, isUncertain: true },
1721
+ wordsCount: { value: 0, isUncertain: true },
1722
+ sentencesCount: { value: 0, isUncertain: true },
1723
+ linesCount: { value: 0, isUncertain: true },
1724
+ paragraphsCount: { value: 0, isUncertain: true },
1725
+ pagesCount: { value: 0, isUncertain: true },
1726
+ },
1727
+ });
1728
+
1729
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",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}],templates:[{templateType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",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- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `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### Key `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",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
1798
1730
 
1799
1731
  var defaultDiacriticsRemovalMap = [
1800
1732
  {
@@ -2902,7 +2834,7 @@
2902
2834
  return true;
2903
2835
  }
2904
2836
  /**
2905
- * TODO: [πŸ”ƒ] !!!!! If the pipeline was prepared with different version or different set of models, prepare it once again
2837
+ * TODO: [πŸ”ƒ][main] !!!!! If the pipeline was prepared with different version or different set of models, prepare it once again
2906
2838
  * TODO: [🐠] Maybe base this on `makeValidator`
2907
2839
  * TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
2908
2840
  * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
@@ -3122,6 +3054,101 @@
3122
3054
  return union;
3123
3055
  }
3124
3056
 
3057
+ /**
3058
+ * @@@
3059
+ *
3060
+ * @public exported from `@promptbook/utils`
3061
+ */
3062
+ function deepClone(objectValue) {
3063
+ return JSON.parse(JSON.stringify(objectValue));
3064
+ /*
3065
+ TODO: [🧠] Is there a better implementation?
3066
+ > const propertyNames = Object.getOwnPropertyNames(objectValue);
3067
+ > for (const propertyName of propertyNames) {
3068
+ > const value = (objectValue as really_any)[propertyName];
3069
+ > if (value && typeof value === 'object') {
3070
+ > deepClone(value);
3071
+ > }
3072
+ > }
3073
+ > return Object.assign({}, objectValue);
3074
+ */
3075
+ }
3076
+ /**
3077
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
3078
+ */
3079
+
3080
+ /**
3081
+ * Function `addUsage` will add multiple usages into one
3082
+ *
3083
+ * Note: If you provide 0 values, it returns ZERO_USAGE
3084
+ *
3085
+ * @public exported from `@promptbook/core`
3086
+ */
3087
+ function addUsage() {
3088
+ var usageItems = [];
3089
+ for (var _i = 0; _i < arguments.length; _i++) {
3090
+ usageItems[_i] = arguments[_i];
3091
+ }
3092
+ return usageItems.reduce(function (acc, item) {
3093
+ var e_1, _a, e_2, _b;
3094
+ var _c;
3095
+ acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
3096
+ try {
3097
+ for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
3098
+ var key = _e.value;
3099
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3100
+ //@ts-ignore
3101
+ if (item.input[key]) {
3102
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3103
+ //@ts-ignore
3104
+ acc.input[key].value += item.input[key].value || 0;
3105
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3106
+ //@ts-ignore
3107
+ if (item.input[key].isUncertain) {
3108
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3109
+ //@ts-ignore
3110
+ acc.input[key].isUncertain = true;
3111
+ }
3112
+ }
3113
+ }
3114
+ }
3115
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
3116
+ finally {
3117
+ try {
3118
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
3119
+ }
3120
+ finally { if (e_1) throw e_1.error; }
3121
+ }
3122
+ try {
3123
+ for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
3124
+ var key = _g.value;
3125
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3126
+ //@ts-ignore
3127
+ if (item.output[key]) {
3128
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3129
+ //@ts-ignore
3130
+ acc.output[key].value += item.output[key].value || 0;
3131
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3132
+ //@ts-ignore
3133
+ if (item.output[key].isUncertain) {
3134
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3135
+ //@ts-ignore
3136
+ acc.output[key].isUncertain = true;
3137
+ }
3138
+ }
3139
+ }
3140
+ }
3141
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
3142
+ finally {
3143
+ try {
3144
+ if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
3145
+ }
3146
+ finally { if (e_2) throw e_2.error; }
3147
+ }
3148
+ return acc;
3149
+ }, deepClone(ZERO_USAGE));
3150
+ }
3151
+
3125
3152
  /**
3126
3153
  * Counts number of characters in the text
3127
3154
  *
@@ -3303,7 +3330,7 @@
3303
3330
  console.warn(spaceTrim.spaceTrim(function (block) { return "\n Pipeline is not prepared\n\n ".concat(block(pipelineIdentification), "\n\n It will be prepared ad-hoc before the first execution and **returned as `preparedPipeline` in `PipelineExecutorResult`**\n But it is recommended to prepare the pipeline during collection preparation\n\n @see more at https://ptbk.io/prepare-pipeline\n "); }));
3304
3331
  }
3305
3332
  var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
3306
- // TODO: !!! Extract to separate functions and files - ALL FUNCTIONS BELOW
3333
+ // TODO:[main] !!! Extract to separate functions and files - ALL FUNCTIONS BELOW
3307
3334
  function getContextForTemplate(template) {
3308
3335
  return __awaiter(this, void 0, void 0, function () {
3309
3336
  return __generator(this, function (_a) {
@@ -4122,7 +4149,7 @@
4122
4149
  return pipelineExecutor;
4123
4150
  }
4124
4151
  /**
4125
- * TODO: !!! Identify not only pipeline BUT exact template ${block(pipelineIdentification)}
4152
+ * TODO:[main] !!! Identify not only pipeline BUT exact template ${block(pipelineIdentification)}
4126
4153
  * TODO: Use isVerbose here (not only pass to `preparePipeline`)
4127
4154
  * TODO: [🧠][🌳] Use here `countTotalUsage` and put preparation and prepared pipiline to report
4128
4155
  * TODO: [πŸͺ‚] Use maxParallelCount here (not only pass to `preparePipeline`)
@@ -4185,7 +4212,7 @@
4185
4212
  outputParameters = result.outputParameters;
4186
4213
  knowledgePiecesRaw = outputParameters.knowledgePieces;
4187
4214
  knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
4188
- // <- TODO: !!!!! Smarter split and filter out empty pieces
4215
+ // <- TODO:[main] !!!!! Smarter split and filter out empty pieces
4189
4216
  if (isVerbose) {
4190
4217
  console.info('knowledgeTextPieces:', knowledgeTextPieces);
4191
4218
  }
@@ -4265,7 +4292,7 @@
4265
4292
  });
4266
4293
  }
4267
4294
  /**
4268
- * TODO: [🐝][πŸ”Ό] !!! Export via `@promptbook/markdown`
4295
+ * TODO: [🐝][πŸ”Ό][main] !!! Export via `@promptbook/markdown`
4269
4296
  * TODO: [πŸͺ‚] Do it in parallel 11:11
4270
4297
  * Note: No need to aggregate usage here, it is done by intercepting the llmTools
4271
4298
  */
@@ -4289,7 +4316,7 @@
4289
4316
  var partialPieces, pieces;
4290
4317
  return __generator(this, function (_a) {
4291
4318
  switch (_a.label) {
4292
- case 0: return [4 /*yield*/, prepareKnowledgeFromMarkdown(knowledgeSource.sourceContent, // <- TODO: [🐝] !!! Unhardcode markdown, detect which type it is - BE AWARE of big package size
4319
+ case 0: return [4 /*yield*/, prepareKnowledgeFromMarkdown(knowledgeSource.sourceContent, // <- TODO: [🐝][main] !!! Unhardcode markdown, detect which type it is - BE AWARE of big package size
4293
4320
  options)];
4294
4321
  case 1:
4295
4322
  partialPieces = _a.sent();
@@ -4481,7 +4508,7 @@
4481
4508
  });
4482
4509
  }
4483
4510
  /**
4484
- * TODO: [πŸ”ƒ] !!!!! If the persona was prepared with different version or different set of models, prepare it once again
4511
+ * TODO: [πŸ”ƒ][main] !!!!! If the persona was prepared with different version or different set of models, prepare it once again
4485
4512
  * TODO: [🏒] !! Check validity of `modelName` in pipeline
4486
4513
  * TODO: [🏒] !! Check validity of `systemMessage` in pipeline
4487
4514
  * TODO: [🏒] !! Check validity of `temperature` in pipeline
@@ -4530,7 +4557,7 @@
4530
4557
  case 0:
4531
4558
  _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a;
4532
4559
  templates = pipeline.templates, parameters = pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
4533
- // TODO: !!!!! Apply samples to each template (if missing and is for the template defined)
4560
+ // TODO:[main] !!!!! Apply samples to each template (if missing and is for the template defined)
4534
4561
  TODO_USE(parameters);
4535
4562
  templatesPrepared = new Array(
4536
4563
  // <- TODO: [🧱] Implement in a functional (not new Class) way
@@ -4562,7 +4589,7 @@
4562
4589
  /**
4563
4590
  * TODO: [🧠] Add context to each template (if missing)
4564
4591
  * TODO: [🧠] What is better name `prepareTemplate` or `prepareTemplateAndParameters`
4565
- * TODO: [♨] !!! Prepare index the samples and maybe templates
4592
+ * TODO: [♨][main] !!! Prepare index the samples and maybe templates
4566
4593
  * TODO: Write tests for `preparePipeline`
4567
4594
  * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
4568
4595
  * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
@@ -4734,7 +4761,7 @@
4734
4761
  if (sourceContent === '') {
4735
4762
  throw new ParseError("Source is not defined");
4736
4763
  }
4737
- // TODO: !!!! Following checks should be applied every link in the `sourceContent`
4764
+ // TODO:[main] !!!! Following checks should be applied every link in the `sourceContent`
4738
4765
  if (sourceContent.startsWith('http://')) {
4739
4766
  throw new ParseError("Source is not secure");
4740
4767
  }
@@ -4919,7 +4946,7 @@
4919
4946
  if (command.templateType === 'KNOWLEDGE') {
4920
4947
  knowledgeCommandParser.$applyToPipelineJson({
4921
4948
  type: 'KNOWLEDGE',
4922
- sourceContent: $templateJson.content, // <- TODO: [🐝] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
4949
+ sourceContent: $templateJson.content, // <- TODO: [🐝][main] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
4923
4950
  }, $pipelineJson);
4924
4951
  $templateJson.isTemplate = false;
4925
4952
  return;
@@ -5199,76 +5226,6 @@
5199
5226
  },
5200
5227
  };
5201
5228
 
5202
- /**
5203
- * @@@
5204
- *
5205
- * @param text @@@
5206
- * @returns @@@
5207
- * @example 'HELLO_WORLD'
5208
- * @example 'I_LOVE_PROMPTBOOK'
5209
- * @public exported from `@promptbook/utils`
5210
- */
5211
- function normalizeTo_SCREAMING_CASE(text) {
5212
- var e_1, _a;
5213
- var charType;
5214
- var lastCharType = 'OTHER';
5215
- var normalizedName = '';
5216
- try {
5217
- for (var text_1 = __values(text), text_1_1 = text_1.next(); !text_1_1.done; text_1_1 = text_1.next()) {
5218
- var char = text_1_1.value;
5219
- var normalizedChar = void 0;
5220
- if (/^[a-z]$/.test(char)) {
5221
- charType = 'LOWERCASE';
5222
- normalizedChar = char.toUpperCase();
5223
- }
5224
- else if (/^[A-Z]$/.test(char)) {
5225
- charType = 'UPPERCASE';
5226
- normalizedChar = char;
5227
- }
5228
- else if (/^[0-9]$/.test(char)) {
5229
- charType = 'NUMBER';
5230
- normalizedChar = char;
5231
- }
5232
- else if (/^\/$/.test(char)) {
5233
- charType = 'SLASH';
5234
- normalizedChar = char;
5235
- }
5236
- else {
5237
- charType = 'OTHER';
5238
- normalizedChar = '_';
5239
- }
5240
- if (charType !== lastCharType &&
5241
- !(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
5242
- !(lastCharType === 'NUMBER') &&
5243
- !(charType === 'NUMBER')) {
5244
- normalizedName += '_';
5245
- }
5246
- normalizedName += normalizedChar;
5247
- lastCharType = charType;
5248
- }
5249
- }
5250
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
5251
- finally {
5252
- try {
5253
- if (text_1_1 && !text_1_1.done && (_a = text_1.return)) _a.call(text_1);
5254
- }
5255
- finally { if (e_1) throw e_1.error; }
5256
- }
5257
- normalizedName = normalizedName.replace(/_+/g, '_');
5258
- normalizedName = normalizedName.replace(/_?\/_?/g, '/');
5259
- normalizedName = normalizedName.replace(/^_/, '');
5260
- normalizedName = normalizedName.replace(/_$/, '');
5261
- return normalizedName;
5262
- }
5263
- /**
5264
- * TODO: Tests
5265
- * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'Moje tabule' })).toEqual('/VtG7sR9rRJqwNEdM2/Moje tabule');
5266
- * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'ěőčřžžýÑíúů' })).toEqual('/VtG7sR9rRJqwNEdM2/escrzyaieuu');
5267
- * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj');
5268
- * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj_ahojAhoj ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj-ahoj-ahoj-ahoj');
5269
- * TODO: [🌺] Use some intermediate util splitWords
5270
- */
5271
-
5272
5229
  /**
5273
5230
  * Parses the foreach command
5274
5231
  *
@@ -5306,59 +5263,17 @@
5306
5263
  'FOREACH List Line -> `{customer}`',
5307
5264
  'FOR List Line -> `{customer}`',
5308
5265
  'EACH List Line -> `{customer}`',
5309
- // <- TODO: [🍭] !!!!!! More
5266
+ // <- TODO: [🍭] More
5310
5267
  ],
5311
5268
  /**
5312
5269
  * Parses the FOREACH command
5313
5270
  */
5314
5271
  parse: function (input) {
5315
- var args = input.args, rawArgs = input.rawArgs;
5316
- var formatName = normalizeTo_SCREAMING_CASE(args[0] || '');
5317
- var cellName = normalizeTo_SCREAMING_CASE(args[1] || '');
5318
- var assignSign = args[2];
5319
- var parameter = args[3];
5320
- if (![
5321
- 'LIST',
5322
- 'CSV',
5323
- // <- TODO: [🏒] Unhardcode formats
5324
- ].includes(formatName)) {
5325
- console.info({ args: args, formatName: formatName });
5326
- throw new Error("Unsupported format \"".concat(formatName, "\""));
5327
- // <- TODO: [🏒] List all supported format names
5328
- }
5329
- if (![
5330
- 'LINE',
5331
- 'ROW',
5332
- 'COLUMN',
5333
- 'CELL',
5334
- // <- TODO: [🏒] Unhardcode format cekks
5335
- ].includes(cellName)) {
5336
- console.info({ args: args, cellName: cellName });
5337
- throw new Error("Format ".concat(formatName, " does not support cell \"").concat(cellName, "\""));
5338
- // <- TODO: [🏒] List all supported cell names for the format
5339
- }
5340
- if (assignSign !== '->') {
5341
- console.info({ args: args, assignSign: assignSign });
5342
- throw new Error("FOREACH command must have '->' to assign the value to the parameter");
5343
- }
5344
- var parameterNames = extractParameterNames(parameter || rawArgs);
5345
- if (parameterNames.size !== 1) {
5346
- console.info({ args: args, parameter: parameter, rawArgs: rawArgs });
5347
- throw new Error("FOREACH command contain exactly one parameter, but found ".concat(parameterNames.size));
5348
- }
5349
- var parameterName = parameterNames.values().next().value;
5350
- if (typeof parameterName !== 'string'
5351
- // <- TODO: !!!!!! Replace with propper parameter name validation
5352
- ) {
5353
- console.info({ args: args, parameterName: parameterName });
5354
- throw new Error("Invalid parameter name");
5355
- // <- TODO: !!!!!! Better error (with rules and precise error) from validateParameterName
5356
- }
5272
+ var args = input.args;
5273
+ keepUnused(args);
5274
+ // <- TODO: [🍭] Implement
5357
5275
  return {
5358
5276
  type: 'FOREACH',
5359
- formatName: formatName,
5360
- cellName: cellName,
5361
- parameterName: parameterName,
5362
5277
  };
5363
5278
  },
5364
5279
  /**
@@ -5368,7 +5283,7 @@
5368
5283
  */
5369
5284
  $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
5370
5285
  keepUnused(command, $templateJson, $pipelineJson);
5371
- // <- TODO: [🍭] !!!!!! Implement
5286
+ // <- TODO: [🍭] Implement
5372
5287
  },
5373
5288
  /**
5374
5289
  * Converts the FOREACH command back to string
@@ -5378,7 +5293,7 @@
5378
5293
  stringify: function (command) {
5379
5294
  keepUnused(command);
5380
5295
  return "";
5381
- // <- TODO: [🍭] !!!!!! Implement
5296
+ // <- TODO: [🍭] Implement
5382
5297
  },
5383
5298
  /**
5384
5299
  * Reads the FOREACH command from the `TemplateJson`
@@ -5388,12 +5303,11 @@
5388
5303
  takeFromTemplateJson: function ($templateJson) {
5389
5304
  keepUnused($templateJson);
5390
5305
  return [];
5391
- // <- TODO: [🍭] !!!!!! Implement
5306
+ // <- TODO: [🍭] Implement
5392
5307
  },
5393
5308
  };
5394
5309
  /**
5395
- * TODO: !!!!!! Comment console logs
5396
- * TODO: [🍭] !!!!!! Make .ptbk.md file with examples of the FOREACH command and also with wrong parsing and logic
5310
+ * TODO: [🍭] Make .ptbk.md file with examples of the FOREACH command and also with wrong parsing and logic
5397
5311
  */
5398
5312
 
5399
5313
  /**
@@ -5746,7 +5660,6 @@
5746
5660
  isInput = false;
5747
5661
  isOutput = false;
5748
5662
  }
5749
- // TODO: !!!!!! Add parameter name validation
5750
5663
  return {
5751
5664
  type: 'PARAMETER',
5752
5665
  parameterName: parameterName,
@@ -6075,6 +5988,7 @@
6075
5988
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
6076
5989
  */
6077
5990
  $applyToPipelineJson: function (command, $pipelineJson) {
5991
+ // TODO: Warn if the version is overridden
6078
5992
  $pipelineJson.promptbookVersion = command.promptbookVersion;
6079
5993
  },
6080
5994
  /**
@@ -6499,6 +6413,76 @@
6499
6413
  return str;
6500
6414
  }
6501
6415
 
6416
+ /**
6417
+ * @@@
6418
+ *
6419
+ * @param text @@@
6420
+ * @returns @@@
6421
+ * @example 'HELLO_WORLD'
6422
+ * @example 'I_LOVE_PROMPTBOOK'
6423
+ * @public exported from `@promptbook/utils`
6424
+ */
6425
+ function normalizeTo_SCREAMING_CASE(text) {
6426
+ var e_1, _a;
6427
+ var charType;
6428
+ var lastCharType = 'OTHER';
6429
+ var normalizedName = '';
6430
+ try {
6431
+ for (var text_1 = __values(text), text_1_1 = text_1.next(); !text_1_1.done; text_1_1 = text_1.next()) {
6432
+ var char = text_1_1.value;
6433
+ var normalizedChar = void 0;
6434
+ if (/^[a-z]$/.test(char)) {
6435
+ charType = 'LOWERCASE';
6436
+ normalizedChar = char.toUpperCase();
6437
+ }
6438
+ else if (/^[A-Z]$/.test(char)) {
6439
+ charType = 'UPPERCASE';
6440
+ normalizedChar = char;
6441
+ }
6442
+ else if (/^[0-9]$/.test(char)) {
6443
+ charType = 'NUMBER';
6444
+ normalizedChar = char;
6445
+ }
6446
+ else if (/^\/$/.test(char)) {
6447
+ charType = 'SLASH';
6448
+ normalizedChar = char;
6449
+ }
6450
+ else {
6451
+ charType = 'OTHER';
6452
+ normalizedChar = '_';
6453
+ }
6454
+ if (charType !== lastCharType &&
6455
+ !(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
6456
+ !(lastCharType === 'NUMBER') &&
6457
+ !(charType === 'NUMBER')) {
6458
+ normalizedName += '_';
6459
+ }
6460
+ normalizedName += normalizedChar;
6461
+ lastCharType = charType;
6462
+ }
6463
+ }
6464
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
6465
+ finally {
6466
+ try {
6467
+ if (text_1_1 && !text_1_1.done && (_a = text_1.return)) _a.call(text_1);
6468
+ }
6469
+ finally { if (e_1) throw e_1.error; }
6470
+ }
6471
+ normalizedName = normalizedName.replace(/_+/g, '_');
6472
+ normalizedName = normalizedName.replace(/_?\/_?/g, '/');
6473
+ normalizedName = normalizedName.replace(/^_/, '');
6474
+ normalizedName = normalizedName.replace(/_$/, '');
6475
+ return normalizedName;
6476
+ }
6477
+ /**
6478
+ * TODO: Tests
6479
+ * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'Moje tabule' })).toEqual('/VtG7sR9rRJqwNEdM2/Moje tabule');
6480
+ * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'ěőčřžžýÑíúů' })).toEqual('/VtG7sR9rRJqwNEdM2/escrzyaieuu');
6481
+ * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj');
6482
+ * > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj_ahojAhoj ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj-ahoj-ahoj-ahoj');
6483
+ * TODO: [🌺] Use some intermediate util splitWords
6484
+ */
6485
+
6502
6486
  /**
6503
6487
  * Parses one line of ul/ol to command
6504
6488
  *
@@ -6511,7 +6495,6 @@
6511
6495
  if (raw.includes('\n') || raw.includes('\r')) {
6512
6496
  throw new ParseError('Command can not contain new line characters' /* <- TODO: [🚞] */);
6513
6497
  }
6514
- // TODO: Unit test all this processing and parsing
6515
6498
  var normalized = raw.trim();
6516
6499
  normalized = normalized.split('`').join('');
6517
6500
  normalized = normalized.split('"').join('');
@@ -6567,7 +6550,7 @@
6567
6550
  // Arg1 Arg2 Arg3 | FOO
6568
6551
  {
6569
6552
  var commandNameRaw = items.slice(-1).join('_');
6570
- var args = items.slice(0, -1); // <- Note: This is probbably not correct
6553
+ var args = items.slice(0, -1);
6571
6554
  var rawArgs = raw.substring(0, raw.length - commandNameRaw.length).trim();
6572
6555
  var command = parseCommandVariant({ usagePlace: usagePlace, raw: raw, rawArgs: rawArgs, normalized: normalized, args: args, commandNameRaw: commandNameRaw });
6573
6556
  if (command !== null) {
@@ -6895,7 +6878,7 @@
6895
6878
  var $pipelineJson = {
6896
6879
  title: undefined /* <- Note: [πŸ™] Putting here placeholder to keep `title` on top at final JSON */,
6897
6880
  pipelineUrl: undefined /* <- Note: Putting here placeholder to keep `pipelineUrl` on top at final JSON */,
6898
- promptbookVersion: PROMPTBOOK_VERSION,
6881
+ promptbookVersion: undefined /* <- Note: By default no explicit version */,
6899
6882
  description: undefined /* <- Note: [πŸ™] Putting here placeholder to keep `description` on top at final JSON */,
6900
6883
  parameters: [],
6901
6884
  templates: [],
@@ -7186,7 +7169,7 @@
7186
7169
  return $asDeeplyFrozenSerializableJson('pipelineJson', $pipelineJson);
7187
7170
  }
7188
7171
  /**
7189
- * TODO: !!!! Warn if used only sync version
7172
+ * TODO:[main] !!!! Warn if used only sync version
7190
7173
  * TODO: [🚞] Report here line/column of error
7191
7174
  * TODO: Use spaceTrim more effectively
7192
7175
  * TODO: [🧠] Parameter flags - isInput, isOutput, isInternal
@@ -7461,7 +7444,7 @@
7461
7444
  }
7462
7445
  }
7463
7446
  /**
7464
- * TODO: [🧠] !!! In-memory cache of same values to prevent multiple checks
7447
+ * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
7465
7448
  * TODO: [🧠][πŸ’Ί] Can be done this on type-level?
7466
7449
  */
7467
7450
 
@@ -8514,6 +8497,7 @@
8514
8497
  exports.PrefixStorage = PrefixStorage;
8515
8498
  exports.RESERVED_PARAMETER_NAMES = RESERVED_PARAMETER_NAMES;
8516
8499
  exports.TemplateTypes = TemplateTypes;
8500
+ exports.UNCERTAIN_USAGE = UNCERTAIN_USAGE;
8517
8501
  exports.UnexpectedError = UnexpectedError;
8518
8502
  exports.ZERO_USAGE = ZERO_USAGE;
8519
8503
  exports._AnthropicClaudeMetadataRegistration = _AnthropicClaudeMetadataRegistration;