@promptbook/core 0.61.0-24 → 0.61.0-25

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.
package/README.md CHANGED
@@ -88,7 +88,7 @@ File `write-website-content.ptbk.md`:
88
88
  > - PROMPTBOOK VERSION 0.0.1
89
89
  > - INPUT  PARAM `{rawTitle}` Automatically suggested a site name or empty text
90
90
  > - INPUT  PARAM `{rawAssigment}` Automatically generated site entry from image recognition
91
- > - OUTPUT PARAM `{content}` Web content
91
+ > - OUTPUT PARAM `{websiteContent}` Web content
92
92
  > - OUTPUT PARAM `{keywords}` Keywords
93
93
  >
94
94
  > ## 👤 Specifying the assigment
@@ -247,7 +247,7 @@ File `write-website-content.ptbk.md`:
247
247
  > {contentBody}
248
248
  > ```
249
249
  >
250
- > `-> {content}`
250
+ > `-> {websiteContent}`
251
251
 
252
252
 
253
253
 
@@ -287,7 +287,7 @@ flowchart LR
287
287
  templateCombineTheBeginning--"{contentBeginning}"-->templateCombineTheContent
288
288
  templateWriteTheContent--"{contentBody}"-->templateCombineTheContent
289
289
 
290
- templateCombineTheContent--"{content}"-->output
290
+ templateCombineTheContent--"{websiteContent}"-->output
291
291
  output((Output)):::output
292
292
 
293
293
  classDef input color: grey;
package/esm/index.es.js CHANGED
@@ -474,6 +474,7 @@ var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
474
474
  * The names of the parameters that are reserved for special purposes
475
475
  */
476
476
  var RESERVED_PARAMETER_NAMES = deepFreeze([
477
+ 'content',
477
478
  'context',
478
479
  'knowledge',
479
480
  'samples',
@@ -486,6 +487,10 @@ var RESERVED_PARAMETER_NAMES = deepFreeze([
486
487
  * @@@
487
488
  */
488
489
  var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
490
+ /**
491
+ * @@@
492
+ */
493
+ var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
489
494
  /*
490
495
  TODO: !!! Just testing false-negative detection of [🟡][🟢][🔵][⚪] leak
491
496
  */
@@ -926,6 +931,36 @@ var ReferenceError$1 = /** @class */ (function (_super) {
926
931
  return ReferenceError;
927
932
  }(Error));
928
933
 
934
+ /**
935
+ * Parses the template and returns the list of all parameter names
936
+ *
937
+ * @param template the template with parameters in {curly} braces
938
+ * @returns the list of parameter names
939
+ */
940
+ function extractParameters(template) {
941
+ var e_1, _a;
942
+ var matches = template.matchAll(/{\w+}/g);
943
+ var parameterNames = new Set();
944
+ try {
945
+ for (var matches_1 = __values(matches), matches_1_1 = matches_1.next(); !matches_1_1.done; matches_1_1 = matches_1.next()) {
946
+ var match = matches_1_1.value;
947
+ var parameterName = match[0].slice(1, -1);
948
+ parameterNames.add(parameterName);
949
+ }
950
+ }
951
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
952
+ finally {
953
+ try {
954
+ if (matches_1_1 && !matches_1_1.done && (_a = matches_1.return)) _a.call(matches_1);
955
+ }
956
+ finally { if (e_1) throw e_1.error; }
957
+ }
958
+ return parameterNames;
959
+ }
960
+ /**
961
+ * TODO: !!!!! Rename to extractParameterNames
962
+ */
963
+
929
964
  /**
930
965
  * Unprepare just strips the preparation data of the pipeline
931
966
  */
@@ -933,7 +968,14 @@ function unpreparePipeline(pipeline) {
933
968
  var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, promptTemplates = pipeline.promptTemplates;
934
969
  personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
935
970
  knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
936
- promptTemplates = promptTemplates.map(function (promptTemplate) { return (__assign(__assign({}, promptTemplate), { preparedContent: undefined })); });
971
+ promptTemplates = promptTemplates.map(function (promptTemplate) {
972
+ var dependentParameterNames = promptTemplate.dependentParameterNames;
973
+ var parameterNames = extractParameters(promptTemplate.preparedContent || '');
974
+ dependentParameterNames = dependentParameterNames.filter(function (dependentParameterName) { return !parameterNames.has(dependentParameterName); });
975
+ var promptTemplateUnprepared = __assign(__assign({}, promptTemplate), { dependentParameterNames: dependentParameterNames });
976
+ delete promptTemplateUnprepared.preparedContent;
977
+ return promptTemplateUnprepared;
978
+ });
937
979
  return __assign(__assign({}, pipeline), { promptTemplates: promptTemplates, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] });
938
980
  }
939
981
  /**
@@ -1457,7 +1499,7 @@ function forEachAsync(array, options, callbackfunction) {
1457
1499
  });
1458
1500
  }
1459
1501
 
1460
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-23",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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}",dependentParameterNames:["content"],resultingParameterName:"knowledgePieces"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-23",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-23",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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}",dependentParameterNames:["content"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-23",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-23",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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}",expectations:{words:{min:1,max:8}},dependentParameterNames:["content"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-23",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-23",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:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",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}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-23",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"}];
1502
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-24",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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> {knowledgeContent}",dependentParameterNames:["knowledgeContent"],resultingParameterName:"knowledgePieces"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-24",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-24",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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> {knowledgePieceContent}",dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-24",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-24",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",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> {knowledgePieceContent}",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-24",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-24",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:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",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}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-24",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"}];
1461
1503
 
1462
1504
  var defaultDiacriticsRemovalMap = [
1463
1505
  {
@@ -1841,33 +1883,6 @@ function assertsExecutionSuccessful(executionResult) {
1841
1883
  * TODO: [🧠] Can this return type be better typed than void
1842
1884
  */
1843
1885
 
1844
- /**
1845
- * Parses the template and returns the list of all parameter names
1846
- *
1847
- * @param template the template with parameters in {curly} braces
1848
- * @returns the list of parameter names
1849
- */
1850
- function extractParameters(template) {
1851
- var e_1, _a;
1852
- var matches = template.matchAll(/{\w+}/g);
1853
- var parameterNames = new Set();
1854
- try {
1855
- for (var matches_1 = __values(matches), matches_1_1 = matches_1.next(); !matches_1_1.done; matches_1_1 = matches_1.next()) {
1856
- var match = matches_1_1.value;
1857
- var parameterName = match[0].slice(1, -1);
1858
- parameterNames.add(parameterName);
1859
- }
1860
- }
1861
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1862
- finally {
1863
- try {
1864
- if (matches_1_1 && !matches_1_1.done && (_a = matches_1.return)) _a.call(matches_1);
1865
- }
1866
- finally { if (e_1) throw e_1.error; }
1867
- }
1868
- return parameterNames;
1869
- }
1870
-
1871
1886
  /**
1872
1887
  * Parses the given script and returns the list of all used variables that are not defined in the script
1873
1888
  *
@@ -1925,10 +1940,10 @@ function extractVariables(script) {
1925
1940
  */
1926
1941
  function extractParametersFromPromptTemplate(promptTemplate) {
1927
1942
  var e_1, _a, e_2, _b, e_3, _c;
1928
- var title = promptTemplate.title, description = promptTemplate.description, blockType = promptTemplate.blockType, content = promptTemplate.content, jokerParameterNames = promptTemplate.jokerParameterNames;
1943
+ var title = promptTemplate.title, description = promptTemplate.description, blockType = promptTemplate.blockType, content = promptTemplate.content, preparedContent = promptTemplate.preparedContent, jokerParameterNames = promptTemplate.jokerParameterNames;
1929
1944
  var parameterNames = new Set();
1930
1945
  try {
1931
- for (var _d = __values(__spreadArray(__spreadArray(__spreadArray([], __read(extractParameters(title)), false), __read(extractParameters(description || '')), false), __read(extractParameters(content)), false)), _e = _d.next(); !_e.done; _e = _d.next()) {
1946
+ for (var _d = __values(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(extractParameters(title)), false), __read(extractParameters(description || '')), false), __read(extractParameters(content)), false), __read(extractParameters(preparedContent || '')), false)), _e = _d.next(); !_e.done; _e = _d.next()) {
1932
1947
  var parameterName = _e.value;
1933
1948
  parameterNames.add(parameterName);
1934
1949
  }
@@ -1968,6 +1983,8 @@ function extractParametersFromPromptTemplate(promptTemplate) {
1968
1983
  }
1969
1984
  finally { if (e_3) throw e_3.error; }
1970
1985
  }
1986
+ parameterNames.delete('content');
1987
+ // <- Note {websiteContent} is used in `preparedContent`
1971
1988
  return parameterNames;
1972
1989
  }
1973
1990
  /**
@@ -2137,7 +2154,14 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
2137
2154
  throw errors[0];
2138
2155
  }
2139
2156
  else if (errors.length > 1) {
2140
- throw new PipelineExecutionError(spaceTrim(function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors.map(function (error) { return "- ".concat(error.name || 'Error', ": ").concat(error.message); }).join('\n')), "\n\n "); }));
2157
+ throw new PipelineExecutionError(
2158
+ // TODO: Tell which execution tools failed like
2159
+ // 1) OpenAI throw PipelineExecutionError: Parameter {knowledge} is not defined
2160
+ // 2) AnthropicClaude throw PipelineExecutionError: Parameter {knowledge} is not defined
2161
+ // 3) ...
2162
+ spaceTrim(function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors
2163
+ .map(function (error, i) { return "".concat(i + 1, ") **").concat(error.name || 'Error', ":** ").concat(error.message); })
2164
+ .join('\n')), "\n\n "); }));
2141
2165
  }
2142
2166
  else {
2143
2167
  throw new PipelineExecutionError(spaceTrim(function (block) { return "\n You have not provided any `LlmExecutionTools` that support model variant \"".concat(prompt.modelRequirements.modelVariant, "\n\n Available `LlmExecutionTools`:\n ").concat(block(_this.llmExecutionTools
@@ -2342,6 +2366,10 @@ function replaceParameters(template, parameters) {
2342
2366
  if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
2343
2367
  throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
2344
2368
  }
2369
+ else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
2370
+ // TODO: [🍵]
2371
+ throw new UnexpectedError("Parameter {".concat(parameterName, "} is restricted to use"));
2372
+ }
2345
2373
  }
2346
2374
  }
2347
2375
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -2476,7 +2504,7 @@ function union() {
2476
2504
  /**
2477
2505
  * The version of the Promptbook library
2478
2506
  */
2479
- var PROMPTBOOK_VERSION = '0.61.0-23';
2507
+ var PROMPTBOOK_VERSION = '0.61.0-24';
2480
2508
  // TODO: !!!! List here all the versions and annotate + put into script
2481
2509
 
2482
2510
  /**
@@ -2631,7 +2659,7 @@ function createPipelineExecutor(options) {
2631
2659
  console.warn(spaceTrim$1("\n Pipeline ".concat(rawPipeline.pipelineUrl || rawPipeline.sourceFile || rawPipeline.title, " is not prepared\n\n ").concat(rawPipeline.sourceFile, "\n\n It will be prepared ad-hoc before the first execution\n But it is recommended to prepare the pipeline during collection preparation\n\n @see more at https://ptbk.io/prepare-pipeline\n ")));
2632
2660
  }
2633
2661
  var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
2634
- // TODO: !!!!! Extract to separate functions and files - ALL FUNCTIONS BELOW
2662
+ // TODO: !!! Extract to separate functions and files - ALL FUNCTIONS BELOW
2635
2663
  function getContextForTemplate(// <- TODO: [🧠][🥜]
2636
2664
  template) {
2637
2665
  return __awaiter(this, void 0, void 0, function () {
@@ -2682,6 +2710,7 @@ function createPipelineExecutor(options) {
2682
2710
  currentDate = new Date().toISOString();
2683
2711
  modelName = RESERVED_PARAMETER_MISSING_VALUE;
2684
2712
  reservedParameters = {
2713
+ content: RESERVED_PARAMETER_RESTRICTED,
2685
2714
  context: context,
2686
2715
  knowledge: knowledge,
2687
2716
  samples: samples,
@@ -3392,6 +3421,8 @@ function createPipelineExecutor(options) {
3392
3421
  return pipelineExecutor;
3393
3422
  }
3394
3423
  /**
3424
+ * TODO: !!!! return `preparedPipeline` from execution
3425
+ * TODO: !!!! `isNotPreparedWarningSupressed`
3395
3426
  * TODO: Use isVerbose here (not only pass to `preparePipeline`)
3396
3427
  * TODO: [🪂] Use maxParallelCount here (not only pass to `preparePipeline`)
3397
3428
  * TODO: [♈] Probbably move expectations from templates to parameters
@@ -3406,7 +3437,7 @@ function createPipelineExecutor(options) {
3406
3437
  /**
3407
3438
  * @@@
3408
3439
  */
3409
- function prepareKnowledgeFromMarkdown(content /* <- TODO: [🖖] (?maybe not) Always the file */, options) {
3440
+ function prepareKnowledgeFromMarkdown(knowledgeContent /* <- TODO: [🖖] (?maybe not) Always the file */, options) {
3410
3441
  return __awaiter(this, void 0, void 0, function () {
3411
3442
  var llmTools, _a, maxParallelCount, _b, isVerbose, collection, prepareKnowledgeFromMarkdownExecutor, _c, prepareTitleExecutor, _d, prepareKeywordsExecutor, _e, result, outputParameters, knowledgePiecesRaw, knowledgeTextPieces, knowledge;
3412
3443
  var _f, _g, _h;
@@ -3444,7 +3475,7 @@ function prepareKnowledgeFromMarkdown(content /* <- TODO: [🖖] (?maybe not) Al
3444
3475
  llm: llmTools,
3445
3476
  },
3446
3477
  _h)]);
3447
- return [4 /*yield*/, prepareKnowledgeFromMarkdownExecutor({ content: content })];
3478
+ return [4 /*yield*/, prepareKnowledgeFromMarkdownExecutor({ knowledgeContent: knowledgeContent })];
3448
3479
  case 4:
3449
3480
  result = _j.sent();
3450
3481
  assertsExecutionSuccessful(result);
@@ -3457,25 +3488,25 @@ function prepareKnowledgeFromMarkdown(content /* <- TODO: [🖖] (?maybe not) Al
3457
3488
  return [4 /*yield*/, Promise.all(
3458
3489
  // TODO: [🪂] !! Do not send all at once but in chunks
3459
3490
  knowledgeTextPieces.map(function (knowledgeTextPiece, i) { return __awaiter(_this, void 0, void 0, function () {
3460
- var name, title, content, keywords, index, titleResult, _a, titleRaw, keywordsResult, _b, keywordsRaw, embeddingResult, error_1;
3491
+ var name, title, knowledgePieceContent, keywords, index, titleResult, _a, titleRaw, keywordsResult, _b, keywordsRaw, embeddingResult, error_1;
3461
3492
  return __generator(this, function (_c) {
3462
3493
  switch (_c.label) {
3463
3494
  case 0:
3464
3495
  name = "piece-".concat(i);
3465
3496
  title = spaceTrim(knowledgeTextPiece.substring(0, 100));
3466
- content = spaceTrim(knowledgeTextPiece);
3497
+ knowledgePieceContent = spaceTrim(knowledgeTextPiece);
3467
3498
  keywords = [];
3468
3499
  index = [];
3469
3500
  _c.label = 1;
3470
3501
  case 1:
3471
3502
  _c.trys.push([1, 7, , 8]);
3472
- return [4 /*yield*/, prepareTitleExecutor({ content: content })];
3503
+ return [4 /*yield*/, prepareTitleExecutor({ knowledgePieceContent: knowledgePieceContent })];
3473
3504
  case 2:
3474
3505
  titleResult = _c.sent();
3475
3506
  _a = titleResult.outputParameters.title, titleRaw = _a === void 0 ? 'Untitled' : _a;
3476
3507
  title = spaceTrim(titleRaw) /* <- TODO: Maybe do in pipeline */;
3477
3508
  name = titleToName(title);
3478
- return [4 /*yield*/, prepareKeywordsExecutor({ content: content })];
3509
+ return [4 /*yield*/, prepareKeywordsExecutor({ knowledgePieceContent: knowledgePieceContent })];
3479
3510
  case 3:
3480
3511
  keywordsResult = _c.sent();
3481
3512
  _b = keywordsResult.outputParameters.keywords, keywordsRaw = _b === void 0 ? '' : _b;
@@ -3493,7 +3524,7 @@ function prepareKnowledgeFromMarkdown(content /* <- TODO: [🖖] (?maybe not) Al
3493
3524
  case 4: return [4 /*yield*/, llmTools.callEmbeddingModel({
3494
3525
  title: "Embedding for ".concat(title) /* <- Note: No impact on embedding result itself, just for logging */,
3495
3526
  parameters: {},
3496
- content: content,
3527
+ content: knowledgePieceContent,
3497
3528
  modelRequirements: {
3498
3529
  modelVariant: 'EMBEDDING',
3499
3530
  },
@@ -3514,7 +3545,7 @@ function prepareKnowledgeFromMarkdown(content /* <- TODO: [🖖] (?maybe not) Al
3514
3545
  case 8: return [2 /*return*/, {
3515
3546
  name: name,
3516
3547
  title: title,
3517
- content: content,
3548
+ content: knowledgePieceContent,
3518
3549
  keywords: keywords,
3519
3550
  index: index,
3520
3551
  // <- TODO: [☀] sources,
@@ -3680,14 +3711,18 @@ function prepareTemplates(pipeline, options) {
3680
3711
  TODO_USE(parameters);
3681
3712
  promptTemplatesPrepared = new Array(promptTemplates.length);
3682
3713
  return [4 /*yield*/, forEachAsync(promptTemplates, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (template, index) { return __awaiter(_this, void 0, void 0, function () {
3683
- var preparedContent, preparedTemplate;
3714
+ var dependentParameterNames, preparedContent, preparedTemplate;
3684
3715
  return __generator(this, function (_a) {
3716
+ dependentParameterNames = template.dependentParameterNames;
3685
3717
  preparedContent = undefined;
3686
- if (knowledgePiecesCount > 0) {
3718
+ if (knowledgePiecesCount > 0 && !dependentParameterNames.includes('knowledge')) {
3687
3719
  preparedContent = spaceTrim$1("\n {content}\n\n ## Knowledge\n\n {knowledge}\n ");
3688
3720
  // <- TODO: [🧠][🧻] Cutomize shape/language/formatting of the addition to the prompt
3721
+ dependentParameterNames = __spreadArray(__spreadArray([], __read(dependentParameterNames), false), [
3722
+ 'knowledge',
3723
+ ], false);
3689
3724
  }
3690
- preparedTemplate = __assign(__assign({}, template), { preparedContent: preparedContent });
3725
+ preparedTemplate = __assign(__assign({}, template), { dependentParameterNames: dependentParameterNames, preparedContent: preparedContent });
3691
3726
  promptTemplatesPrepared[index] = preparedTemplate;
3692
3727
  return [2 /*return*/];
3693
3728
  });
@@ -4486,7 +4521,7 @@ var parameterCommandParser = {
4486
4521
  /**
4487
4522
  * Example usages of the PARAMETER command
4488
4523
  */
4489
- examples: ['PARAMETER {title} Title of the book', 'OUTPUT PARAMETER {content} Content of the book'],
4524
+ examples: ['PARAMETER {title} Title of the book', 'OUTPUT PARAMETER {websiteContent} Content of the book'],
4490
4525
  /**
4491
4526
  * Parses the PARAMETER command
4492
4527
  */