@promptbook/cli 0.69.0-12 → 0.69.0-14

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.
@@ -47,6 +47,7 @@ import { isPassingExpectations } from '../execution/utils/checkExpectations';
47
47
  import { usageToHuman } from '../execution/utils/usageToHuman';
48
48
  import { usageToWorktime } from '../execution/utils/usageToWorktime';
49
49
  import { CsvFormatDefinition } from '../formats/csv/CsvFormatDefinition';
50
+ import { MANDATORY_CSV_SETTINGS } from '../formats/csv/CsvSettings';
50
51
  import { TextFormatDefinition } from '../formats/text/TextFormatDefinition';
51
52
  import { CallbackInterfaceTools } from '../knowledge/dialogs/callback/CallbackInterfaceTools';
52
53
  import type { CallbackInterfaceToolsOptions } from '../knowledge/dialogs/callback/CallbackInterfaceToolsOptions';
@@ -123,6 +124,7 @@ export { isPassingExpectations };
123
124
  export { usageToHuman };
124
125
  export { usageToWorktime };
125
126
  export { CsvFormatDefinition };
127
+ export { MANDATORY_CSV_SETTINGS };
126
128
  export { TextFormatDefinition };
127
129
  export { CallbackInterfaceTools };
128
130
  export type { CallbackInterfaceToolsOptions };
@@ -1,5 +1,13 @@
1
- import type { ParseConfig, UnparseConfig } from "papaparse";
1
+ import type { ParseConfig, UnparseConfig } from 'papaparse';
2
2
  /**
3
3
  * @@@
4
4
  */
5
- export type CsvSettings = ParseConfig & UnparseConfig;
5
+ export type CsvSettings = Pick<ParseConfig & UnparseConfig, 'delimiter' | 'quoteChar' | 'newline' | 'skipEmptyLines'>;
6
+ /**
7
+ * @@@
8
+ *
9
+ * @public exported from `@promptbook/core`
10
+ */
11
+ export declare const MANDATORY_CSV_SETTINGS: Readonly<{
12
+ readonly header: true;
13
+ }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/cli",
3
- "version": "0.69.0-12",
3
+ "version": "0.69.0-14",
4
4
  "description": "Supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -39,7 +39,7 @@
39
39
  /**
40
40
  * The version of the Promptbook library
41
41
  */
42
- var PROMPTBOOK_VERSION = '0.69.0-11';
42
+ var PROMPTBOOK_VERSION = '0.69.0-13';
43
43
  // TODO: !!!! List here all the versions and annotate + put into script
44
44
 
45
45
  /*! *****************************************************************************
@@ -526,14 +526,12 @@
526
526
  *
527
527
  * @public exported from `@promptbook/core`
528
528
  */
529
- var DEFAULT_CSV_SETTINGS = {
530
- header: true,
529
+ var DEFAULT_CSV_SETTINGS = Object.freeze({
531
530
  delimiter: ',',
532
531
  quoteChar: '"',
533
532
  newline: '\n',
534
533
  skipEmptyLines: true,
535
- // encoding: 'utf8'
536
- };
534
+ });
537
535
  /**
538
536
  * @@@
539
537
  *
@@ -1082,7 +1080,7 @@
1082
1080
  });
1083
1081
  }
1084
1082
 
1085
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.69.0-11",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.69.0-11",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.69.0-11",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.69.0-11",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
1083
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.69.0-13",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.69.0-13",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.69.0-13",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.69.0-13",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
1086
1084
 
1087
1085
  /**
1088
1086
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -2505,9 +2503,7 @@
2505
2503
  throw new PipelineExecutionError("You have not provided any `LlmExecutionTools`");
2506
2504
  }
2507
2505
  else {
2508
- throw new PipelineExecutionError(spaceTrim__default["default"](function (block) { return "\n You have not provided any `LlmExecutionTools` that support model variant \"".concat(prompt.modelRequirements.modelVariant, "\n\n Available `LlmExecutionTools`:\n ").concat(block(_this.llmExecutionTools
2509
- .map(function (tools) { return "- ".concat(tools.title, " ").concat(tools.description || ''); })
2510
- .join('\n')), "\n\n "); }));
2506
+ throw new PipelineExecutionError(spaceTrim__default["default"](function (block) { return "\n You have not provided any `LlmExecutionTools` that support model variant \"".concat(prompt.modelRequirements.modelVariant, "\"\n\n Available `LlmExecutionTools`:\n ").concat(block(_this.llmExecutionTools.map(function (tools) { return "- ".concat(tools.title); }).join('\n')), "\n\n "); }));
2511
2507
  }
2512
2508
  }
2513
2509
  });
@@ -2813,6 +2809,16 @@
2813
2809
  }
2814
2810
  }
2815
2811
 
2812
+ /**
2813
+ * @@@
2814
+ *
2815
+ * @public exported from `@promptbook/core`
2816
+ */
2817
+ var MANDATORY_CSV_SETTINGS = Object.freeze({
2818
+ header: true,
2819
+ // encoding: 'utf8',
2820
+ });
2821
+
2816
2822
  /**
2817
2823
  * Definition for CSV spreadsheet
2818
2824
  *
@@ -2851,7 +2857,7 @@
2851
2857
  return __generator(this, function (_a) {
2852
2858
  switch (_a.label) {
2853
2859
  case 0:
2854
- csv = papaparse.parse(value, settings);
2860
+ csv = papaparse.parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
2855
2861
  if (csv.errors.length !== 0) {
2856
2862
  throw new ParseError(// <- TODO: !!!!!! Split PipelineParseError and FormatParseError -> CsvParseError
2857
2863
  spaceTrim__default["default"](function (block) { return "\n CSV parsing error\n\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n "); }));
@@ -2876,7 +2882,7 @@
2876
2882
  }); }))];
2877
2883
  case 1:
2878
2884
  mappedData = _a.sent();
2879
- return [2 /*return*/, papaparse.unparse(mappedData, settings)];
2885
+ return [2 /*return*/, papaparse.unparse(mappedData, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS))];
2880
2886
  }
2881
2887
  });
2882
2888
  });
@@ -2891,7 +2897,7 @@
2891
2897
  return __generator(this, function (_a) {
2892
2898
  switch (_a.label) {
2893
2899
  case 0:
2894
- csv = papaparse.parse(value, settings);
2900
+ csv = papaparse.parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
2895
2901
  if (csv.errors.length !== 0) {
2896
2902
  throw new ParseError(// <- TODO: !!!!!! Split PipelineParseError and FormatParseError -> CsvParseError
2897
2903
  spaceTrim__default["default"](function (block) { return "\n CSV parsing error\n\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n "); }));
@@ -2914,7 +2920,7 @@
2914
2920
  }); }))];
2915
2921
  case 1:
2916
2922
  mappedData = _a.sent();
2917
- return [2 /*return*/, papaparse.unparse(mappedData, settings)];
2923
+ return [2 /*return*/, papaparse.unparse(mappedData, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS))];
2918
2924
  }
2919
2925
  });
2920
2926
  });
@@ -3535,10 +3541,10 @@
3535
3541
  $scriptPipelineExecutionErrors: [],
3536
3542
  };
3537
3543
  _loop_1 = function (attempt) {
3538
- var isJokerAttempt, jokerParameterName, _b, modelRequirements, _c, _d, _e, _f, _g, _h, scriptTools, _j, error_1, e_1_1, _k, _l, _m, functionName, postprocessingError, _o, _p, scriptTools, _q, error_2, e_2_1, e_3_1, error_3;
3539
- var e_1, _r, e_3, _s, e_2, _t;
3540
- return __generator(this, function (_u) {
3541
- switch (_u.label) {
3544
+ var isJokerAttempt, jokerParameterName, _b, modelRequirements, _c, _d, _e, _f, _g, scriptTools, _h, error_1, e_1_1, _j, _k, _l, functionName, postprocessingError, _m, _o, scriptTools, _p, error_2, e_2_1, e_3_1, error_3;
3545
+ var e_1, _q, e_3, _r, e_2, _s;
3546
+ return __generator(this, function (_t) {
3547
+ switch (_t.label) {
3542
3548
  case 0:
3543
3549
  isJokerAttempt = attempt < 0;
3544
3550
  jokerParameterName = jokerParameterNames[jokerParameterNames.length + attempt];
@@ -3558,21 +3564,21 @@
3558
3564
  $ongoingTemplateResult.$resultString = parameters[jokerParameterName];
3559
3565
  }
3560
3566
  }
3561
- _u.label = 1;
3567
+ _t.label = 1;
3562
3568
  case 1:
3563
- _u.trys.push([1, 44, 45, 46]);
3564
- if (!!isJokerAttempt) return [3 /*break*/, 26];
3569
+ _t.trys.push([1, 43, 44, 45]);
3570
+ if (!!isJokerAttempt) return [3 /*break*/, 25];
3565
3571
  _b = template.templateType;
3566
3572
  switch (_b) {
3567
3573
  case 'SIMPLE_TEMPLATE': return [3 /*break*/, 2];
3568
3574
  case 'PROMPT_TEMPLATE': return [3 /*break*/, 3];
3569
- case 'SCRIPT_TEMPLATE': return [3 /*break*/, 12];
3570
- case 'DIALOG_TEMPLATE': return [3 /*break*/, 23];
3575
+ case 'SCRIPT_TEMPLATE': return [3 /*break*/, 11];
3576
+ case 'DIALOG_TEMPLATE': return [3 /*break*/, 22];
3571
3577
  }
3572
- return [3 /*break*/, 25];
3578
+ return [3 /*break*/, 24];
3573
3579
  case 2:
3574
3580
  $ongoingTemplateResult.$resultString = replaceParameters(preparedContent, parameters);
3575
- return [3 /*break*/, 26];
3581
+ return [3 /*break*/, 25];
3576
3582
  case 3:
3577
3583
  modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (template.modelRequirements || {}));
3578
3584
  $ongoingTemplateResult.$prompt = {
@@ -3597,67 +3603,57 @@
3597
3603
  case 'COMPLETION': return [3 /*break*/, 6];
3598
3604
  case 'EMBEDDING': return [3 /*break*/, 8];
3599
3605
  }
3600
- return [3 /*break*/, 10];
3606
+ return [3 /*break*/, 9];
3601
3607
  case 4:
3602
3608
  _d = $ongoingTemplateResult;
3603
3609
  return [4 /*yield*/, llmTools.callChatModel($deepFreeze($ongoingTemplateResult.$prompt))];
3604
3610
  case 5:
3605
- _d.$chatResult = _u.sent();
3611
+ _d.$chatResult = _t.sent();
3606
3612
  // TODO: [🍬] Destroy chatThread
3607
3613
  $ongoingTemplateResult.$result = $ongoingTemplateResult.$chatResult;
3608
3614
  $ongoingTemplateResult.$resultString = $ongoingTemplateResult.$chatResult.content;
3609
- return [3 /*break*/, 11];
3615
+ return [3 /*break*/, 10];
3610
3616
  case 6:
3611
3617
  _e = $ongoingTemplateResult;
3612
3618
  return [4 /*yield*/, llmTools.callCompletionModel($deepFreeze($ongoingTemplateResult.$prompt))];
3613
3619
  case 7:
3614
- _e.$completionResult = _u.sent();
3620
+ _e.$completionResult = _t.sent();
3615
3621
  $ongoingTemplateResult.$result = $ongoingTemplateResult.$completionResult;
3616
3622
  $ongoingTemplateResult.$resultString =
3617
3623
  $ongoingTemplateResult.$completionResult.content;
3618
- return [3 /*break*/, 11];
3619
- case 8:
3620
- // TODO: [🧠] This is weird, embedding model can not be used such a way in the pipeline
3621
- _f = $ongoingTemplateResult;
3622
- return [4 /*yield*/, llmTools.callEmbeddingModel($deepFreeze($ongoingTemplateResult.$prompt))];
3623
- case 9:
3624
- // TODO: [🧠] This is weird, embedding model can not be used such a way in the pipeline
3625
- _f.$embeddingResult = _u.sent();
3626
- $ongoingTemplateResult.$result = $ongoingTemplateResult.$embeddingResult;
3627
- $ongoingTemplateResult.$resultString =
3628
- $ongoingTemplateResult.$embeddingResult.content.join(',');
3629
- return [3 /*break*/, 11];
3630
- case 10: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Unknown model variant \"".concat(template.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
3631
- case 11: return [3 /*break*/, 26];
3632
- case 12:
3624
+ return [3 /*break*/, 10];
3625
+ case 8: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Embedding model can not be used in pipeline\n\n This should be catched during parsing\n\n ".concat(block(pipelineIdentification), "\n\n "); }));
3626
+ case 9: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Unknown model variant \"".concat(template.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
3627
+ case 10: return [3 /*break*/, 25];
3628
+ case 11:
3633
3629
  if (arrayableToArray(tools.script).length === 0) {
3634
3630
  throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n No script execution tools are available\n\n ".concat(block(pipelineIdentification), "\n "); }));
3635
3631
  }
3636
3632
  if (!template.contentLanguage) {
3637
3633
  throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Script language is not defined for SCRIPT TEMPLATE \"".concat(template.name, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3638
3634
  }
3639
- _u.label = 13;
3635
+ _t.label = 12;
3636
+ case 12:
3637
+ _t.trys.push([12, 19, 20, 21]);
3638
+ _f = (e_1 = void 0, __values(arrayableToArray(tools.script))), _g = _f.next();
3639
+ _t.label = 13;
3640
3640
  case 13:
3641
- _u.trys.push([13, 20, 21, 22]);
3642
- _g = (e_1 = void 0, __values(arrayableToArray(tools.script))), _h = _g.next();
3643
- _u.label = 14;
3641
+ if (!!_g.done) return [3 /*break*/, 18];
3642
+ scriptTools = _g.value;
3643
+ _t.label = 14;
3644
3644
  case 14:
3645
- if (!!_h.done) return [3 /*break*/, 19];
3646
- scriptTools = _h.value;
3647
- _u.label = 15;
3648
- case 15:
3649
- _u.trys.push([15, 17, , 18]);
3650
- _j = $ongoingTemplateResult;
3645
+ _t.trys.push([14, 16, , 17]);
3646
+ _h = $ongoingTemplateResult;
3651
3647
  return [4 /*yield*/, scriptTools.execute($deepFreeze({
3652
3648
  scriptLanguage: template.contentLanguage,
3653
3649
  script: preparedContent,
3654
3650
  parameters: parameters,
3655
3651
  }))];
3652
+ case 15:
3653
+ _h.$resultString = _t.sent();
3654
+ return [3 /*break*/, 18];
3656
3655
  case 16:
3657
- _j.$resultString = _u.sent();
3658
- return [3 /*break*/, 19];
3659
- case 17:
3660
- error_1 = _u.sent();
3656
+ error_1 = _t.sent();
3661
3657
  if (!(error_1 instanceof Error)) {
3662
3658
  throw error_1;
3663
3659
  }
@@ -3665,24 +3661,24 @@
3665
3661
  throw error_1;
3666
3662
  }
3667
3663
  $ongoingTemplateResult.$scriptPipelineExecutionErrors.push(error_1);
3668
- return [3 /*break*/, 18];
3669
- case 18:
3670
- _h = _g.next();
3671
- return [3 /*break*/, 14];
3672
- case 19: return [3 /*break*/, 22];
3673
- case 20:
3674
- e_1_1 = _u.sent();
3664
+ return [3 /*break*/, 17];
3665
+ case 17:
3666
+ _g = _f.next();
3667
+ return [3 /*break*/, 13];
3668
+ case 18: return [3 /*break*/, 21];
3669
+ case 19:
3670
+ e_1_1 = _t.sent();
3675
3671
  e_1 = { error: e_1_1 };
3676
- return [3 /*break*/, 22];
3677
- case 21:
3672
+ return [3 /*break*/, 21];
3673
+ case 20:
3678
3674
  try {
3679
- if (_h && !_h.done && (_r = _g.return)) _r.call(_g);
3675
+ if (_g && !_g.done && (_q = _f.return)) _q.call(_f);
3680
3676
  }
3681
3677
  finally { if (e_1) throw e_1.error; }
3682
3678
  return [7 /*endfinally*/];
3683
- case 22:
3679
+ case 21:
3684
3680
  if ($ongoingTemplateResult.$resultString !== null) {
3685
- return [3 /*break*/, 26];
3681
+ return [3 /*break*/, 25];
3686
3682
  }
3687
3683
  if ($ongoingTemplateResult.$scriptPipelineExecutionErrors.length === 1) {
3688
3684
  throw $ongoingTemplateResult.$scriptPipelineExecutionErrors[0];
@@ -3692,12 +3688,12 @@
3692
3688
  .map(function (error) { return '- ' + error.message; })
3693
3689
  .join('\n\n')), "\n "); }));
3694
3690
  }
3695
- case 23:
3691
+ case 22:
3696
3692
  if (tools.userInterface === undefined) {
3697
3693
  throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n User interface tools are not available\n\n ".concat(block(pipelineIdentification), "\n "); }));
3698
3694
  }
3699
3695
  // TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
3700
- _k = $ongoingTemplateResult;
3696
+ _j = $ongoingTemplateResult;
3701
3697
  return [4 /*yield*/, tools.userInterface.promptDialog($deepFreeze({
3702
3698
  promptTitle: template.title,
3703
3699
  promptMessage: replaceParameters(template.description || '', parameters),
@@ -3706,34 +3702,34 @@
3706
3702
  placeholder: undefined,
3707
3703
  priority: priority,
3708
3704
  }))];
3709
- case 24:
3705
+ case 23:
3710
3706
  // TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
3711
- _k.$resultString = _u.sent();
3712
- return [3 /*break*/, 26];
3713
- case 25: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Unknown execution type \"".concat(template.templateType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3707
+ _j.$resultString = _t.sent();
3708
+ return [3 /*break*/, 25];
3709
+ case 24: throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Unknown execution type \"".concat(template.templateType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
3710
+ case 25:
3711
+ if (!(!isJokerAttempt && template.postprocessingFunctionNames)) return [3 /*break*/, 42];
3712
+ _t.label = 26;
3714
3713
  case 26:
3715
- if (!(!isJokerAttempt && template.postprocessingFunctionNames)) return [3 /*break*/, 43];
3716
- _u.label = 27;
3714
+ _t.trys.push([26, 40, 41, 42]);
3715
+ _k = (e_3 = void 0, __values(template.postprocessingFunctionNames)), _l = _k.next();
3716
+ _t.label = 27;
3717
3717
  case 27:
3718
- _u.trys.push([27, 41, 42, 43]);
3719
- _l = (e_3 = void 0, __values(template.postprocessingFunctionNames)), _m = _l.next();
3720
- _u.label = 28;
3721
- case 28:
3722
- if (!!_m.done) return [3 /*break*/, 40];
3723
- functionName = _m.value;
3718
+ if (!!_l.done) return [3 /*break*/, 39];
3719
+ functionName = _l.value;
3724
3720
  postprocessingError = null;
3725
- _u.label = 29;
3721
+ _t.label = 28;
3722
+ case 28:
3723
+ _t.trys.push([28, 35, 36, 37]);
3724
+ _m = (e_2 = void 0, __values(arrayableToArray(tools.script))), _o = _m.next();
3725
+ _t.label = 29;
3726
3726
  case 29:
3727
- _u.trys.push([29, 36, 37, 38]);
3728
- _o = (e_2 = void 0, __values(arrayableToArray(tools.script))), _p = _o.next();
3729
- _u.label = 30;
3727
+ if (!!_o.done) return [3 /*break*/, 34];
3728
+ scriptTools = _o.value;
3729
+ _t.label = 30;
3730
3730
  case 30:
3731
- if (!!_p.done) return [3 /*break*/, 35];
3732
- scriptTools = _p.value;
3733
- _u.label = 31;
3734
- case 31:
3735
- _u.trys.push([31, 33, , 34]);
3736
- _q = $ongoingTemplateResult;
3731
+ _t.trys.push([30, 32, , 33]);
3732
+ _p = $ongoingTemplateResult;
3737
3733
  return [4 /*yield*/, scriptTools.execute({
3738
3734
  scriptLanguage: "javascript" /* <- TODO: Try it in each languages; In future allow postprocessing with arbitrary combination of languages to combine */,
3739
3735
  script: "".concat(functionName, "(resultString)"),
@@ -3742,12 +3738,12 @@
3742
3738
  // Note: No ...parametersForTemplate, because working with result only
3743
3739
  },
3744
3740
  })];
3745
- case 32:
3746
- _q.$resultString = _u.sent();
3741
+ case 31:
3742
+ _p.$resultString = _t.sent();
3747
3743
  postprocessingError = null;
3748
- return [3 /*break*/, 35];
3749
- case 33:
3750
- error_2 = _u.sent();
3744
+ return [3 /*break*/, 34];
3745
+ case 32:
3746
+ error_2 = _t.sent();
3751
3747
  if (!(error_2 instanceof Error)) {
3752
3748
  throw error_2;
3753
3749
  }
@@ -3756,41 +3752,41 @@
3756
3752
  }
3757
3753
  postprocessingError = error_2;
3758
3754
  $ongoingTemplateResult.$scriptPipelineExecutionErrors.push(error_2);
3759
- return [3 /*break*/, 34];
3760
- case 34:
3761
- _p = _o.next();
3762
- return [3 /*break*/, 30];
3763
- case 35: return [3 /*break*/, 38];
3764
- case 36:
3765
- e_2_1 = _u.sent();
3755
+ return [3 /*break*/, 33];
3756
+ case 33:
3757
+ _o = _m.next();
3758
+ return [3 /*break*/, 29];
3759
+ case 34: return [3 /*break*/, 37];
3760
+ case 35:
3761
+ e_2_1 = _t.sent();
3766
3762
  e_2 = { error: e_2_1 };
3767
- return [3 /*break*/, 38];
3768
- case 37:
3763
+ return [3 /*break*/, 37];
3764
+ case 36:
3769
3765
  try {
3770
- if (_p && !_p.done && (_t = _o.return)) _t.call(_o);
3766
+ if (_o && !_o.done && (_s = _m.return)) _s.call(_m);
3771
3767
  }
3772
3768
  finally { if (e_2) throw e_2.error; }
3773
3769
  return [7 /*endfinally*/];
3774
- case 38:
3770
+ case 37:
3775
3771
  if (postprocessingError) {
3776
3772
  throw postprocessingError;
3777
3773
  }
3778
- _u.label = 39;
3779
- case 39:
3780
- _m = _l.next();
3781
- return [3 /*break*/, 28];
3782
- case 40: return [3 /*break*/, 43];
3783
- case 41:
3784
- e_3_1 = _u.sent();
3774
+ _t.label = 38;
3775
+ case 38:
3776
+ _l = _k.next();
3777
+ return [3 /*break*/, 27];
3778
+ case 39: return [3 /*break*/, 42];
3779
+ case 40:
3780
+ e_3_1 = _t.sent();
3785
3781
  e_3 = { error: e_3_1 };
3786
- return [3 /*break*/, 43];
3787
- case 42:
3782
+ return [3 /*break*/, 42];
3783
+ case 41:
3788
3784
  try {
3789
- if (_m && !_m.done && (_s = _l.return)) _s.call(_l);
3785
+ if (_l && !_l.done && (_r = _k.return)) _r.call(_k);
3790
3786
  }
3791
3787
  finally { if (e_3) throw e_3.error; }
3792
3788
  return [7 /*endfinally*/];
3793
- case 43:
3789
+ case 42:
3794
3790
  // TODO: [💝] Unite object for expecting amount and format
3795
3791
  if (template.format) {
3796
3792
  if (template.format === 'JSON') {
@@ -3815,14 +3811,14 @@
3815
3811
  checkExpectations(template.expectations, $ongoingTemplateResult.$resultString || '');
3816
3812
  }
3817
3813
  return [2 /*return*/, "break-attempts"];
3818
- case 44:
3819
- error_3 = _u.sent();
3814
+ case 43:
3815
+ error_3 = _t.sent();
3820
3816
  if (!(error_3 instanceof ExpectError)) {
3821
3817
  throw error_3;
3822
3818
  }
3823
3819
  $ongoingTemplateResult.$expectError = error_3;
3824
- return [3 /*break*/, 46];
3825
- case 45:
3820
+ return [3 /*break*/, 45];
3821
+ case 44:
3826
3822
  if (!isJokerAttempt &&
3827
3823
  template.templateType === 'PROMPT_TEMPLATE' &&
3828
3824
  $ongoingTemplateResult.$prompt
@@ -3839,7 +3835,7 @@
3839
3835
  });
3840
3836
  }
3841
3837
  return [7 /*endfinally*/];
3842
- case 46:
3838
+ case 45:
3843
3839
  if ($ongoingTemplateResult.$expectError !== null && attempt === maxAttempts - 1) {
3844
3840
  throw new PipelineExecutionError(spaceTrim.spaceTrim(function (block) {
3845
3841
  var _a, _b, _c;
@@ -3938,6 +3934,8 @@
3938
3934
  return __generator(this, function (_a) {
3939
3935
  switch (_a.label) {
3940
3936
  case 0:
3937
+ // TODO: !!!!!!! Limit to N concurrent executions
3938
+ // TODO: !!!!!!! Report progress
3941
3939
  try {
3942
3940
  mappedParameters = mapAvailableToExpectedParameters({
3943
3941
  expectedParameters: Object.fromEntries(template.foreach.subparameterNames.map(function (subparameterName) { return [subparameterName, null]; })),
@@ -4721,8 +4719,13 @@
4721
4719
  case 6: return [3 /*break*/, 8];
4722
4720
  case 7:
4723
4721
  error_1 = _c.sent();
4722
+ // Note: Here is expected error:
4723
+ // > PipelineExecutionError: You have not provided any `LlmExecutionTools` that support model variant "EMBEDDING
4724
+ if (!(error_1 instanceof PipelineExecutionError)) {
4725
+ throw error_1;
4726
+ }
4724
4727
  // TODO: [🟥] Detect browser / node and make it colorfull
4725
- console.error(error_1);
4728
+ console.error(error_1, "<- Note: This error is not critical to prepare the pipeline, just knowledge pieces won't have embeddings");
4726
4729
  return [3 /*break*/, 8];
4727
4730
  case 8: return [2 /*return*/, {
4728
4731
  name: name,
@@ -6225,6 +6228,9 @@
6225
6228
  */
6226
6229
  parse: function (input) {
6227
6230
  var args = input.args, normalized = input.normalized;
6231
+ var availableVariantsMessage = spaceTrim__default["default"](function (block) { return "\n Available variants are:\n ".concat(block(MODEL_VARIANTS.map(function (variantName) {
6232
+ return "- ".concat(variantName).concat(variantName !== 'EMBEDDING' ? '' : ' (Not available in pipeline)');
6233
+ }).join('\n')), "\n "); });
6228
6234
  // TODO: Make this more elegant and dynamically
6229
6235
  if (normalized.startsWith('MODEL_VARIANT')) {
6230
6236
  if (normalized === 'MODEL_VARIANT_CHAT') {
@@ -6240,17 +6246,13 @@
6240
6246
  key: 'modelVariant',
6241
6247
  value: 'COMPLETION',
6242
6248
  };
6249
+ // <- Note: [🤖]
6243
6250
  }
6244
6251
  else if (normalized.startsWith('MODEL_VARIANT_EMBED')) {
6245
- return {
6246
- type: 'MODEL',
6247
- key: 'modelVariant',
6248
- value: 'EMBEDDING',
6249
- };
6250
- // <- Note: [🤖]
6252
+ spaceTrim__default["default"](function (block) { return "\n Embedding model can not be used in pipeline\n\n ".concat(block(availableVariantsMessage), "\n "); });
6251
6253
  }
6252
6254
  else {
6253
- throw new ParseError(spaceTrim__default["default"](function (block) { return "\n Unknown model variant in command:\n\n Supported variants are:\n ".concat(block(MODEL_VARIANTS.map(function (variantName) { return "- ".concat(variantName); }).join('\n')), "\n "); }));
6255
+ throw new ParseError(spaceTrim__default["default"](function (block) { return "\n Unknown model variant in command:\n\n ".concat(block(availableVariantsMessage), "\n "); }));
6254
6256
  }
6255
6257
  }
6256
6258
  if (normalized.startsWith('MODEL_NAME')) {