@promptbook/core 0.61.0-22 โ†’ 0.61.0-24

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 (47) hide show
  1. package/esm/index.es.js +164 -43
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/types.index.d.ts +2 -2
  4. package/esm/typings/src/config.d.ts +8 -4
  5. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +1 -0
  6. package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -0
  7. package/esm/typings/src/execution/PipelineExecutor.d.ts +32 -24
  8. package/esm/typings/src/execution/PromptResultUsage.d.ts +3 -0
  9. package/esm/typings/src/prepare/isPipelinePrepared.d.ts +4 -0
  10. package/esm/typings/src/prepare/preparePipeline.d.ts +0 -1
  11. package/esm/typings/src/prepare/prepareTemplates.d.ts +31 -0
  12. package/esm/typings/src/prepare/unpreparePipeline.d.ts +2 -0
  13. package/esm/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +3 -0
  14. package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +3 -0
  15. package/esm/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +1 -0
  16. package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +3 -0
  17. package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +1 -0
  18. package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -0
  19. package/esm/typings/src/types/PipelineJson/PromptDialogJson.d.ts +4 -3
  20. package/esm/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +10 -0
  21. package/esm/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +1 -0
  22. package/esm/typings/src/types/PipelineJson/ScriptJson.d.ts +5 -2
  23. package/esm/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +5 -2
  24. package/package.json +1 -1
  25. package/umd/index.umd.js +164 -43
  26. package/umd/index.umd.js.map +1 -1
  27. package/umd/typings/src/_packages/types.index.d.ts +2 -2
  28. package/umd/typings/src/config.d.ts +8 -4
  29. package/umd/typings/src/conversion/pipelineStringToJsonSync.d.ts +1 -0
  30. package/umd/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -0
  31. package/umd/typings/src/execution/PipelineExecutor.d.ts +32 -24
  32. package/umd/typings/src/execution/PromptResultUsage.d.ts +3 -0
  33. package/umd/typings/src/prepare/isPipelinePrepared.d.ts +4 -0
  34. package/umd/typings/src/prepare/preparePipeline.d.ts +0 -1
  35. package/umd/typings/src/prepare/prepareTemplates.d.ts +31 -0
  36. package/umd/typings/src/prepare/unpreparePipeline.d.ts +2 -0
  37. package/umd/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +3 -0
  38. package/umd/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +3 -0
  39. package/umd/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +1 -0
  40. package/umd/typings/src/types/PipelineJson/PersonaJson.d.ts +3 -0
  41. package/umd/typings/src/types/PipelineJson/PipelineJson.d.ts +1 -0
  42. package/umd/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -0
  43. package/umd/typings/src/types/PipelineJson/PromptDialogJson.d.ts +4 -3
  44. package/umd/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +10 -0
  45. package/umd/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +1 -0
  46. package/umd/typings/src/types/PipelineJson/ScriptJson.d.ts +5 -2
  47. package/umd/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +5 -2
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) {
@@ -923,14 +930,17 @@ var ReferenceError$1 = /** @class */ (function (_super) {
923
930
  * Unprepare just strips the preparation data of the pipeline
924
931
  */
925
932
  function unpreparePipeline(pipeline) {
926
- var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources;
933
+ var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, promptTemplates = pipeline.promptTemplates;
927
934
  personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
928
935
  knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
929
- return __assign(__assign({}, pipeline), { knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] });
936
+ promptTemplates = promptTemplates.map(function (promptTemplate) { return (__assign(__assign({}, promptTemplate), { preparedContent: undefined })); });
937
+ return __assign(__assign({}, pipeline), { promptTemplates: promptTemplates, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] });
930
938
  }
931
939
  /**
932
940
  * TODO: [๐Ÿ”ผ] !!! Export via `@promptbook/core`
941
+ * TODO: [๐Ÿงฟ] Maybe do same process with same granularity and subfinctions as `preparePipeline`
933
942
  * TODO: Write tests for `preparePipeline`
943
+ * TODO: [๐Ÿ™] Make some standart order of json properties
934
944
  */
935
945
 
936
946
  /**
@@ -1447,7 +1457,7 @@ function forEachAsync(array, options, callbackfunction) {
1447
1457
  });
1448
1458
  }
1449
1459
 
1450
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-21",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-21",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-21",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-21",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-21",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-21",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-21",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-21",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"}];
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"}];
1451
1461
 
1452
1462
  var defaultDiacriticsRemovalMap = [
1453
1463
  {
@@ -2243,22 +2253,27 @@ function isPipelinePrepared(pipeline) {
2243
2253
  // Note: Ignoring `pipeline.preparations` @@@
2244
2254
  // Note: Ignoring `pipeline.knowledgePieces` @@@
2245
2255
  if (!pipeline.personas.every(function (persona) { return persona.modelRequirements !== undefined; })) {
2246
- console.log('!!!!', 'Not all personas have modelRequirements');
2247
2256
  return false;
2248
2257
  }
2249
2258
  if (!pipeline.knowledgeSources.every(function (knowledgeSource) { return knowledgeSource.preparationIds !== undefined; })) {
2250
- console.log('!!!!', 'Not all knowledgeSources have preparationIds');
2251
2259
  return false;
2252
2260
  }
2253
- // TODO: !!!!! Is context in each template
2254
- // TODO: !!!!! Are samples prepared
2255
- // TODO: !!!!! Are templates prepared
2261
+ /*
2262
+ TODO: [๐Ÿง ][๐Ÿซ] `promptTemplates` can not be determined if they are fully prepared SO ignoring them
2263
+ > if (!pipeline.promptTemplates.every(({ preparedContent }) => preparedContent === undefined)) {
2264
+ > return false;
2265
+ > }
2266
+ */
2256
2267
  return true;
2257
2268
  }
2258
2269
  /**
2259
2270
  * TODO: [๐Ÿ ] Maybe base this on `makeValidator`
2260
2271
  * TODO: [๐Ÿ”ผ] Export via core or utils
2261
2272
  * TODO: [๐ŸงŠ] Pipeline can be partially prepared, this should return true ONLY if fully prepared
2273
+ * TODO: [๐Ÿงฟ] Maybe do same process with same granularity and subfinctions as `preparePipeline`
2274
+ * - Is context in each template
2275
+ * - Are samples prepared
2276
+ * - Are templates prepared
2262
2277
  */
2263
2278
 
2264
2279
  /**
@@ -2320,6 +2335,22 @@ var LimitReachedError = /** @class */ (function (_super) {
2320
2335
  * @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
2321
2336
  */
2322
2337
  function replaceParameters(template, parameters) {
2338
+ var e_1, _a;
2339
+ try {
2340
+ for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
2341
+ var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
2342
+ if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
2343
+ throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
2344
+ }
2345
+ }
2346
+ }
2347
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2348
+ finally {
2349
+ try {
2350
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2351
+ }
2352
+ finally { if (e_1) throw e_1.error; }
2353
+ }
2323
2354
  var replacedTemplate = template;
2324
2355
  var match;
2325
2356
  var loopLimit = LOOP_LIMIT;
@@ -2445,7 +2476,7 @@ function union() {
2445
2476
  /**
2446
2477
  * The version of the Promptbook library
2447
2478
  */
2448
- var PROMPTBOOK_VERSION = '0.61.0-21';
2479
+ var PROMPTBOOK_VERSION = '0.61.0-23';
2449
2480
  // TODO: !!!! List here all the versions and annotate + put into script
2450
2481
 
2451
2482
  /**
@@ -2596,14 +2627,25 @@ function createPipelineExecutor(options) {
2596
2627
  pipeline = rawPipeline;
2597
2628
  }
2598
2629
  else {
2599
- 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 ")));
2630
+ // TODO: !!!! This should be maybe warning in report
2631
+ 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 ")));
2600
2632
  }
2601
2633
  var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
2634
+ // TODO: !!!!! Extract to separate functions and files - ALL FUNCTIONS BELOW
2602
2635
  function getContextForTemplate(// <- TODO: [๐Ÿง ][๐Ÿฅœ]
2603
2636
  template) {
2604
2637
  return __awaiter(this, void 0, void 0, function () {
2605
2638
  return __generator(this, function (_a) {
2606
- // TODO: !!!!!! Implement Better - use real index and keyword search
2639
+ TODO_USE(template);
2640
+ return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: !!!! Implement */];
2641
+ });
2642
+ });
2643
+ }
2644
+ function getKnowledgeForTemplate(// <- TODO: [๐Ÿง ][๐Ÿฅœ]
2645
+ template) {
2646
+ return __awaiter(this, void 0, void 0, function () {
2647
+ return __generator(this, function (_a) {
2648
+ // TODO: !!!! Implement Better - use real index and keyword search
2607
2649
  TODO_USE(template);
2608
2650
  return [2 /*return*/, pipeline.knowledgePieces.map(function (_a) {
2609
2651
  var content = _a.content;
@@ -2612,19 +2654,39 @@ function createPipelineExecutor(options) {
2612
2654
  });
2613
2655
  });
2614
2656
  }
2657
+ function getSamplesForTemplate(// <- TODO: [๐Ÿง ][๐Ÿฅœ]
2658
+ template) {
2659
+ return __awaiter(this, void 0, void 0, function () {
2660
+ return __generator(this, function (_a) {
2661
+ // TODO: !!!! Implement Better - use real index and keyword search
2662
+ TODO_USE(template);
2663
+ return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: !!!! Implement */];
2664
+ });
2665
+ });
2666
+ }
2615
2667
  function getReservedParametersForTemplate(template) {
2616
2668
  return __awaiter(this, void 0, void 0, function () {
2617
- var context, currentDate, reservedParameters, RESERVED_PARAMETER_NAMES_1, RESERVED_PARAMETER_NAMES_1_1, parameterName;
2669
+ var context, knowledge, samples, currentDate, modelName, reservedParameters, RESERVED_PARAMETER_NAMES_1, RESERVED_PARAMETER_NAMES_1_1, parameterName;
2618
2670
  var e_3, _a;
2619
2671
  return __generator(this, function (_b) {
2620
2672
  switch (_b.label) {
2621
2673
  case 0: return [4 /*yield*/, getContextForTemplate(template)];
2622
2674
  case 1:
2623
2675
  context = _b.sent();
2676
+ return [4 /*yield*/, getKnowledgeForTemplate(template)];
2677
+ case 2:
2678
+ knowledge = _b.sent();
2679
+ return [4 /*yield*/, getSamplesForTemplate(template)];
2680
+ case 3:
2681
+ samples = _b.sent();
2624
2682
  currentDate = new Date().toISOString();
2683
+ modelName = RESERVED_PARAMETER_MISSING_VALUE;
2625
2684
  reservedParameters = {
2626
2685
  context: context,
2686
+ knowledge: knowledge,
2687
+ samples: samples,
2627
2688
  currentDate: currentDate,
2689
+ modelName: modelName,
2628
2690
  };
2629
2691
  try {
2630
2692
  // Note: Doublecheck that ALL reserved parameters are defined:
@@ -2649,7 +2711,7 @@ function createPipelineExecutor(options) {
2649
2711
  }
2650
2712
  function executeSingleTemplate(currentTemplate) {
2651
2713
  return __awaiter(this, void 0, void 0, function () {
2652
- var name, title, priority, usedParameterNames, dependentParameterNames, definedParameters, _a, _b, _c, definedParameterNames, parameters, _d, _e, parameterName, prompt, chatResult, completionResult, embeddingResult, result, resultString, expectError, scriptPipelineExecutionErrors, maxAttempts, jokerParameterNames, attempt, isJokerAttempt, jokerParameterName, _f, _g, _h, _j, scriptTools, error_2, e_4_1, _k, _l, functionName, postprocessingError, _m, _o, scriptTools, error_3, e_5_1, e_6_1, error_4;
2714
+ var name, title, priority, usedParameterNames, dependentParameterNames, definedParameters, _a, _b, _c, definedParameterNames, parameters, _d, _e, parameterName, prompt, chatResult, completionResult, embeddingResult, result, resultString, expectError, scriptPipelineExecutionErrors, maxAttempts, jokerParameterNames, preparedContent, attempt, isJokerAttempt, jokerParameterName, _f, _g, _h, _j, scriptTools, error_2, e_4_1, _k, _l, functionName, postprocessingError, _m, _o, scriptTools, error_3, e_5_1, e_6_1, error_4;
2653
2715
  var e_7, _p, e_4, _q, e_6, _r, e_5, _s, _t;
2654
2716
  var _this = this;
2655
2717
  return __generator(this, function (_u) {
@@ -2719,6 +2781,9 @@ function createPipelineExecutor(options) {
2719
2781
  expectError = null;
2720
2782
  maxAttempts = currentTemplate.blockType === 'PROMPT_DIALOG' ? Infinity : maxExecutionAttempts;
2721
2783
  jokerParameterNames = currentTemplate.jokerParameterNames || [];
2784
+ preparedContent = (currentTemplate.preparedContent || '{content}')
2785
+ .split('{content}')
2786
+ .join(currentTemplate.content);
2722
2787
  attempt = -jokerParameterNames.length;
2723
2788
  _u.label = 4;
2724
2789
  case 4:
@@ -2753,7 +2818,7 @@ function createPipelineExecutor(options) {
2753
2818
  }
2754
2819
  return [3 /*break*/, 29];
2755
2820
  case 6:
2756
- resultString = replaceParameters(currentTemplate.content, parameters);
2821
+ resultString = replaceParameters(preparedContent, parameters);
2757
2822
  return [3 /*break*/, 30];
2758
2823
  case 7:
2759
2824
  prompt = {
@@ -2762,7 +2827,7 @@ function createPipelineExecutor(options) {
2762
2827
  ? pipeline.pipelineUrl
2763
2828
  : 'anonymous' /* <- TODO: [๐Ÿง ] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(currentTemplate.name),
2764
2829
  parameters: parameters,
2765
- content: currentTemplate.content,
2830
+ content: preparedContent,
2766
2831
  modelRequirements: currentTemplate.modelRequirements,
2767
2832
  expectations: __assign(__assign({}, (pipeline.personas.find(function (_a) {
2768
2833
  var name = _a.name;
@@ -2884,7 +2949,7 @@ function createPipelineExecutor(options) {
2884
2949
  _u.trys.push([19, 21, , 22]);
2885
2950
  return [4 /*yield*/, scriptTools.execute(deepFreeze({
2886
2951
  scriptLanguage: currentTemplate.contentLanguage,
2887
- script: currentTemplate.content,
2952
+ script: preparedContent,
2888
2953
  parameters: parameters,
2889
2954
  }))];
2890
2955
  case 20:
@@ -2933,7 +2998,7 @@ function createPipelineExecutor(options) {
2933
2998
  return [4 /*yield*/, tools.userInterface.promptDialog(deepFreeze({
2934
2999
  promptTitle: currentTemplate.title,
2935
3000
  promptMessage: replaceParameters(currentTemplate.description || '', parameters),
2936
- defaultValue: replaceParameters(currentTemplate.content, parameters),
3001
+ defaultValue: replaceParameters(preparedContent, parameters),
2937
3002
  // TODO: [๐Ÿง ] !! Figure out how to define placeholder in .ptbk.md file
2938
3003
  placeholder: undefined,
2939
3004
  priority: priority,
@@ -3111,7 +3176,7 @@ function createPipelineExecutor(options) {
3111
3176
  var parameter = _c.value;
3112
3177
  if (parametersToPass[parameter.name] === undefined) {
3113
3178
  // [4]
3114
- errors.push(new PipelineExecutionError("Parameter {".concat(parameter.name, "} should be an output parameter, but it was not be resolved")));
3179
+ warnings.push(new PipelineExecutionError("Parameter {".concat(parameter.name, "} should be an output parameter, but it was not generated during pipeline execution")));
3115
3180
  continue;
3116
3181
  }
3117
3182
  outputParameters[parameter.name] = parametersToPass[parameter.name] || '';
@@ -3126,7 +3191,7 @@ function createPipelineExecutor(options) {
3126
3191
  }
3127
3192
  return outputParameters;
3128
3193
  }
3129
- var executionReport, _a, _b, parameter, errors, _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;
3194
+ var errors, warnings, executionReport, _a, _b, parameter, _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;
3130
3195
  var e_1, _e, e_2, _f;
3131
3196
  return __generator(this, function (_g) {
3132
3197
  switch (_g.label) {
@@ -3141,6 +3206,8 @@ function createPipelineExecutor(options) {
3141
3206
  pipeline = _g.sent();
3142
3207
  _g.label = 2;
3143
3208
  case 2:
3209
+ errors = [];
3210
+ warnings = [];
3144
3211
  executionReport = {
3145
3212
  pipelineUrl: pipeline.pipelineUrl,
3146
3213
  title: pipeline.title,
@@ -3159,10 +3226,10 @@ function createPipelineExecutor(options) {
3159
3226
  if (inputParameters[parameter.name] === undefined) {
3160
3227
  return [2 /*return*/, deepFreezeWithSameType({
3161
3228
  isSuccessful: false,
3162
- errors: [
3163
- new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter")),
3164
- // <- TODO: !!!!! Test this error
3165
- ],
3229
+ errors: __spreadArray([
3230
+ new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter"))
3231
+ ], __read(errors), false),
3232
+ warnings: [],
3166
3233
  executionReport: executionReport,
3167
3234
  outputParameters: {},
3168
3235
  usage: ZERO_USAGE,
@@ -3177,22 +3244,21 @@ function createPipelineExecutor(options) {
3177
3244
  }
3178
3245
  finally { if (e_1) throw e_1.error; }
3179
3246
  }
3180
- errors = [];
3181
3247
  _loop_1 = function (parameterName) {
3182
3248
  var parameter = pipeline.parameters.find(function (_a) {
3183
3249
  var name = _a.name;
3184
3250
  return name === parameterName;
3185
3251
  });
3186
3252
  if (parameter === undefined) {
3187
- errors.push(new PipelineExecutionError("Extra parameter {".concat(parameterName, "} is passed as input parameter")));
3253
+ warnings.push(new PipelineExecutionError("Extra parameter {".concat(parameterName, "} is being passed which is not part of the pipeline.")));
3188
3254
  }
3189
3255
  else if (parameter.isInput === false) {
3190
3256
  return { value: deepFreezeWithSameType({
3191
3257
  isSuccessful: false,
3192
- errors: [
3193
- new PipelineExecutionError("Parameter {".concat(parameter.name, "} is passed as input parameter but is not input")),
3194
- // <- TODO: !!!!! Test this error
3195
- ],
3258
+ errors: __spreadArray([
3259
+ new PipelineExecutionError("Parameter {".concat(parameter.name, "} is passed as input parameter but it is not input"))
3260
+ ], __read(errors), false),
3261
+ warnings: warnings,
3196
3262
  executionReport: executionReport,
3197
3263
  outputParameters: {},
3198
3264
  usage: ZERO_USAGE,
@@ -3301,6 +3367,7 @@ function createPipelineExecutor(options) {
3301
3367
  return [2 /*return*/, deepFreezeWithSameType({
3302
3368
  isSuccessful: false,
3303
3369
  errors: __spreadArray([error_1], __read(errors), false),
3370
+ warnings: warnings,
3304
3371
  usage: usage_1,
3305
3372
  executionReport: executionReport,
3306
3373
  outputParameters: outputParameters_1,
@@ -3314,6 +3381,7 @@ function createPipelineExecutor(options) {
3314
3381
  return [2 /*return*/, deepFreezeWithSameType({
3315
3382
  isSuccessful: true,
3316
3383
  errors: errors,
3384
+ warnings: warnings,
3317
3385
  usage: usage,
3318
3386
  executionReport: executionReport,
3319
3387
  outputParameters: outputParameters,
@@ -3340,7 +3408,7 @@ function createPipelineExecutor(options) {
3340
3408
  */
3341
3409
  function prepareKnowledgeFromMarkdown(content /* <- TODO: [๐Ÿ––] (?maybe not) Always the file */, options) {
3342
3410
  return __awaiter(this, void 0, void 0, function () {
3343
- var llmTools, _a, maxParallelCount, _b, isVerbose, collection, prepareKnowledgeFromMarkdownExecutor, _c, prepareTitleExecutor, _d, prepareKeywordsExecutor, _e, result, outputParameters, knowledgeRaw, knowledgeTextPieces, knowledge;
3411
+ var llmTools, _a, maxParallelCount, _b, isVerbose, collection, prepareKnowledgeFromMarkdownExecutor, _c, prepareTitleExecutor, _d, prepareKeywordsExecutor, _e, result, outputParameters, knowledgePiecesRaw, knowledgeTextPieces, knowledge;
3344
3412
  var _f, _g, _h;
3345
3413
  var _this = this;
3346
3414
  return __generator(this, function (_j) {
@@ -3381,8 +3449,8 @@ function prepareKnowledgeFromMarkdown(content /* <- TODO: [๐Ÿ––] (?maybe not) Al
3381
3449
  result = _j.sent();
3382
3450
  assertsExecutionSuccessful(result);
3383
3451
  outputParameters = result.outputParameters;
3384
- knowledgeRaw = outputParameters.knowledge;
3385
- knowledgeTextPieces = (knowledgeRaw || '').split('\n---\n');
3452
+ knowledgePiecesRaw = outputParameters.knowledgePieces;
3453
+ knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
3386
3454
  if (isVerbose) {
3387
3455
  console.info('knowledgeTextPieces:', knowledgeTextPieces);
3388
3456
  }
@@ -3596,6 +3664,53 @@ function preparePersona(personaDescription, options) {
3596
3664
  * TODO: [๐Ÿข] !! Check validity of `temperature` in pipeline
3597
3665
  */
3598
3666
 
3667
+ /**
3668
+ * @@@
3669
+ */
3670
+ function prepareTemplates(pipeline, options) {
3671
+ return __awaiter(this, void 0, void 0, function () {
3672
+ var _a, maxParallelCount, promptTemplates, parameters, knowledgePiecesCount, promptTemplatesPrepared;
3673
+ var _this = this;
3674
+ return __generator(this, function (_b) {
3675
+ switch (_b.label) {
3676
+ case 0:
3677
+ _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a;
3678
+ promptTemplates = pipeline.promptTemplates, parameters = pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
3679
+ // TODO: !!!! Apply samples to each template (if missing and is for the template defined)
3680
+ TODO_USE(parameters);
3681
+ promptTemplatesPrepared = new Array(promptTemplates.length);
3682
+ 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;
3684
+ return __generator(this, function (_a) {
3685
+ preparedContent = undefined;
3686
+ if (knowledgePiecesCount > 0) {
3687
+ preparedContent = spaceTrim$1("\n {content}\n\n ## Knowledge\n\n {knowledge}\n ");
3688
+ // <- TODO: [๐Ÿง ][๐Ÿงป] Cutomize shape/language/formatting of the addition to the prompt
3689
+ }
3690
+ preparedTemplate = __assign(__assign({}, template), { preparedContent: preparedContent });
3691
+ promptTemplatesPrepared[index] = preparedTemplate;
3692
+ return [2 /*return*/];
3693
+ });
3694
+ }); })];
3695
+ case 1:
3696
+ _b.sent();
3697
+ return [2 /*return*/, { promptTemplatesPrepared: promptTemplatesPrepared }];
3698
+ }
3699
+ });
3700
+ });
3701
+ }
3702
+ /**
3703
+ * TODO: [๐Ÿง ] Add context to each template (if missing)
3704
+ * TODO: [๐Ÿง ] What is better name `prepareTemplate` or `prepareTemplateAndParameters`
3705
+ * TODO: !!!!! Index the samples and maybe templates
3706
+ * TODO: [๐Ÿ”ผ] !!! Export via `@promptbook/core`
3707
+ * TODO: Write tests for `preparePipeline`
3708
+ * TODO: [๐Ÿ] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
3709
+ * TODO: [๐ŸงŠ] In future one preparation can take data from previous preparation and save tokens and time
3710
+ * TODO: [๐Ÿ› ] Actions, instruments (and maybe knowledge) => Functions and tools
3711
+ * TODO: [๐Ÿง ][๐Ÿฅœ]
3712
+ */
3713
+
3599
3714
  /**
3600
3715
  * Prepare pipeline from string (markdown) format to JSON format
3601
3716
  *
@@ -3604,18 +3719,18 @@ function preparePersona(personaDescription, options) {
3604
3719
  */
3605
3720
  function preparePipeline(pipeline, options) {
3606
3721
  return __awaiter(this, void 0, void 0, function () {
3607
- var _a, maxParallelCount,
3722
+ var _a, maxParallelCount, parameters, promptTemplates,
3608
3723
  /*
3609
3724
  <- TODO: [๐Ÿง ][0] `promptbookVersion` */
3610
3725
  knowledgeSources /*
3611
3726
  <- TODO: [๐ŸงŠ] `knowledgePieces` */, personas /*
3612
- <- TODO: [๐ŸงŠ] `preparations` */, currentPreparation, preparations, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared;
3727
+ <- TODO: [๐ŸงŠ] `preparations` */, currentPreparation, preparations, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared, promptTemplatesPrepared /* TODO: parameters: parametersPrepared*/;
3613
3728
  var _this = this;
3614
3729
  return __generator(this, function (_b) {
3615
3730
  switch (_b.label) {
3616
3731
  case 0:
3617
3732
  _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a;
3618
- knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
3733
+ parameters = pipeline.parameters, promptTemplates = pipeline.promptTemplates, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
3619
3734
  currentPreparation = {
3620
3735
  id: 1,
3621
3736
  // TODO: [๐Ÿฅ]> date: $currentDate(),
@@ -3648,16 +3763,20 @@ function preparePipeline(pipeline, options) {
3648
3763
  case 2:
3649
3764
  partialknowledgePiecesPrepared = _b.sent();
3650
3765
  knowledgePiecesPrepared = partialknowledgePiecesPrepared.map(function (piece) { return (__assign(__assign({}, piece), { preparationIds: [/* TODO: [๐ŸงŠ] -> */ currentPreparation.id] })); });
3651
- // ----- /Knowledge preparation -----
3652
- // TODO: !!!!! Add context to each template (if missing)
3653
- // TODO: !!!!! Apply samples to each template (if missing)
3654
- return [2 /*return*/, __assign(__assign({}, pipeline), { knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: preparations })];
3766
+ return [4 /*yield*/, prepareTemplates({
3767
+ parameters: parameters,
3768
+ promptTemplates: promptTemplates,
3769
+ knowledgePiecesCount: knowledgePiecesPrepared.length,
3770
+ }, options)];
3771
+ case 3:
3772
+ promptTemplatesPrepared = (_b.sent()).promptTemplatesPrepared;
3773
+ // ----- /Templates preparation -----
3774
+ return [2 /*return*/, __assign(__assign({}, pipeline), { promptTemplates: promptTemplatesPrepared, knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: preparations })];
3655
3775
  }
3656
3776
  });
3657
3777
  });
3658
3778
  }
3659
3779
  /**
3660
- * TODO: !!!!! Index the samples and maybe templates
3661
3780
  * TODO: [๐Ÿ”ผ] !!! Export via `@promptbook/core`
3662
3781
  * TODO: Write tests for `preparePipeline`
3663
3782
  * TODO: [๐Ÿ] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
@@ -5573,6 +5692,7 @@ function pipelineStringToJsonSync(pipelineString) {
5573
5692
  * TODO: [๐Ÿฅž] Not optimal parsing because `splitMarkdownIntoSections` is executed twice with same string, once through `flattenMarkdown` and second directly here
5574
5693
  * TODO: [โ™ˆ] Probbably move expectations from templates to parameters
5575
5694
  * TODO: [๐Ÿ› ] Actions, instruments (and maybe knowledge) => Functions and tools
5695
+ * TODO: [๐Ÿ™] Make some standart order of json properties
5576
5696
  */
5577
5697
 
5578
5698
  /**
@@ -5809,6 +5929,7 @@ function stringifyPipelineJson(pipeline) {
5809
5929
  * TODO: !!!! Not Working propperly @see https://promptbook.studio/samples/mixed-knowledge.ptbk.md
5810
5930
  * TODO: [๐Ÿง ][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
5811
5931
  * TODO: [๐Ÿง ] Maybe more elegant solution than replacing via regex
5932
+ * TODO: [๐Ÿ™] Make some standart order of json properties
5812
5933
  */
5813
5934
 
5814
5935
  /**