@promptbook/node 0.69.0-11 → 0.69.0-13
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 +180 -183
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +4 -0
- package/esm/typings/src/_packages/types.index.d.ts +4 -0
- package/esm/typings/src/config.d.ts +7 -0
- package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorSettings.d.ts +7 -0
- package/esm/typings/src/formats/_common/FormatDefinition.d.ts +9 -6
- package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +4 -3
- package/esm/typings/src/formats/csv/CsvFormatDefinition.d.ts +3 -1
- package/esm/typings/src/formats/csv/CsvSettings.d.ts +13 -0
- package/esm/typings/src/formats/index.d.ts +1 -1
- package/esm/typings/src/formats/json/JsonFormatDefinition.d.ts +3 -2
- package/esm/typings/src/formats/text/TextFormatDefinition.d.ts +3 -1
- package/esm/typings/src/formats/xml/XmlFormatDefinition.d.ts +3 -2
- package/esm/typings/src/utils/organization/{f.d.ts → empty_object.d.ts} +5 -1
- package/esm/typings/src/utils/organization/just_empty_object.d.ts +12 -0
- package/package.json +2 -2
- package/umd/index.umd.js +180 -183
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -15,7 +15,7 @@ import * as dotenv from 'dotenv';
|
|
|
15
15
|
/**
|
|
16
16
|
* The version of the Promptbook library
|
|
17
17
|
*/
|
|
18
|
-
var PROMPTBOOK_VERSION = '0.69.0-
|
|
18
|
+
var PROMPTBOOK_VERSION = '0.69.0-12';
|
|
19
19
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
20
20
|
|
|
21
21
|
/*! *****************************************************************************
|
|
@@ -422,6 +422,17 @@ var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
|
|
|
422
422
|
*/
|
|
423
423
|
var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
|
|
424
424
|
// <- TODO: [🧜♂️]
|
|
425
|
+
/**
|
|
426
|
+
* @@@
|
|
427
|
+
*
|
|
428
|
+
* @public exported from `@promptbook/core`
|
|
429
|
+
*/
|
|
430
|
+
var DEFAULT_CSV_SETTINGS = Object.freeze({
|
|
431
|
+
delimiter: ',',
|
|
432
|
+
quoteChar: '"',
|
|
433
|
+
newline: '\n',
|
|
434
|
+
skipEmptyLines: true,
|
|
435
|
+
});
|
|
425
436
|
/**
|
|
426
437
|
* @@@
|
|
427
438
|
*
|
|
@@ -885,7 +896,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
885
896
|
});
|
|
886
897
|
}
|
|
887
898
|
|
|
888
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.69.0-
|
|
899
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.69.0-12",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-12",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-12",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-12",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"}];
|
|
889
900
|
|
|
890
901
|
/**
|
|
891
902
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -2324,9 +2335,7 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
|
|
|
2324
2335
|
throw new PipelineExecutionError("You have not provided any `LlmExecutionTools`");
|
|
2325
2336
|
}
|
|
2326
2337
|
else {
|
|
2327
|
-
throw new PipelineExecutionError(spaceTrim$1(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
|
|
2328
|
-
.map(function (tools) { return "- ".concat(tools.title, " ").concat(tools.description || ''); })
|
|
2329
|
-
.join('\n')), "\n\n "); }));
|
|
2338
|
+
throw new PipelineExecutionError(spaceTrim$1(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 "); }));
|
|
2330
2339
|
}
|
|
2331
2340
|
}
|
|
2332
2341
|
});
|
|
@@ -2632,6 +2641,16 @@ function TODO_USE() {
|
|
|
2632
2641
|
}
|
|
2633
2642
|
}
|
|
2634
2643
|
|
|
2644
|
+
/**
|
|
2645
|
+
* @@@
|
|
2646
|
+
*
|
|
2647
|
+
* @public exported from `@promptbook/core`
|
|
2648
|
+
*/
|
|
2649
|
+
var MANDATORY_CSV_SETTINGS = Object.freeze({
|
|
2650
|
+
header: true,
|
|
2651
|
+
// encoding: 'utf8',
|
|
2652
|
+
});
|
|
2653
|
+
|
|
2635
2654
|
/**
|
|
2636
2655
|
* Definition for CSV spreadsheet
|
|
2637
2656
|
*
|
|
@@ -2641,41 +2660,36 @@ function TODO_USE() {
|
|
|
2641
2660
|
var CsvFormatDefinition = {
|
|
2642
2661
|
formatName: 'CSV',
|
|
2643
2662
|
aliases: ['SPREADSHEET', 'TABLE'],
|
|
2644
|
-
isValid: function (value, schema) {
|
|
2663
|
+
isValid: function (value, settings, schema) {
|
|
2664
|
+
// TODO: !!!!!! Implement CSV validation
|
|
2645
2665
|
TODO_USE(value /* <- TODO: Use value here */);
|
|
2666
|
+
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2646
2667
|
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
2647
2668
|
return true;
|
|
2648
2669
|
},
|
|
2649
|
-
canBeValid: function (partialValue, schema) {
|
|
2670
|
+
canBeValid: function (partialValue, settings, schema) {
|
|
2650
2671
|
TODO_USE(partialValue /* <- TODO: Use partialValue here */);
|
|
2672
|
+
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2651
2673
|
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
2652
2674
|
return true;
|
|
2653
2675
|
},
|
|
2654
|
-
heal: function (value, schema) {
|
|
2676
|
+
heal: function (value, settings, schema) {
|
|
2655
2677
|
TODO_USE(value /* <- TODO: Use partialValue here */);
|
|
2678
|
+
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2656
2679
|
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
2657
2680
|
throw new Error('Not implemented');
|
|
2658
2681
|
},
|
|
2659
2682
|
subvalueDefinitions: [
|
|
2660
2683
|
{
|
|
2661
2684
|
subvalueName: 'ROW',
|
|
2662
|
-
mapValues: function (value, mapCallback) {
|
|
2685
|
+
mapValues: function (value, settings, mapCallback) {
|
|
2663
2686
|
return __awaiter(this, void 0, void 0, function () {
|
|
2664
2687
|
var csv, mappedData;
|
|
2665
2688
|
var _this = this;
|
|
2666
2689
|
return __generator(this, function (_a) {
|
|
2667
2690
|
switch (_a.label) {
|
|
2668
2691
|
case 0:
|
|
2669
|
-
csv = parse(value, {
|
|
2670
|
-
header: true,
|
|
2671
|
-
delimiter: ',',
|
|
2672
|
-
quoteChar: '"',
|
|
2673
|
-
newline: '\r\n',
|
|
2674
|
-
skipEmptyLines: true,
|
|
2675
|
-
// encoding: 'utf8',
|
|
2676
|
-
// <- TODO: !!!!!! DEFAULT_CSV_OPTIONS
|
|
2677
|
-
// <- TODO: [🧠] How to define parsing options for formats, its different concept than schema
|
|
2678
|
-
});
|
|
2692
|
+
csv = parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
|
|
2679
2693
|
if (csv.errors.length !== 0) {
|
|
2680
2694
|
throw new ParseError(// <- TODO: !!!!!! Split PipelineParseError and FormatParseError -> CsvParseError
|
|
2681
2695
|
spaceTrim$1(function (block) { return "\n CSV parsing error\n\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n "); }));
|
|
@@ -2689,25 +2703,18 @@ var CsvFormatDefinition = {
|
|
|
2689
2703
|
_a = [__assign({}, row)];
|
|
2690
2704
|
_b = {};
|
|
2691
2705
|
// <- TODO: !!!!!! Dynamic new column name and position
|
|
2706
|
+
// <- TODO: !!!!!! Check name collisions
|
|
2692
2707
|
return [4 /*yield*/, mapCallback(row, index)];
|
|
2693
2708
|
case 1: return [2 /*return*/, (__assign.apply(void 0, _a.concat([(_b.newColumn =
|
|
2694
2709
|
// <- TODO: !!!!!! Dynamic new column name and position
|
|
2710
|
+
// <- TODO: !!!!!! Check name collisions
|
|
2695
2711
|
_c.sent(), _b)])))];
|
|
2696
2712
|
}
|
|
2697
2713
|
});
|
|
2698
2714
|
}); }))];
|
|
2699
2715
|
case 1:
|
|
2700
2716
|
mappedData = _a.sent();
|
|
2701
|
-
return [2 /*return*/, unparse(mappedData, {
|
|
2702
|
-
header: true,
|
|
2703
|
-
delimiter: ',',
|
|
2704
|
-
quoteChar: '"',
|
|
2705
|
-
newline: '\r\n',
|
|
2706
|
-
skipEmptyLines: true,
|
|
2707
|
-
// encoding: 'utf8',
|
|
2708
|
-
// <- TODO: !!!!!! DEFAULT_CSV_OPTIONS
|
|
2709
|
-
// <- TODO: [🧠] How to define parsing options for formats, its different concept than schema
|
|
2710
|
-
})];
|
|
2717
|
+
return [2 /*return*/, unparse(mappedData, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS))];
|
|
2711
2718
|
}
|
|
2712
2719
|
});
|
|
2713
2720
|
});
|
|
@@ -2715,23 +2722,14 @@ var CsvFormatDefinition = {
|
|
|
2715
2722
|
},
|
|
2716
2723
|
{
|
|
2717
2724
|
subvalueName: 'CELL',
|
|
2718
|
-
mapValues: function (value, mapCallback) {
|
|
2725
|
+
mapValues: function (value, settings, mapCallback) {
|
|
2719
2726
|
return __awaiter(this, void 0, void 0, function () {
|
|
2720
2727
|
var csv, mappedData;
|
|
2721
2728
|
var _this = this;
|
|
2722
2729
|
return __generator(this, function (_a) {
|
|
2723
2730
|
switch (_a.label) {
|
|
2724
2731
|
case 0:
|
|
2725
|
-
csv = parse(value, {
|
|
2726
|
-
header: true,
|
|
2727
|
-
delimiter: ',',
|
|
2728
|
-
quoteChar: '"',
|
|
2729
|
-
newline: '\r\n',
|
|
2730
|
-
skipEmptyLines: true,
|
|
2731
|
-
// encoding: 'utf8',
|
|
2732
|
-
// <- TODO: !!!!!! DEFAULT_CSV_OPTIONS
|
|
2733
|
-
// <- TODO: [🧠] How to define parsing options for formats, its different concept than schema
|
|
2734
|
-
});
|
|
2732
|
+
csv = parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
|
|
2735
2733
|
if (csv.errors.length !== 0) {
|
|
2736
2734
|
throw new ParseError(// <- TODO: !!!!!! Split PipelineParseError and FormatParseError -> CsvParseError
|
|
2737
2735
|
spaceTrim$1(function (block) { return "\n CSV parsing error\n\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n "); }));
|
|
@@ -2754,16 +2752,7 @@ var CsvFormatDefinition = {
|
|
|
2754
2752
|
}); }))];
|
|
2755
2753
|
case 1:
|
|
2756
2754
|
mappedData = _a.sent();
|
|
2757
|
-
return [2 /*return*/, unparse(mappedData, {
|
|
2758
|
-
header: true,
|
|
2759
|
-
delimiter: ',',
|
|
2760
|
-
quoteChar: '"',
|
|
2761
|
-
newline: '\r\n',
|
|
2762
|
-
skipEmptyLines: true,
|
|
2763
|
-
// encoding: 'utf8',
|
|
2764
|
-
// <- TODO: !!!!!! DEFAULT_CSV_OPTIONS
|
|
2765
|
-
// <- TODO: [🧠] How to define parsing options for formats, its different concept than schema
|
|
2766
|
-
})];
|
|
2755
|
+
return [2 /*return*/, unparse(mappedData, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS))];
|
|
2767
2756
|
}
|
|
2768
2757
|
});
|
|
2769
2758
|
});
|
|
@@ -2808,17 +2797,20 @@ function isValidJsonString(value /* <- [👨⚖️] */) {
|
|
|
2808
2797
|
var JsonFormatDefinition = {
|
|
2809
2798
|
formatName: 'JSON',
|
|
2810
2799
|
mimeType: 'application/json',
|
|
2811
|
-
isValid: function (value, schema) {
|
|
2800
|
+
isValid: function (value, settings, schema) {
|
|
2812
2801
|
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
2802
|
+
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2813
2803
|
return isValidJsonString(value);
|
|
2814
2804
|
},
|
|
2815
|
-
canBeValid: function (partialValue, schema) {
|
|
2805
|
+
canBeValid: function (partialValue, settings, schema) {
|
|
2816
2806
|
TODO_USE(partialValue /* <- TODO: Use partialValue here */);
|
|
2807
|
+
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2817
2808
|
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
2818
2809
|
return true;
|
|
2819
2810
|
},
|
|
2820
|
-
heal: function (value, schema) {
|
|
2811
|
+
heal: function (value, settings, schema) {
|
|
2821
2812
|
TODO_USE(value /* <- TODO: Use partialValue here */);
|
|
2813
|
+
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2822
2814
|
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
2823
2815
|
throw new Error('Not implemented');
|
|
2824
2816
|
},
|
|
@@ -2827,7 +2819,7 @@ var JsonFormatDefinition = {
|
|
|
2827
2819
|
/**
|
|
2828
2820
|
* TODO: [🧠] Maybe propper instance of object
|
|
2829
2821
|
* TODO: [0] Make string_serialized_json
|
|
2830
|
-
* TODO: [1] Make type for JSON Schema
|
|
2822
|
+
* TODO: [1] Make type for JSON Settings and Schema
|
|
2831
2823
|
* TODO: [🧠] What to use for validating JSONs - JSON Schema, ZoD, typescript types/interfaces,...?
|
|
2832
2824
|
* TODO: [🍓] In `JsonFormatDefinition` implement simple `isValid`
|
|
2833
2825
|
* TODO: [🍓] In `JsonFormatDefinition` implement partial `canBeValid`
|
|
@@ -2857,7 +2849,7 @@ var TextFormatDefinition = {
|
|
|
2857
2849
|
subvalueDefinitions: [
|
|
2858
2850
|
{
|
|
2859
2851
|
subvalueName: 'LINE',
|
|
2860
|
-
mapValues: function (value, mapCallback) {
|
|
2852
|
+
mapValues: function (value, settings, mapCallback) {
|
|
2861
2853
|
return __awaiter(this, void 0, void 0, function () {
|
|
2862
2854
|
var lines, mappedLines;
|
|
2863
2855
|
return __generator(this, function (_a) {
|
|
@@ -2883,6 +2875,7 @@ var TextFormatDefinition = {
|
|
|
2883
2875
|
],
|
|
2884
2876
|
};
|
|
2885
2877
|
/**
|
|
2878
|
+
* TODO: [1] Make type for XML Text and Schema
|
|
2886
2879
|
* TODO: [🧠][🤠] Here should be all words, characters, lines, paragraphs, pages aviable as subvalues
|
|
2887
2880
|
* TODO: [🍓] In `TextFormatDefinition` implement simple `isValid`
|
|
2888
2881
|
* TODO: [🍓] In `TextFormatDefinition` implement partial `canBeValid`
|
|
@@ -2899,18 +2892,21 @@ var TextFormatDefinition = {
|
|
|
2899
2892
|
var XmlFormatDefinition = {
|
|
2900
2893
|
formatName: 'XML',
|
|
2901
2894
|
mimeType: 'application/xml',
|
|
2902
|
-
isValid: function (value, schema) {
|
|
2895
|
+
isValid: function (value, settings, schema) {
|
|
2903
2896
|
TODO_USE(value /* <- TODO: Use value here */);
|
|
2897
|
+
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2904
2898
|
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
2905
2899
|
return true;
|
|
2906
2900
|
},
|
|
2907
|
-
canBeValid: function (partialValue, schema) {
|
|
2901
|
+
canBeValid: function (partialValue, settings, schema) {
|
|
2908
2902
|
TODO_USE(partialValue /* <- TODO: Use partialValue here */);
|
|
2903
|
+
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2909
2904
|
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
2910
2905
|
return true;
|
|
2911
2906
|
},
|
|
2912
|
-
heal: function (value, schema) {
|
|
2907
|
+
heal: function (value, settings, schema) {
|
|
2913
2908
|
TODO_USE(value /* <- TODO: Use partialValue here */);
|
|
2909
|
+
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2914
2910
|
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
2915
2911
|
throw new Error('Not implemented');
|
|
2916
2912
|
},
|
|
@@ -2919,7 +2915,7 @@ var XmlFormatDefinition = {
|
|
|
2919
2915
|
/**
|
|
2920
2916
|
* TODO: [🧠] Maybe propper instance of object
|
|
2921
2917
|
* TODO: [0] Make string_serialized_xml
|
|
2922
|
-
* TODO: [1] Make type for XML Schema
|
|
2918
|
+
* TODO: [1] Make type for XML Settings and Schema
|
|
2923
2919
|
* TODO: [🧠] What to use for validating XMLs - XSD,...
|
|
2924
2920
|
* TODO: [🍓] In `XmlFormatDefinition` implement simple `isValid`
|
|
2925
2921
|
* TODO: [🍓] In `XmlFormatDefinition` implement partial `canBeValid`
|
|
@@ -3377,10 +3373,10 @@ function executeAttempts(options) {
|
|
|
3377
3373
|
$scriptPipelineExecutionErrors: [],
|
|
3378
3374
|
};
|
|
3379
3375
|
_loop_1 = function (attempt) {
|
|
3380
|
-
var isJokerAttempt, jokerParameterName, _b, modelRequirements, _c, _d, _e, _f, _g,
|
|
3381
|
-
var e_1,
|
|
3382
|
-
return __generator(this, function (
|
|
3383
|
-
switch (
|
|
3376
|
+
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;
|
|
3377
|
+
var e_1, _q, e_3, _r, e_2, _s;
|
|
3378
|
+
return __generator(this, function (_t) {
|
|
3379
|
+
switch (_t.label) {
|
|
3384
3380
|
case 0:
|
|
3385
3381
|
isJokerAttempt = attempt < 0;
|
|
3386
3382
|
jokerParameterName = jokerParameterNames[jokerParameterNames.length + attempt];
|
|
@@ -3400,21 +3396,21 @@ function executeAttempts(options) {
|
|
|
3400
3396
|
$ongoingTemplateResult.$resultString = parameters[jokerParameterName];
|
|
3401
3397
|
}
|
|
3402
3398
|
}
|
|
3403
|
-
|
|
3399
|
+
_t.label = 1;
|
|
3404
3400
|
case 1:
|
|
3405
|
-
|
|
3406
|
-
if (!!isJokerAttempt) return [3 /*break*/,
|
|
3401
|
+
_t.trys.push([1, 43, 44, 45]);
|
|
3402
|
+
if (!!isJokerAttempt) return [3 /*break*/, 25];
|
|
3407
3403
|
_b = template.templateType;
|
|
3408
3404
|
switch (_b) {
|
|
3409
3405
|
case 'SIMPLE_TEMPLATE': return [3 /*break*/, 2];
|
|
3410
3406
|
case 'PROMPT_TEMPLATE': return [3 /*break*/, 3];
|
|
3411
|
-
case 'SCRIPT_TEMPLATE': return [3 /*break*/,
|
|
3412
|
-
case 'DIALOG_TEMPLATE': return [3 /*break*/,
|
|
3407
|
+
case 'SCRIPT_TEMPLATE': return [3 /*break*/, 11];
|
|
3408
|
+
case 'DIALOG_TEMPLATE': return [3 /*break*/, 22];
|
|
3413
3409
|
}
|
|
3414
|
-
return [3 /*break*/,
|
|
3410
|
+
return [3 /*break*/, 24];
|
|
3415
3411
|
case 2:
|
|
3416
3412
|
$ongoingTemplateResult.$resultString = replaceParameters(preparedContent, parameters);
|
|
3417
|
-
return [3 /*break*/,
|
|
3413
|
+
return [3 /*break*/, 25];
|
|
3418
3414
|
case 3:
|
|
3419
3415
|
modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (template.modelRequirements || {}));
|
|
3420
3416
|
$ongoingTemplateResult.$prompt = {
|
|
@@ -3439,67 +3435,57 @@ function executeAttempts(options) {
|
|
|
3439
3435
|
case 'COMPLETION': return [3 /*break*/, 6];
|
|
3440
3436
|
case 'EMBEDDING': return [3 /*break*/, 8];
|
|
3441
3437
|
}
|
|
3442
|
-
return [3 /*break*/,
|
|
3438
|
+
return [3 /*break*/, 9];
|
|
3443
3439
|
case 4:
|
|
3444
3440
|
_d = $ongoingTemplateResult;
|
|
3445
3441
|
return [4 /*yield*/, llmTools.callChatModel($deepFreeze($ongoingTemplateResult.$prompt))];
|
|
3446
3442
|
case 5:
|
|
3447
|
-
_d.$chatResult =
|
|
3443
|
+
_d.$chatResult = _t.sent();
|
|
3448
3444
|
// TODO: [🍬] Destroy chatThread
|
|
3449
3445
|
$ongoingTemplateResult.$result = $ongoingTemplateResult.$chatResult;
|
|
3450
3446
|
$ongoingTemplateResult.$resultString = $ongoingTemplateResult.$chatResult.content;
|
|
3451
|
-
return [3 /*break*/,
|
|
3447
|
+
return [3 /*break*/, 10];
|
|
3452
3448
|
case 6:
|
|
3453
3449
|
_e = $ongoingTemplateResult;
|
|
3454
3450
|
return [4 /*yield*/, llmTools.callCompletionModel($deepFreeze($ongoingTemplateResult.$prompt))];
|
|
3455
3451
|
case 7:
|
|
3456
|
-
_e.$completionResult =
|
|
3452
|
+
_e.$completionResult = _t.sent();
|
|
3457
3453
|
$ongoingTemplateResult.$result = $ongoingTemplateResult.$completionResult;
|
|
3458
3454
|
$ongoingTemplateResult.$resultString =
|
|
3459
3455
|
$ongoingTemplateResult.$completionResult.content;
|
|
3460
|
-
return [3 /*break*/,
|
|
3461
|
-
case 8:
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
case 9:
|
|
3466
|
-
// TODO: [🧠] This is weird, embedding model can not be used such a way in the pipeline
|
|
3467
|
-
_f.$embeddingResult = _u.sent();
|
|
3468
|
-
$ongoingTemplateResult.$result = $ongoingTemplateResult.$embeddingResult;
|
|
3469
|
-
$ongoingTemplateResult.$resultString =
|
|
3470
|
-
$ongoingTemplateResult.$embeddingResult.content.join(',');
|
|
3471
|
-
return [3 /*break*/, 11];
|
|
3472
|
-
case 10: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown model variant \"".concat(template.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
|
|
3473
|
-
case 11: return [3 /*break*/, 26];
|
|
3474
|
-
case 12:
|
|
3456
|
+
return [3 /*break*/, 10];
|
|
3457
|
+
case 8: throw new PipelineExecutionError(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 "); }));
|
|
3458
|
+
case 9: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown model variant \"".concat(template.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
|
|
3459
|
+
case 10: return [3 /*break*/, 25];
|
|
3460
|
+
case 11:
|
|
3475
3461
|
if (arrayableToArray(tools.script).length === 0) {
|
|
3476
3462
|
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n No script execution tools are available\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
3477
3463
|
}
|
|
3478
3464
|
if (!template.contentLanguage) {
|
|
3479
3465
|
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Script language is not defined for SCRIPT TEMPLATE \"".concat(template.name, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3480
3466
|
}
|
|
3481
|
-
|
|
3467
|
+
_t.label = 12;
|
|
3468
|
+
case 12:
|
|
3469
|
+
_t.trys.push([12, 19, 20, 21]);
|
|
3470
|
+
_f = (e_1 = void 0, __values(arrayableToArray(tools.script))), _g = _f.next();
|
|
3471
|
+
_t.label = 13;
|
|
3482
3472
|
case 13:
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3473
|
+
if (!!_g.done) return [3 /*break*/, 18];
|
|
3474
|
+
scriptTools = _g.value;
|
|
3475
|
+
_t.label = 14;
|
|
3486
3476
|
case 14:
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
_u.label = 15;
|
|
3490
|
-
case 15:
|
|
3491
|
-
_u.trys.push([15, 17, , 18]);
|
|
3492
|
-
_j = $ongoingTemplateResult;
|
|
3477
|
+
_t.trys.push([14, 16, , 17]);
|
|
3478
|
+
_h = $ongoingTemplateResult;
|
|
3493
3479
|
return [4 /*yield*/, scriptTools.execute($deepFreeze({
|
|
3494
3480
|
scriptLanguage: template.contentLanguage,
|
|
3495
3481
|
script: preparedContent,
|
|
3496
3482
|
parameters: parameters,
|
|
3497
3483
|
}))];
|
|
3484
|
+
case 15:
|
|
3485
|
+
_h.$resultString = _t.sent();
|
|
3486
|
+
return [3 /*break*/, 18];
|
|
3498
3487
|
case 16:
|
|
3499
|
-
|
|
3500
|
-
return [3 /*break*/, 19];
|
|
3501
|
-
case 17:
|
|
3502
|
-
error_1 = _u.sent();
|
|
3488
|
+
error_1 = _t.sent();
|
|
3503
3489
|
if (!(error_1 instanceof Error)) {
|
|
3504
3490
|
throw error_1;
|
|
3505
3491
|
}
|
|
@@ -3507,24 +3493,24 @@ function executeAttempts(options) {
|
|
|
3507
3493
|
throw error_1;
|
|
3508
3494
|
}
|
|
3509
3495
|
$ongoingTemplateResult.$scriptPipelineExecutionErrors.push(error_1);
|
|
3510
|
-
return [3 /*break*/,
|
|
3511
|
-
case
|
|
3512
|
-
|
|
3513
|
-
return [3 /*break*/,
|
|
3514
|
-
case
|
|
3515
|
-
case
|
|
3516
|
-
e_1_1 =
|
|
3496
|
+
return [3 /*break*/, 17];
|
|
3497
|
+
case 17:
|
|
3498
|
+
_g = _f.next();
|
|
3499
|
+
return [3 /*break*/, 13];
|
|
3500
|
+
case 18: return [3 /*break*/, 21];
|
|
3501
|
+
case 19:
|
|
3502
|
+
e_1_1 = _t.sent();
|
|
3517
3503
|
e_1 = { error: e_1_1 };
|
|
3518
|
-
return [3 /*break*/,
|
|
3519
|
-
case
|
|
3504
|
+
return [3 /*break*/, 21];
|
|
3505
|
+
case 20:
|
|
3520
3506
|
try {
|
|
3521
|
-
if (
|
|
3507
|
+
if (_g && !_g.done && (_q = _f.return)) _q.call(_f);
|
|
3522
3508
|
}
|
|
3523
3509
|
finally { if (e_1) throw e_1.error; }
|
|
3524
3510
|
return [7 /*endfinally*/];
|
|
3525
|
-
case
|
|
3511
|
+
case 21:
|
|
3526
3512
|
if ($ongoingTemplateResult.$resultString !== null) {
|
|
3527
|
-
return [3 /*break*/,
|
|
3513
|
+
return [3 /*break*/, 25];
|
|
3528
3514
|
}
|
|
3529
3515
|
if ($ongoingTemplateResult.$scriptPipelineExecutionErrors.length === 1) {
|
|
3530
3516
|
throw $ongoingTemplateResult.$scriptPipelineExecutionErrors[0];
|
|
@@ -3534,12 +3520,12 @@ function executeAttempts(options) {
|
|
|
3534
3520
|
.map(function (error) { return '- ' + error.message; })
|
|
3535
3521
|
.join('\n\n')), "\n "); }));
|
|
3536
3522
|
}
|
|
3537
|
-
case
|
|
3523
|
+
case 22:
|
|
3538
3524
|
if (tools.userInterface === undefined) {
|
|
3539
3525
|
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n User interface tools are not available\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
3540
3526
|
}
|
|
3541
3527
|
// TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
|
|
3542
|
-
|
|
3528
|
+
_j = $ongoingTemplateResult;
|
|
3543
3529
|
return [4 /*yield*/, tools.userInterface.promptDialog($deepFreeze({
|
|
3544
3530
|
promptTitle: template.title,
|
|
3545
3531
|
promptMessage: replaceParameters(template.description || '', parameters),
|
|
@@ -3548,34 +3534,34 @@ function executeAttempts(options) {
|
|
|
3548
3534
|
placeholder: undefined,
|
|
3549
3535
|
priority: priority,
|
|
3550
3536
|
}))];
|
|
3551
|
-
case
|
|
3537
|
+
case 23:
|
|
3552
3538
|
// TODO: [🌹] When making next attempt for `DIALOG TEMPLATE`, preserve the previous user input
|
|
3553
|
-
|
|
3554
|
-
return [3 /*break*/,
|
|
3555
|
-
case
|
|
3539
|
+
_j.$resultString = _t.sent();
|
|
3540
|
+
return [3 /*break*/, 25];
|
|
3541
|
+
case 24: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown execution type \"".concat(template.templateType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3542
|
+
case 25:
|
|
3543
|
+
if (!(!isJokerAttempt && template.postprocessingFunctionNames)) return [3 /*break*/, 42];
|
|
3544
|
+
_t.label = 26;
|
|
3556
3545
|
case 26:
|
|
3557
|
-
|
|
3558
|
-
|
|
3546
|
+
_t.trys.push([26, 40, 41, 42]);
|
|
3547
|
+
_k = (e_3 = void 0, __values(template.postprocessingFunctionNames)), _l = _k.next();
|
|
3548
|
+
_t.label = 27;
|
|
3559
3549
|
case 27:
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
_u.label = 28;
|
|
3563
|
-
case 28:
|
|
3564
|
-
if (!!_m.done) return [3 /*break*/, 40];
|
|
3565
|
-
functionName = _m.value;
|
|
3550
|
+
if (!!_l.done) return [3 /*break*/, 39];
|
|
3551
|
+
functionName = _l.value;
|
|
3566
3552
|
postprocessingError = null;
|
|
3567
|
-
|
|
3553
|
+
_t.label = 28;
|
|
3554
|
+
case 28:
|
|
3555
|
+
_t.trys.push([28, 35, 36, 37]);
|
|
3556
|
+
_m = (e_2 = void 0, __values(arrayableToArray(tools.script))), _o = _m.next();
|
|
3557
|
+
_t.label = 29;
|
|
3568
3558
|
case 29:
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3559
|
+
if (!!_o.done) return [3 /*break*/, 34];
|
|
3560
|
+
scriptTools = _o.value;
|
|
3561
|
+
_t.label = 30;
|
|
3572
3562
|
case 30:
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
_u.label = 31;
|
|
3576
|
-
case 31:
|
|
3577
|
-
_u.trys.push([31, 33, , 34]);
|
|
3578
|
-
_q = $ongoingTemplateResult;
|
|
3563
|
+
_t.trys.push([30, 32, , 33]);
|
|
3564
|
+
_p = $ongoingTemplateResult;
|
|
3579
3565
|
return [4 /*yield*/, scriptTools.execute({
|
|
3580
3566
|
scriptLanguage: "javascript" /* <- TODO: Try it in each languages; In future allow postprocessing with arbitrary combination of languages to combine */,
|
|
3581
3567
|
script: "".concat(functionName, "(resultString)"),
|
|
@@ -3584,12 +3570,12 @@ function executeAttempts(options) {
|
|
|
3584
3570
|
// Note: No ...parametersForTemplate, because working with result only
|
|
3585
3571
|
},
|
|
3586
3572
|
})];
|
|
3587
|
-
case
|
|
3588
|
-
|
|
3573
|
+
case 31:
|
|
3574
|
+
_p.$resultString = _t.sent();
|
|
3589
3575
|
postprocessingError = null;
|
|
3590
|
-
return [3 /*break*/,
|
|
3591
|
-
case
|
|
3592
|
-
error_2 =
|
|
3576
|
+
return [3 /*break*/, 34];
|
|
3577
|
+
case 32:
|
|
3578
|
+
error_2 = _t.sent();
|
|
3593
3579
|
if (!(error_2 instanceof Error)) {
|
|
3594
3580
|
throw error_2;
|
|
3595
3581
|
}
|
|
@@ -3598,41 +3584,41 @@ function executeAttempts(options) {
|
|
|
3598
3584
|
}
|
|
3599
3585
|
postprocessingError = error_2;
|
|
3600
3586
|
$ongoingTemplateResult.$scriptPipelineExecutionErrors.push(error_2);
|
|
3601
|
-
return [3 /*break*/,
|
|
3602
|
-
case
|
|
3603
|
-
|
|
3604
|
-
return [3 /*break*/,
|
|
3605
|
-
case
|
|
3606
|
-
case
|
|
3607
|
-
e_2_1 =
|
|
3587
|
+
return [3 /*break*/, 33];
|
|
3588
|
+
case 33:
|
|
3589
|
+
_o = _m.next();
|
|
3590
|
+
return [3 /*break*/, 29];
|
|
3591
|
+
case 34: return [3 /*break*/, 37];
|
|
3592
|
+
case 35:
|
|
3593
|
+
e_2_1 = _t.sent();
|
|
3608
3594
|
e_2 = { error: e_2_1 };
|
|
3609
|
-
return [3 /*break*/,
|
|
3610
|
-
case
|
|
3595
|
+
return [3 /*break*/, 37];
|
|
3596
|
+
case 36:
|
|
3611
3597
|
try {
|
|
3612
|
-
if (
|
|
3598
|
+
if (_o && !_o.done && (_s = _m.return)) _s.call(_m);
|
|
3613
3599
|
}
|
|
3614
3600
|
finally { if (e_2) throw e_2.error; }
|
|
3615
3601
|
return [7 /*endfinally*/];
|
|
3616
|
-
case
|
|
3602
|
+
case 37:
|
|
3617
3603
|
if (postprocessingError) {
|
|
3618
3604
|
throw postprocessingError;
|
|
3619
3605
|
}
|
|
3620
|
-
|
|
3621
|
-
case
|
|
3622
|
-
|
|
3623
|
-
return [3 /*break*/,
|
|
3624
|
-
case
|
|
3625
|
-
case
|
|
3626
|
-
e_3_1 =
|
|
3606
|
+
_t.label = 38;
|
|
3607
|
+
case 38:
|
|
3608
|
+
_l = _k.next();
|
|
3609
|
+
return [3 /*break*/, 27];
|
|
3610
|
+
case 39: return [3 /*break*/, 42];
|
|
3611
|
+
case 40:
|
|
3612
|
+
e_3_1 = _t.sent();
|
|
3627
3613
|
e_3 = { error: e_3_1 };
|
|
3628
|
-
return [3 /*break*/,
|
|
3629
|
-
case
|
|
3614
|
+
return [3 /*break*/, 42];
|
|
3615
|
+
case 41:
|
|
3630
3616
|
try {
|
|
3631
|
-
if (
|
|
3617
|
+
if (_l && !_l.done && (_r = _k.return)) _r.call(_k);
|
|
3632
3618
|
}
|
|
3633
3619
|
finally { if (e_3) throw e_3.error; }
|
|
3634
3620
|
return [7 /*endfinally*/];
|
|
3635
|
-
case
|
|
3621
|
+
case 42:
|
|
3636
3622
|
// TODO: [💝] Unite object for expecting amount and format
|
|
3637
3623
|
if (template.format) {
|
|
3638
3624
|
if (template.format === 'JSON') {
|
|
@@ -3657,14 +3643,14 @@ function executeAttempts(options) {
|
|
|
3657
3643
|
checkExpectations(template.expectations, $ongoingTemplateResult.$resultString || '');
|
|
3658
3644
|
}
|
|
3659
3645
|
return [2 /*return*/, "break-attempts"];
|
|
3660
|
-
case
|
|
3661
|
-
error_3 =
|
|
3646
|
+
case 43:
|
|
3647
|
+
error_3 = _t.sent();
|
|
3662
3648
|
if (!(error_3 instanceof ExpectError)) {
|
|
3663
3649
|
throw error_3;
|
|
3664
3650
|
}
|
|
3665
3651
|
$ongoingTemplateResult.$expectError = error_3;
|
|
3666
|
-
return [3 /*break*/,
|
|
3667
|
-
case
|
|
3652
|
+
return [3 /*break*/, 45];
|
|
3653
|
+
case 44:
|
|
3668
3654
|
if (!isJokerAttempt &&
|
|
3669
3655
|
template.templateType === 'PROMPT_TEMPLATE' &&
|
|
3670
3656
|
$ongoingTemplateResult.$prompt
|
|
@@ -3681,7 +3667,7 @@ function executeAttempts(options) {
|
|
|
3681
3667
|
});
|
|
3682
3668
|
}
|
|
3683
3669
|
return [7 /*endfinally*/];
|
|
3684
|
-
case
|
|
3670
|
+
case 45:
|
|
3685
3671
|
if ($ongoingTemplateResult.$expectError !== null && attempt === maxAttempts - 1) {
|
|
3686
3672
|
throw new PipelineExecutionError(spaceTrim(function (block) {
|
|
3687
3673
|
var _a, _b, _c;
|
|
@@ -3737,12 +3723,12 @@ function executeAttempts(options) {
|
|
|
3737
3723
|
*/
|
|
3738
3724
|
function executeFormatCells(options) {
|
|
3739
3725
|
return __awaiter(this, void 0, void 0, function () {
|
|
3740
|
-
var template, jokerParameterNames, parameters, priority, pipelineIdentification, parameterValue, formatDefinition, subvalueDefinition, resultString;
|
|
3726
|
+
var template, jokerParameterNames, parameters, priority, pipelineIdentification, settings, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
|
|
3741
3727
|
var _this = this;
|
|
3742
3728
|
return __generator(this, function (_a) {
|
|
3743
3729
|
switch (_a.label) {
|
|
3744
3730
|
case 0:
|
|
3745
|
-
template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, pipelineIdentification = options.pipelineIdentification;
|
|
3731
|
+
template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, pipelineIdentification = options.pipelineIdentification, settings = options.settings;
|
|
3746
3732
|
if (template.foreach === undefined) {
|
|
3747
3733
|
return [2 /*return*/, /* not await */ executeAttempts(options)];
|
|
3748
3734
|
}
|
|
@@ -3771,11 +3757,17 @@ function executeFormatCells(options) {
|
|
|
3771
3757
|
.map(function (subvalueName) { return "- ".concat(subvalueName); })
|
|
3772
3758
|
.join('\n')), "\n\n [\u26F7] This should never happen because cell name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
3773
3759
|
}
|
|
3774
|
-
|
|
3760
|
+
if (formatDefinition.formatName === 'CSV') {
|
|
3761
|
+
formatSettings = settings.csvSettings;
|
|
3762
|
+
// <- TODO: !!!!!! More universal, make simmilar pattern for other formats for example \n vs \r\n in text
|
|
3763
|
+
}
|
|
3764
|
+
return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
3775
3765
|
var mappedParameters, allSubparameters, subresultString;
|
|
3776
3766
|
return __generator(this, function (_a) {
|
|
3777
3767
|
switch (_a.label) {
|
|
3778
3768
|
case 0:
|
|
3769
|
+
// TODO: !!!!!!! Limit to N concurrent executions
|
|
3770
|
+
// TODO: !!!!!!! Report progress
|
|
3779
3771
|
try {
|
|
3780
3772
|
mappedParameters = mapAvailableToExpectedParameters({
|
|
3781
3773
|
expectedParameters: Object.fromEntries(template.foreach.subparameterNames.map(function (subparameterName) { return [subparameterName, null]; })),
|
|
@@ -4406,7 +4398,7 @@ function executePipeline(options) {
|
|
|
4406
4398
|
function createPipelineExecutor(options) {
|
|
4407
4399
|
var _this = this;
|
|
4408
4400
|
var pipeline = options.pipeline, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
|
|
4409
|
-
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.
|
|
4401
|
+
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.csvSettings, csvSettings = _d === void 0 ? DEFAULT_CSV_SETTINGS : _d, _e = settings.isVerbose, isVerbose = _e === void 0 ? IS_VERBOSE : _e, _f = settings.isNotPreparedWarningSupressed, isNotPreparedWarningSupressed = _f === void 0 ? false : _f;
|
|
4410
4402
|
validatePipeline(pipeline);
|
|
4411
4403
|
var pipelineIdentification = (function () {
|
|
4412
4404
|
// Note: This is a 😐 implementation of [🚞]
|
|
@@ -4441,6 +4433,7 @@ function createPipelineExecutor(options) {
|
|
|
4441
4433
|
settings: {
|
|
4442
4434
|
maxExecutionAttempts: maxExecutionAttempts,
|
|
4443
4435
|
maxParallelCount: maxParallelCount,
|
|
4436
|
+
csvSettings: csvSettings,
|
|
4444
4437
|
isVerbose: isVerbose,
|
|
4445
4438
|
isNotPreparedWarningSupressed: isNotPreparedWarningSupressed,
|
|
4446
4439
|
},
|
|
@@ -4558,8 +4551,13 @@ function prepareKnowledgeFromMarkdown(knowledgeContent /* <- TODO: [🖖] (?mayb
|
|
|
4558
4551
|
case 6: return [3 /*break*/, 8];
|
|
4559
4552
|
case 7:
|
|
4560
4553
|
error_1 = _c.sent();
|
|
4554
|
+
// Note: Here is expected error:
|
|
4555
|
+
// > PipelineExecutionError: You have not provided any `LlmExecutionTools` that support model variant "EMBEDDING
|
|
4556
|
+
if (!(error_1 instanceof PipelineExecutionError)) {
|
|
4557
|
+
throw error_1;
|
|
4558
|
+
}
|
|
4561
4559
|
// TODO: [🟥] Detect browser / node and make it colorfull
|
|
4562
|
-
console.error(error_1);
|
|
4560
|
+
console.error(error_1, "<- Note: This error is not critical to prepare the pipeline, just knowledge pieces won't have embeddings");
|
|
4563
4561
|
return [3 /*break*/, 8];
|
|
4564
4562
|
case 8: return [2 /*return*/, {
|
|
4565
4563
|
name: name,
|
|
@@ -6062,6 +6060,9 @@ var modelCommandParser = {
|
|
|
6062
6060
|
*/
|
|
6063
6061
|
parse: function (input) {
|
|
6064
6062
|
var args = input.args, normalized = input.normalized;
|
|
6063
|
+
var availableVariantsMessage = spaceTrim$1(function (block) { return "\n Available variants are:\n ".concat(block(MODEL_VARIANTS.map(function (variantName) {
|
|
6064
|
+
return "- ".concat(variantName).concat(variantName !== 'EMBEDDING' ? '' : ' (Not available in pipeline)');
|
|
6065
|
+
}).join('\n')), "\n "); });
|
|
6065
6066
|
// TODO: Make this more elegant and dynamically
|
|
6066
6067
|
if (normalized.startsWith('MODEL_VARIANT')) {
|
|
6067
6068
|
if (normalized === 'MODEL_VARIANT_CHAT') {
|
|
@@ -6077,17 +6078,13 @@ var modelCommandParser = {
|
|
|
6077
6078
|
key: 'modelVariant',
|
|
6078
6079
|
value: 'COMPLETION',
|
|
6079
6080
|
};
|
|
6081
|
+
// <- Note: [🤖]
|
|
6080
6082
|
}
|
|
6081
6083
|
else if (normalized.startsWith('MODEL_VARIANT_EMBED')) {
|
|
6082
|
-
return
|
|
6083
|
-
type: 'MODEL',
|
|
6084
|
-
key: 'modelVariant',
|
|
6085
|
-
value: 'EMBEDDING',
|
|
6086
|
-
};
|
|
6087
|
-
// <- Note: [🤖]
|
|
6084
|
+
spaceTrim$1(function (block) { return "\n Embedding model can not be used in pipeline\n\n ".concat(block(availableVariantsMessage), "\n "); });
|
|
6088
6085
|
}
|
|
6089
6086
|
else {
|
|
6090
|
-
throw new ParseError(spaceTrim$1(function (block) { return "\n Unknown model variant in command:\n\n
|
|
6087
|
+
throw new ParseError(spaceTrim$1(function (block) { return "\n Unknown model variant in command:\n\n ".concat(block(availableVariantsMessage), "\n "); }));
|
|
6091
6088
|
}
|
|
6092
6089
|
}
|
|
6093
6090
|
if (normalized.startsWith('MODEL_NAME')) {
|