@promptbook/cli 0.61.0-27 → 0.61.0-29

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
@@ -150,7 +150,7 @@ new Function("\n try {\n if (typeof WorkerGlobalScope !== 'undefined'
150
150
  /**
151
151
  * The version of the Promptbook library
152
152
  */
153
- var PROMPTBOOK_VERSION = '0.61.0-26';
153
+ var PROMPTBOOK_VERSION = '0.61.0-28';
154
154
  // TODO: !!!! List here all the versions and annotate + put into script
155
155
 
156
156
  /**
@@ -747,7 +747,7 @@ function forEachAsync(array, options, callbackfunction) {
747
747
  });
748
748
  }
749
749
 
750
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-26",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-26",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-26",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-26",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-26",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-26",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-26",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-26",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"}];
750
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-28",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-28",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-28",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-28",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-28",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-28",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-28",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-28",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"}];
751
751
 
752
752
  /**
753
753
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -2476,17 +2476,17 @@ function checkExpectations(expectations, value) {
2476
2476
  */
2477
2477
  function createPipelineExecutor(options) {
2478
2478
  var _this = this;
2479
- var rawPipeline = options.pipeline, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
2480
- var _b = settings.maxExecutionAttempts, maxExecutionAttempts = _b === void 0 ? MAX_EXECUTION_ATTEMPTS : _b, _c = settings.maxParallelCount, maxParallelCount = _c === void 0 ? MAX_PARALLEL_COUNT : _c, _d = settings.isVerbose, isVerbose = _d === void 0 ? false : _d;
2481
- validatePipeline(rawPipeline);
2479
+ var pipeline = options.pipeline, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
2480
+ var _b = settings.maxExecutionAttempts, maxExecutionAttempts = _b === void 0 ? MAX_EXECUTION_ATTEMPTS : _b, _c = settings.maxParallelCount, maxParallelCount = _c === void 0 ? MAX_PARALLEL_COUNT : _c, _d = settings.isVerbose, isVerbose = _d === void 0 ? false : _d, _e = settings.isNotPreparedWarningSupressed, isNotPreparedWarningSupressed = _e === void 0 ? false : _e;
2481
+ validatePipeline(pipeline);
2482
2482
  var llmTools = joinLlmExecutionTools.apply(void 0, __spreadArray([], __read(arrayableToArray(tools.llm)), false));
2483
- var pipeline;
2484
- if (isPipelinePrepared(rawPipeline)) {
2485
- pipeline = rawPipeline;
2483
+ var preparedPipeline;
2484
+ if (isPipelinePrepared(pipeline)) {
2485
+ preparedPipeline = pipeline;
2486
2486
  }
2487
- else {
2488
- // TODO: !!!!! This should be maybe warning in report
2489
- 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 ")));
2487
+ else if (isNotPreparedWarningSupressed !== true) {
2488
+ // TODO: !!!!! Test that this work as intended together with prepared pipeline
2489
+ console.warn(spaceTrim$1("\n Pipeline ".concat(pipeline.pipelineUrl || pipeline.sourceFile || pipeline.title, " is not prepared\n\n ").concat(pipeline.sourceFile, "\n\n It will be prepared ad-hoc before the first execution and **returned as `preparedPipeline` in `PipelineExecutorResult`**\n But it is recommended to prepare the pipeline during collection preparation\n\n @see more at https://ptbk.io/prepare-pipeline\n ")));
2490
2490
  }
2491
2491
  var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
2492
2492
  // TODO: !!! Extract to separate functions and files - ALL FUNCTIONS BELOW
@@ -2503,9 +2503,9 @@ function createPipelineExecutor(options) {
2503
2503
  template) {
2504
2504
  return __awaiter(this, void 0, void 0, function () {
2505
2505
  return __generator(this, function (_a) {
2506
- // TODO: [♨] Implement Better - use real index and keyword search
2506
+ // TODO: [♨] Implement Better - use real index and keyword search from `template` and {samples}
2507
2507
  TODO_USE(template);
2508
- return [2 /*return*/, pipeline.knowledgePieces.map(function (_a) {
2508
+ return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
2509
2509
  var content = _a.content;
2510
2510
  return "- ".concat(content);
2511
2511
  }).join('\n')];
@@ -2578,7 +2578,7 @@ function createPipelineExecutor(options) {
2578
2578
  case 0:
2579
2579
  name = "pipeline-executor-frame-".concat(currentTemplate.name);
2580
2580
  title = currentTemplate.title;
2581
- priority = pipeline.promptTemplates.length - pipeline.promptTemplates.indexOf(currentTemplate);
2581
+ priority = preparedPipeline.promptTemplates.length - preparedPipeline.promptTemplates.indexOf(currentTemplate);
2582
2582
  if (!onProgress /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
2583
2583
  return [4 /*yield*/, onProgress({
2584
2584
  name: name,
@@ -2682,13 +2682,13 @@ function createPipelineExecutor(options) {
2682
2682
  case 7:
2683
2683
  prompt = {
2684
2684
  title: currentTemplate.title,
2685
- pipelineUrl: "".concat(pipeline.pipelineUrl
2686
- ? pipeline.pipelineUrl
2685
+ pipelineUrl: "".concat(preparedPipeline.pipelineUrl
2686
+ ? preparedPipeline.pipelineUrl
2687
2687
  : 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(currentTemplate.name),
2688
2688
  parameters: parameters,
2689
2689
  content: preparedContent,
2690
2690
  modelRequirements: currentTemplate.modelRequirements,
2691
- expectations: __assign(__assign({}, (pipeline.personas.find(function (_a) {
2691
+ expectations: __assign(__assign({}, (preparedPipeline.personas.find(function (_a) {
2692
2692
  var name = _a.name;
2693
2693
  return name === currentTemplate.personaName;
2694
2694
  }) || {})), currentTemplate.expectations),
@@ -2980,7 +2980,7 @@ function createPipelineExecutor(options) {
2980
2980
  ) {
2981
2981
  // TODO: [🧠] Maybe put other blockTypes into report
2982
2982
  executionReport.promptExecutions.push({
2983
- prompt: __assign(__assign({ '!!! All information': null }, prompt), { '!!! Wanted information': null, title: currentTemplate.title /* <- Note: If title in pipeline contains emojis, pass it innto report */, content: prompt.content, modelRequirements: prompt.modelRequirements, expectations: prompt.expectations, expectFormat: prompt.expectFormat }),
2983
+ prompt: __assign({}, prompt),
2984
2984
  result: result || undefined,
2985
2985
  error: expectError || undefined,
2986
2986
  });
@@ -3021,7 +3021,7 @@ function createPipelineExecutor(options) {
3021
3021
  var outputParameters = {};
3022
3022
  try {
3023
3023
  // Note: Filter ONLY output parameters
3024
- for (var _b = __values(pipeline.parameters.filter(function (_a) {
3024
+ for (var _b = __values(preparedPipeline.parameters.filter(function (_a) {
3025
3025
  var isOutput = _a.isOutput;
3026
3026
  return isOutput;
3027
3027
  })), _c = _b.next(); !_c.done; _c = _b.next()) {
@@ -3048,29 +3048,29 @@ function createPipelineExecutor(options) {
3048
3048
  return __generator(this, function (_g) {
3049
3049
  switch (_g.label) {
3050
3050
  case 0:
3051
- if (!(pipeline === undefined)) return [3 /*break*/, 2];
3052
- return [4 /*yield*/, preparePipeline(rawPipeline, {
3051
+ if (!(preparedPipeline === undefined)) return [3 /*break*/, 2];
3052
+ return [4 /*yield*/, preparePipeline(pipeline, {
3053
3053
  llmTools: llmTools,
3054
3054
  isVerbose: isVerbose,
3055
3055
  maxParallelCount: maxParallelCount,
3056
3056
  })];
3057
3057
  case 1:
3058
- pipeline = _g.sent();
3058
+ preparedPipeline = _g.sent();
3059
3059
  _g.label = 2;
3060
3060
  case 2:
3061
3061
  errors = [];
3062
3062
  warnings = [];
3063
3063
  executionReport = {
3064
- pipelineUrl: pipeline.pipelineUrl,
3065
- title: pipeline.title,
3064
+ pipelineUrl: preparedPipeline.pipelineUrl,
3065
+ title: preparedPipeline.title,
3066
3066
  promptbookUsedVersion: PROMPTBOOK_VERSION,
3067
- promptbookRequestedVersion: pipeline.promptbookVersion,
3068
- description: pipeline.description,
3067
+ promptbookRequestedVersion: preparedPipeline.promptbookVersion,
3068
+ description: preparedPipeline.description,
3069
3069
  promptExecutions: [],
3070
3070
  };
3071
3071
  try {
3072
3072
  // Note: Check that all input input parameters are defined
3073
- for (_a = __values(pipeline.parameters.filter(function (_a) {
3073
+ for (_a = __values(preparedPipeline.parameters.filter(function (_a) {
3074
3074
  var isInput = _a.isInput;
3075
3075
  return isInput;
3076
3076
  })), _b = _a.next(); !_b.done; _b = _a.next()) {
@@ -3085,6 +3085,7 @@ function createPipelineExecutor(options) {
3085
3085
  executionReport: executionReport,
3086
3086
  outputParameters: {},
3087
3087
  usage: ZERO_USAGE,
3088
+ preparedPipeline: preparedPipeline,
3088
3089
  })];
3089
3090
  }
3090
3091
  }
@@ -3097,7 +3098,7 @@ function createPipelineExecutor(options) {
3097
3098
  finally { if (e_1) throw e_1.error; }
3098
3099
  }
3099
3100
  _loop_1 = function (parameterName) {
3100
- var parameter = pipeline.parameters.find(function (_a) {
3101
+ var parameter = preparedPipeline.parameters.find(function (_a) {
3101
3102
  var name = _a.name;
3102
3103
  return name === parameterName;
3103
3104
  });
@@ -3114,6 +3115,7 @@ function createPipelineExecutor(options) {
3114
3115
  executionReport: executionReport,
3115
3116
  outputParameters: {},
3116
3117
  usage: ZERO_USAGE,
3118
+ preparedPipeline: preparedPipeline,
3117
3119
  }) };
3118
3120
  }
3119
3121
  };
@@ -3137,7 +3139,7 @@ function createPipelineExecutor(options) {
3137
3139
  _g.label = 3;
3138
3140
  case 3:
3139
3141
  _g.trys.push([3, 8, , 9]);
3140
- resovedParameterNames_1 = pipeline.parameters
3142
+ resovedParameterNames_1 = preparedPipeline.parameters
3141
3143
  .filter(function (_a) {
3142
3144
  var isInput = _a.isInput;
3143
3145
  return isInput;
@@ -3146,7 +3148,7 @@ function createPipelineExecutor(options) {
3146
3148
  var name = _a.name;
3147
3149
  return name;
3148
3150
  });
3149
- unresovedTemplates_1 = __spreadArray([], __read(pipeline.promptTemplates), false);
3151
+ unresovedTemplates_1 = __spreadArray([], __read(preparedPipeline.promptTemplates), false);
3150
3152
  resolving_1 = [];
3151
3153
  loopLimit = LOOP_LIMIT;
3152
3154
  _loop_2 = function () {
@@ -3223,6 +3225,7 @@ function createPipelineExecutor(options) {
3223
3225
  usage: usage_1,
3224
3226
  executionReport: executionReport,
3225
3227
  outputParameters: outputParameters_1,
3228
+ preparedPipeline: preparedPipeline,
3226
3229
  })];
3227
3230
  case 9:
3228
3231
  usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
@@ -3237,6 +3240,7 @@ function createPipelineExecutor(options) {
3237
3240
  usage: usage,
3238
3241
  executionReport: executionReport,
3239
3242
  outputParameters: outputParameters,
3243
+ preparedPipeline: preparedPipeline,
3240
3244
  })];
3241
3245
  }
3242
3246
  });
@@ -3244,8 +3248,6 @@ function createPipelineExecutor(options) {
3244
3248
  return pipelineExecutor;
3245
3249
  }
3246
3250
  /**
3247
- * TODO: !!!!! return `preparedPipeline` from execution
3248
- * TODO: !!!!! `isNotPreparedWarningSupressed`
3249
3251
  * TODO: Use isVerbose here (not only pass to `preparePipeline`)
3250
3252
  * TODO: [🪂] Use maxParallelCount here (not only pass to `preparePipeline`)
3251
3253
  * TODO: [♈] Probbably move expectations from templates to parameters
@@ -3305,6 +3307,7 @@ function prepareKnowledgeFromMarkdown(knowledgeContent /* <- TODO: [🖖] (?mayb
3305
3307
  outputParameters = result.outputParameters;
3306
3308
  knowledgePiecesRaw = outputParameters.knowledgePieces;
3307
3309
  knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
3310
+ // <- TODO: !!!!! Smarter split and filter out empty pieces
3308
3311
  if (isVerbose) {
3309
3312
  console.info('knowledgeTextPieces:', knowledgeTextPieces);
3310
3313
  }
@@ -3530,7 +3533,7 @@ function prepareTemplates(pipeline, options) {
3530
3533
  case 0:
3531
3534
  _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a;
3532
3535
  promptTemplates = pipeline.promptTemplates, parameters = pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
3533
- // TODO: !!!!!! Apply samples to each template (if missing and is for the template defined)
3536
+ // TODO: !!!!! Apply samples to each template (if missing and is for the template defined)
3534
3537
  TODO_USE(parameters);
3535
3538
  promptTemplatesPrepared = new Array(promptTemplates.length);
3536
3539
  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 () {
@@ -3639,7 +3642,7 @@ function preparePipeline(pipeline, options) {
3639
3642
  * TODO: Write tests for `preparePipeline`
3640
3643
  * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
3641
3644
  * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
3642
- * TODO: [🎐] !!!!!! Use here countTotalUsage
3645
+ * TODO: [🎐] !!!!! Use here countTotalUsage
3643
3646
  * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
3644
3647
  */
3645
3648
 
@@ -6234,7 +6237,7 @@ var AnthropicClaudeExecutionTools = /** @class */ (function () {
6234
6237
  */
6235
6238
  AnthropicClaudeExecutionTools.prototype.callChatModel = function (prompt) {
6236
6239
  return __awaiter(this, void 0, void 0, function () {
6237
- var content, parameters, modelRequirements, modelName, rawRequest, start, complete, rawResponse, resultContent, usage;
6240
+ var content, parameters, modelRequirements, modelName, rawPromptContent, rawRequest, start, complete, rawResponse, resultContent, usage;
6238
6241
  return __generator(this, function (_a) {
6239
6242
  switch (_a.label) {
6240
6243
  case 0:
@@ -6247,6 +6250,7 @@ var AnthropicClaudeExecutionTools = /** @class */ (function () {
6247
6250
  throw new PipelineExecutionError('Use callChatModel only for CHAT variant');
6248
6251
  }
6249
6252
  modelName = modelRequirements.modelName || this.getDefaultChatModel().modelName;
6253
+ rawPromptContent = replaceParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
6250
6254
  rawRequest = {
6251
6255
  model: modelRequirements.modelName || this.getDefaultChatModel().modelName,
6252
6256
  max_tokens: modelRequirements.maxTokens || 4096,
@@ -6258,7 +6262,7 @@ var AnthropicClaudeExecutionTools = /** @class */ (function () {
6258
6262
  messages: [
6259
6263
  {
6260
6264
  role: 'user',
6261
- content: replaceParameters(content, __assign(__assign({}, parameters), { modelName: modelName })),
6265
+ content: rawPromptContent,
6262
6266
  },
6263
6267
  ],
6264
6268
  // TODO: Is here some equivalent of user identification?> user: this.options.user,
@@ -6295,8 +6299,10 @@ var AnthropicClaudeExecutionTools = /** @class */ (function () {
6295
6299
  complete: complete,
6296
6300
  },
6297
6301
  usage: usage,
6302
+ rawPromptContent: rawPromptContent,
6303
+ rawRequest: rawRequest,
6298
6304
  rawResponse: rawResponse,
6299
- // <- [🤹‍♂️]
6305
+ // <- [🗯]
6300
6306
  }];
6301
6307
  }
6302
6308
  });
@@ -6329,7 +6335,7 @@ var AnthropicClaudeExecutionTools = /** @class */ (function () {
6329
6335
 
6330
6336
  const rawRequest: xxxx.Completions.CompletionCreateParamsNonStreaming = {
6331
6337
  ...modelSettings,
6332
- prompt: replaceParameters(content, { ...parameters, modelName }),
6338
+ prompt: rawPromptContent,
6333
6339
  user: this.options.user,
6334
6340
  };
6335
6341
  const start: string_date_iso8601 = getCurrentIsoDate();
@@ -6368,7 +6374,7 @@ var AnthropicClaudeExecutionTools = /** @class */ (function () {
6368
6374
  },
6369
6375
  usage,
6370
6376
  rawResponse,
6371
- // <- [🤹‍♂️]
6377
+ // <- [🗯]
6372
6378
  };
6373
6379
  }
6374
6380
  */
@@ -6836,7 +6842,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
6836
6842
  */
6837
6843
  OpenAiExecutionTools.prototype.callChatModel = function (prompt) {
6838
6844
  return __awaiter(this, void 0, void 0, function () {
6839
- var content, parameters, modelRequirements, expectFormat, modelName, modelSettings, rawRequest, start, complete, rawResponse, resultContent, usage;
6845
+ var content, parameters, modelRequirements, expectFormat, modelName, modelSettings, rawPromptContent, rawRequest, start, complete, rawResponse, resultContent, usage;
6840
6846
  return __generator(this, function (_a) {
6841
6847
  switch (_a.label) {
6842
6848
  case 0:
@@ -6862,6 +6868,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
6862
6868
  type: 'json_object',
6863
6869
  };
6864
6870
  }
6871
+ rawPromptContent = replaceParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
6865
6872
  rawRequest = __assign(__assign({}, modelSettings), { messages: __spreadArray(__spreadArray([], __read((modelRequirements.systemMessage === undefined
6866
6873
  ? []
6867
6874
  : [
@@ -6872,7 +6879,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
6872
6879
  ])), false), [
6873
6880
  {
6874
6881
  role: 'user',
6875
- content: replaceParameters(content, __assign(__assign({}, parameters), { modelName: modelName })),
6882
+ content: rawPromptContent,
6876
6883
  },
6877
6884
  ], false), user: this.options.user });
6878
6885
  start = getCurrentIsoDate();
@@ -6907,8 +6914,10 @@ var OpenAiExecutionTools = /** @class */ (function () {
6907
6914
  complete: complete,
6908
6915
  },
6909
6916
  usage: usage,
6917
+ rawPromptContent: rawPromptContent,
6918
+ rawRequest: rawRequest,
6910
6919
  rawResponse: rawResponse,
6911
- // <- [🤹‍♂️]
6920
+ // <- [🗯]
6912
6921
  }];
6913
6922
  }
6914
6923
  });
@@ -6919,7 +6928,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
6919
6928
  */
6920
6929
  OpenAiExecutionTools.prototype.callCompletionModel = function (prompt) {
6921
6930
  return __awaiter(this, void 0, void 0, function () {
6922
- var content, parameters, modelRequirements, modelName, modelSettings, rawRequest, start, complete, rawResponse, resultContent, usage;
6931
+ var content, parameters, modelRequirements, modelName, modelSettings, rawPromptContent, rawRequest, start, complete, rawResponse, resultContent, usage;
6923
6932
  return __generator(this, function (_a) {
6924
6933
  switch (_a.label) {
6925
6934
  case 0:
@@ -6940,7 +6949,8 @@ var OpenAiExecutionTools = /** @class */ (function () {
6940
6949
  // <- TODO: [🈁] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
6941
6950
  // <- Note: [🧆]
6942
6951
  };
6943
- rawRequest = __assign(__assign({}, modelSettings), { prompt: replaceParameters(content, __assign(__assign({}, parameters), { modelName: modelName })), user: this.options.user });
6952
+ rawPromptContent = replaceParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
6953
+ rawRequest = __assign(__assign({}, modelSettings), { prompt: rawPromptContent, user: this.options.user });
6944
6954
  start = getCurrentIsoDate();
6945
6955
  if (this.options.isVerbose) {
6946
6956
  console.info(colors.bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
@@ -6970,8 +6980,10 @@ var OpenAiExecutionTools = /** @class */ (function () {
6970
6980
  complete: complete,
6971
6981
  },
6972
6982
  usage: usage,
6983
+ rawPromptContent: rawPromptContent,
6984
+ rawRequest: rawRequest,
6973
6985
  rawResponse: rawResponse,
6974
- // <- [🤹‍♂️]
6986
+ // <- [🗯]
6975
6987
  }];
6976
6988
  }
6977
6989
  });
@@ -6982,7 +6994,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
6982
6994
  */
6983
6995
  OpenAiExecutionTools.prototype.callEmbeddingModel = function (prompt) {
6984
6996
  return __awaiter(this, void 0, void 0, function () {
6985
- var content, parameters, modelRequirements, modelName, rawRequest, start, complete, rawResponse, resultContent, usage;
6997
+ var content, parameters, modelRequirements, modelName, rawPromptContent, rawRequest, start, complete, rawResponse, resultContent, usage;
6986
6998
  return __generator(this, function (_a) {
6987
6999
  switch (_a.label) {
6988
7000
  case 0:
@@ -6995,8 +7007,9 @@ var OpenAiExecutionTools = /** @class */ (function () {
6995
7007
  throw new PipelineExecutionError('Use embed only for EMBEDDING variant');
6996
7008
  }
6997
7009
  modelName = modelRequirements.modelName || this.getDefaultEmbeddingModel().modelName;
7010
+ rawPromptContent = replaceParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
6998
7011
  rawRequest = {
6999
- input: replaceParameters(content, __assign(__assign({}, parameters), { modelName: modelName })),
7012
+ input: rawPromptContent,
7000
7013
  model: modelName,
7001
7014
  };
7002
7015
  start = getCurrentIsoDate();
@@ -7024,8 +7037,10 @@ var OpenAiExecutionTools = /** @class */ (function () {
7024
7037
  complete: complete,
7025
7038
  },
7026
7039
  usage: usage,
7040
+ rawPromptContent: rawPromptContent,
7041
+ rawRequest: rawRequest,
7027
7042
  rawResponse: rawResponse,
7028
- // <- [🤹‍♂️]
7043
+ // <- [🗯]
7029
7044
  }];
7030
7045
  }
7031
7046
  });