@promptbook/core 0.61.0-21 → 0.61.0-23

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/esm/index.es.js CHANGED
@@ -466,19 +466,26 @@ var MAX_PARALLEL_COUNT = 5;
466
466
  * The maximum number of attempts to execute LLM task before giving up
467
467
  */
468
468
  var MAX_EXECUTION_ATTEMPTS = 3;
469
+ /**
470
+ * Nonce which is used for replacing things in strings
471
+ */
472
+ var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
469
473
  /**
470
474
  * The names of the parameters that are reserved for special purposes
471
475
  */
472
476
  var RESERVED_PARAMETER_NAMES = deepFreeze([
473
477
  'context',
478
+ 'knowledge',
479
+ 'samples',
480
+ 'modelName',
474
481
  'currentDate',
475
482
  // <- TODO: Add more like 'date', 'modelName',...
476
483
  // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
477
484
  ]);
478
485
  /**
479
- * Nonce which is used for replacing things in strings
486
+ * @@@
480
487
  */
481
- var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
488
+ var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
482
489
  /*
483
490
  TODO: !!! Just testing false-negative detection of [🟡][🟢][🔵][⚪] leak
484
491
  */
@@ -753,7 +760,7 @@ function validatePipeline(pipeline) {
753
760
  throw new PipelineLogicError("Parameter {".concat(template.resultingParameterName, "} is defined multiple times"));
754
761
  }
755
762
  if (RESERVED_PARAMETER_NAMES.includes(template.resultingParameterName)) {
756
- throw new PipelineLogicError("Parameter name {".concat(template.resultingParameterName, "} is reserved, please use fifferent name"));
763
+ throw new PipelineLogicError("Parameter name {".concat(template.resultingParameterName, "} is reserved, please use different name"));
757
764
  }
758
765
  definedParameters.add(template.resultingParameterName);
759
766
  if (template.blockType === 'PROMPT_TEMPLATE' && template.modelRequirements.modelVariant === undefined) {
@@ -930,6 +937,7 @@ function unpreparePipeline(pipeline) {
930
937
  }
931
938
  /**
932
939
  * TODO: [🔼] !!! Export via `@promptbook/core`
940
+ * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
933
941
  * TODO: Write tests for `preparePipeline`
934
942
  */
935
943
 
@@ -1447,7 +1455,7 @@ function forEachAsync(array, options, callbackfunction) {
1447
1455
  });
1448
1456
  }
1449
1457
 
1450
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-20",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledge",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:"knowledge"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-20",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-20",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-20",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-20",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-20",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-20",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-20",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"}];
1458
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-22",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-22",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-22",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-22",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-22",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-22",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-22",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-22",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"}];
1451
1459
 
1452
1460
  var defaultDiacriticsRemovalMap = [
1453
1461
  {
@@ -1820,7 +1828,11 @@ function assertsExecutionSuccessful(executionResult) {
1820
1828
  throw errors[0];
1821
1829
  }
1822
1830
  else {
1823
- throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Multiple errors occurred during promptnook execution\n\n ".concat(block(errors.map(function (error) { return '- ' + error.message; }).join('\n')), "\n "); }));
1831
+ throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Multiple errors occurred during promptnook execution\n\n ".concat(block(errors
1832
+ .map(function (error, index) {
1833
+ return spaceTrim$1(function (block) { return "\n Error ".concat(index + 1, ":\n ").concat(block(error.stack || error.message), "\n "); });
1834
+ })
1835
+ .join('\n')), "\n "); }));
1824
1836
  }
1825
1837
  }
1826
1838
  /**
@@ -2239,22 +2251,21 @@ function isPipelinePrepared(pipeline) {
2239
2251
  // Note: Ignoring `pipeline.preparations` @@@
2240
2252
  // Note: Ignoring `pipeline.knowledgePieces` @@@
2241
2253
  if (!pipeline.personas.every(function (persona) { return persona.modelRequirements !== undefined; })) {
2242
- console.log('!!!!', 'Not all personas have modelRequirements');
2243
2254
  return false;
2244
2255
  }
2245
2256
  if (!pipeline.knowledgeSources.every(function (knowledgeSource) { return knowledgeSource.preparationIds !== undefined; })) {
2246
- console.log('!!!!', 'Not all knowledgeSources have preparationIds');
2247
2257
  return false;
2248
2258
  }
2249
- // TODO: !!!!! Is context in each template
2250
- // TODO: !!!!! Are samples prepared
2251
- // TODO: !!!!! Are templates prepared
2252
2259
  return true;
2253
2260
  }
2254
2261
  /**
2255
2262
  * TODO: [🐠] Maybe base this on `makeValidator`
2256
2263
  * TODO: [🔼] Export via core or utils
2257
2264
  * TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
2265
+ * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
2266
+ * - Is context in each template
2267
+ * - Are samples prepared
2268
+ * - Are templates prepared
2258
2269
  */
2259
2270
 
2260
2271
  /**
@@ -2316,6 +2327,22 @@ var LimitReachedError = /** @class */ (function (_super) {
2316
2327
  * @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
2317
2328
  */
2318
2329
  function replaceParameters(template, parameters) {
2330
+ var e_1, _a;
2331
+ try {
2332
+ for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
2333
+ var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
2334
+ if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
2335
+ throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
2336
+ }
2337
+ }
2338
+ }
2339
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2340
+ finally {
2341
+ try {
2342
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2343
+ }
2344
+ finally { if (e_1) throw e_1.error; }
2345
+ }
2319
2346
  var replacedTemplate = template;
2320
2347
  var match;
2321
2348
  var loopLimit = LOOP_LIMIT;
@@ -2441,7 +2468,7 @@ function union() {
2441
2468
  /**
2442
2469
  * The version of the Promptbook library
2443
2470
  */
2444
- var PROMPTBOOK_VERSION = '0.61.0-20';
2471
+ var PROMPTBOOK_VERSION = '0.61.0-22';
2445
2472
  // TODO: !!!! List here all the versions and annotate + put into script
2446
2473
 
2447
2474
  /**
@@ -2595,11 +2622,21 @@ function createPipelineExecutor(options) {
2595
2622
  console.warn(spaceTrim$1("\n Pipeline ".concat(rawPipeline.pipelineUrl || rawPipeline.sourceFile || rawPipeline.title, " is not prepared\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 ")));
2596
2623
  }
2597
2624
  var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
2625
+ // TODO: !!!!! Extract to separate functions and files - ALL FUNCTIONS BELOW
2598
2626
  function getContextForTemplate(// <- TODO: [🧠][🥜]
2599
2627
  template) {
2600
2628
  return __awaiter(this, void 0, void 0, function () {
2601
2629
  return __generator(this, function (_a) {
2602
- // TODO: !!!!!! Implement Better - use real index and keyword search
2630
+ TODO_USE(template);
2631
+ return [2 /*return*/, ''];
2632
+ });
2633
+ });
2634
+ }
2635
+ function getKnowledgeForTemplate(// <- TODO: [🧠][🥜]
2636
+ template) {
2637
+ return __awaiter(this, void 0, void 0, function () {
2638
+ return __generator(this, function (_a) {
2639
+ // TODO: !!!! Implement Better - use real index and keyword search
2603
2640
  TODO_USE(template);
2604
2641
  return [2 /*return*/, pipeline.knowledgePieces.map(function (_a) {
2605
2642
  var content = _a.content;
@@ -2608,19 +2645,39 @@ function createPipelineExecutor(options) {
2608
2645
  });
2609
2646
  });
2610
2647
  }
2648
+ function getSamplesForTemplate(// <- TODO: [🧠][🥜]
2649
+ template) {
2650
+ return __awaiter(this, void 0, void 0, function () {
2651
+ return __generator(this, function (_a) {
2652
+ // TODO: !!!! Implement Better - use real index and keyword search
2653
+ TODO_USE(template);
2654
+ return [2 /*return*/, ''];
2655
+ });
2656
+ });
2657
+ }
2611
2658
  function getReservedParametersForTemplate(template) {
2612
2659
  return __awaiter(this, void 0, void 0, function () {
2613
- var context, currentDate, reservedParameters, RESERVED_PARAMETER_NAMES_1, RESERVED_PARAMETER_NAMES_1_1, parameterName;
2660
+ var context, knowledge, samples, currentDate, modelName, reservedParameters, RESERVED_PARAMETER_NAMES_1, RESERVED_PARAMETER_NAMES_1_1, parameterName;
2614
2661
  var e_3, _a;
2615
2662
  return __generator(this, function (_b) {
2616
2663
  switch (_b.label) {
2617
2664
  case 0: return [4 /*yield*/, getContextForTemplate(template)];
2618
2665
  case 1:
2619
2666
  context = _b.sent();
2667
+ return [4 /*yield*/, getKnowledgeForTemplate(template)];
2668
+ case 2:
2669
+ knowledge = _b.sent();
2670
+ return [4 /*yield*/, getSamplesForTemplate(template)];
2671
+ case 3:
2672
+ samples = _b.sent();
2620
2673
  currentDate = new Date().toISOString();
2674
+ modelName = RESERVED_PARAMETER_MISSING_VALUE;
2621
2675
  reservedParameters = {
2622
2676
  context: context,
2677
+ knowledge: knowledge,
2678
+ samples: samples,
2623
2679
  currentDate: currentDate,
2680
+ modelName: modelName,
2624
2681
  };
2625
2682
  try {
2626
2683
  // Note: Doublecheck that ALL reserved parameters are defined:
@@ -3107,7 +3164,7 @@ function createPipelineExecutor(options) {
3107
3164
  var parameter = _c.value;
3108
3165
  if (parametersToPass[parameter.name] === undefined) {
3109
3166
  // [4]
3110
- errors.push(new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an output parameter but not set in the pipeline")));
3167
+ warnings.push(new PipelineExecutionError("Parameter {".concat(parameter.name, "} should be an output parameter, but it was not be resolved")));
3111
3168
  continue;
3112
3169
  }
3113
3170
  outputParameters[parameter.name] = parametersToPass[parameter.name] || '';
@@ -3122,7 +3179,7 @@ function createPipelineExecutor(options) {
3122
3179
  }
3123
3180
  return outputParameters;
3124
3181
  }
3125
- var executionReport, _a, _b, parameter, errors, _loop_1, _c, _d, parameterName, state_1, parametersToPass, resovedParameters_1, unresovedTemplates_1, resolving_1, loopLimit, _loop_2, error_1, usage_1, outputParameters_1, usage, outputParameters;
3182
+ var executionReport, _a, _b, parameter, errors, warnings, _loop_1, _c, _d, parameterName, state_1, parametersToPass, resovedParameterNames_1, unresovedTemplates_1, resolving_1, loopLimit, _loop_2, error_1, usage_1, outputParameters_1, usage, outputParameters;
3126
3183
  var e_1, _e, e_2, _f;
3127
3184
  return __generator(this, function (_g) {
3128
3185
  switch (_g.label) {
@@ -3157,8 +3214,8 @@ function createPipelineExecutor(options) {
3157
3214
  isSuccessful: false,
3158
3215
  errors: [
3159
3216
  new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter")),
3160
- // <- TODO: !!!!! Test this error
3161
3217
  ],
3218
+ warnings: [],
3162
3219
  executionReport: executionReport,
3163
3220
  outputParameters: {},
3164
3221
  usage: ZERO_USAGE,
@@ -3174,21 +3231,22 @@ function createPipelineExecutor(options) {
3174
3231
  finally { if (e_1) throw e_1.error; }
3175
3232
  }
3176
3233
  errors = [];
3234
+ warnings = [];
3177
3235
  _loop_1 = function (parameterName) {
3178
3236
  var parameter = pipeline.parameters.find(function (_a) {
3179
3237
  var name = _a.name;
3180
3238
  return name === parameterName;
3181
3239
  });
3182
3240
  if (parameter === undefined) {
3183
- errors.push(new PipelineExecutionError("Extra parameter {".concat(parameterName, "} is passed as input parameter")));
3241
+ warnings.push(new PipelineExecutionError("Extra parameter {".concat(parameterName, "} is being passed which is not part of the pipeline.")));
3184
3242
  }
3185
3243
  else if (parameter.isInput === false) {
3186
3244
  return { value: deepFreezeWithSameType({
3187
3245
  isSuccessful: false,
3188
3246
  errors: [
3189
- new PipelineExecutionError("Parameter {".concat(parameter.name, "} is passed as input parameter but is not input")),
3190
- // <- TODO: !!!!! Test this error
3247
+ new PipelineExecutionError("Parameter {".concat(parameter.name, "} is passed as input parameter but it is not input")),
3191
3248
  ],
3249
+ warnings: warnings,
3192
3250
  executionReport: executionReport,
3193
3251
  outputParameters: {},
3194
3252
  usage: ZERO_USAGE,
@@ -3215,7 +3273,7 @@ function createPipelineExecutor(options) {
3215
3273
  _g.label = 3;
3216
3274
  case 3:
3217
3275
  _g.trys.push([3, 8, , 9]);
3218
- resovedParameters_1 = pipeline.parameters
3276
+ resovedParameterNames_1 = pipeline.parameters
3219
3277
  .filter(function (_a) {
3220
3278
  var isInput = _a.isInput;
3221
3279
  return isInput;
@@ -3237,7 +3295,9 @@ function createPipelineExecutor(options) {
3237
3295
  throw new UnexpectedError('Loop limit reached during resolving parameters pipeline execution');
3238
3296
  }
3239
3297
  currentTemplate = unresovedTemplates_1.find(function (template) {
3240
- return template.dependentParameterNames.every(function (name) { return resovedParameters_1.includes(name); });
3298
+ return template.dependentParameterNames.every(function (name) {
3299
+ return __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), __read(RESERVED_PARAMETER_NAMES), false).includes(name);
3300
+ });
3241
3301
  });
3242
3302
  if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
3243
3303
  throw new UnexpectedError(
@@ -3249,7 +3309,7 @@ function createPipelineExecutor(options) {
3249
3309
  .map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
3250
3310
  .join(' and '));
3251
3311
  })
3252
- .join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameters_1.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n\n Note: This should be catched in `validatePipeline`\n "); }));
3312
+ .join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameterNames_1.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n\n Note: This should be catched in `validatePipeline`\n "); }));
3253
3313
  case 1:
3254
3314
  if (!!currentTemplate) return [3 /*break*/, 3];
3255
3315
  /* [5] */ return [4 /*yield*/, Promise.race(resolving_1)];
@@ -3260,7 +3320,7 @@ function createPipelineExecutor(options) {
3260
3320
  unresovedTemplates_1 = unresovedTemplates_1.filter(function (template) { return template !== currentTemplate; });
3261
3321
  work_1 = executeSingleTemplate(currentTemplate)
3262
3322
  .then(function () {
3263
- resovedParameters_1 = __spreadArray(__spreadArray([], __read(resovedParameters_1), false), [currentTemplate.resultingParameterName], false);
3323
+ resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [currentTemplate.resultingParameterName], false);
3264
3324
  })
3265
3325
  .then(function () {
3266
3326
  resolving_1 = resolving_1.filter(function (w) { return w !== work_1; });
@@ -3295,6 +3355,7 @@ function createPipelineExecutor(options) {
3295
3355
  return [2 /*return*/, deepFreezeWithSameType({
3296
3356
  isSuccessful: false,
3297
3357
  errors: __spreadArray([error_1], __read(errors), false),
3358
+ warnings: warnings,
3298
3359
  usage: usage_1,
3299
3360
  executionReport: executionReport,
3300
3361
  outputParameters: outputParameters_1,
@@ -3308,6 +3369,7 @@ function createPipelineExecutor(options) {
3308
3369
  return [2 /*return*/, deepFreezeWithSameType({
3309
3370
  isSuccessful: true,
3310
3371
  errors: errors,
3372
+ warnings: warnings,
3311
3373
  usage: usage,
3312
3374
  executionReport: executionReport,
3313
3375
  outputParameters: outputParameters,
@@ -3334,7 +3396,7 @@ function createPipelineExecutor(options) {
3334
3396
  */
3335
3397
  function prepareKnowledgeFromMarkdown(content /* <- TODO: [🖖] (?maybe not) Always the file */, options) {
3336
3398
  return __awaiter(this, void 0, void 0, function () {
3337
- var llmTools, _a, maxParallelCount, _b, isVerbose, collection, prepareKnowledgeFromMarkdownExecutor, _c, prepareTitleExecutor, _d, prepareKeywordsExecutor, _e, result, outputParameters, knowledgeRaw, knowledgeTextPieces, knowledge;
3399
+ var llmTools, _a, maxParallelCount, _b, isVerbose, collection, prepareKnowledgeFromMarkdownExecutor, _c, prepareTitleExecutor, _d, prepareKeywordsExecutor, _e, result, outputParameters, knowledgePiecesRaw, knowledgeTextPieces, knowledge;
3338
3400
  var _f, _g, _h;
3339
3401
  var _this = this;
3340
3402
  return __generator(this, function (_j) {
@@ -3375,8 +3437,8 @@ function prepareKnowledgeFromMarkdown(content /* <- TODO: [🖖] (?maybe not) Al
3375
3437
  result = _j.sent();
3376
3438
  assertsExecutionSuccessful(result);
3377
3439
  outputParameters = result.outputParameters;
3378
- knowledgeRaw = outputParameters.knowledge;
3379
- knowledgeTextPieces = (knowledgeRaw || '').split('\n---\n');
3440
+ knowledgePiecesRaw = outputParameters.knowledgePieces;
3441
+ knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
3380
3442
  if (isVerbose) {
3381
3443
  console.info('knowledgeTextPieces:', knowledgeTextPieces);
3382
3444
  }
@@ -3644,7 +3706,8 @@ function preparePipeline(pipeline, options) {
3644
3706
  knowledgePiecesPrepared = partialknowledgePiecesPrepared.map(function (piece) { return (__assign(__assign({}, piece), { preparationIds: [/* TODO: [🧊] -> */ currentPreparation.id] })); });
3645
3707
  // ----- /Knowledge preparation -----
3646
3708
  // TODO: !!!!! Add context to each template (if missing)
3647
- // TODO: !!!!! Apply samples to each template (if missing)
3709
+ // TODO: !!!!! Add knowledge to each template (if missing and is in pipeline defined)
3710
+ // TODO: !!!!! Apply samples to each template (if missing and is for the template defined)
3648
3711
  return [2 /*return*/, __assign(__assign({}, pipeline), { knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: preparations })];
3649
3712
  }
3650
3713
  });