@promptbook/core 0.72.0-3 → 0.72.0-5
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 +129 -52
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +4 -0
- package/esm/typings/src/collection/constructors/createCollectionFromUrl.d.ts +1 -1
- package/esm/typings/src/commands/FOREACH/ForeachJson.d.ts +5 -1
- package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +1 -1
- package/esm/typings/src/errors/AbstractFormatError.d.ts +11 -0
- package/esm/typings/src/execution/PipelineExecutor.d.ts +1 -0
- package/esm/typings/src/execution/createPipelineExecutor/00-createPipelineExecutor.d.ts +3 -0
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +3 -0
- package/esm/typings/src/execution/createPipelineExecutor/20-executeTemplate.d.ts +3 -0
- package/esm/typings/src/execution/createPipelineExecutor/{30-executeFormatCells.d.ts → 30-executeFormatSubvalues.d.ts} +2 -6
- package/esm/typings/src/execution/embeddingVectorToString.d.ts +1 -1
- package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +2 -1
- package/esm/typings/src/formats/csv/CsvFormatError.d.ts +10 -0
- package/esm/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +2 -2
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/playground/playground.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/ParameterJson.d.ts +1 -1
- package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +0 -3
- package/esm/typings/src/types/execution-report/executionReportJsonToString.d.ts +2 -1
- package/esm/typings/src/types/typeAliases.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +130 -51
- package/umd/index.umd.js.map +1 -1
package/umd/index.umd.js
CHANGED
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
/**
|
|
17
17
|
* The version of the Promptbook library
|
|
18
18
|
*/
|
|
19
|
-
var PROMPTBOOK_VERSION = '0.72.0-
|
|
20
|
-
// TODO:[main] !!!! List here all the versions and annotate + put into script
|
|
19
|
+
var PROMPTBOOK_VERSION = '0.72.0-4';
|
|
20
|
+
// TODO: [main] !!!! List here all the versions and annotate + put into script
|
|
21
21
|
|
|
22
22
|
/*! *****************************************************************************
|
|
23
23
|
Copyright (c) Microsoft Corporation.
|
|
@@ -229,7 +229,7 @@
|
|
|
229
229
|
commands.push("PIPELINE URL ".concat(pipelineUrl));
|
|
230
230
|
}
|
|
231
231
|
commands.push("PROMPTBOOK VERSION ".concat(promptbookVersion));
|
|
232
|
-
// TODO:[main] !!! This increase size of the bundle and is probbably not necessary
|
|
232
|
+
// TODO: [main] !!! This increase size of the bundle and is probbably not necessary
|
|
233
233
|
pipelineString = prettifyMarkdown(pipelineString);
|
|
234
234
|
try {
|
|
235
235
|
for (var _g = __values(parameters.filter(function (_a) {
|
|
@@ -377,12 +377,12 @@
|
|
|
377
377
|
pipelineString += '```' + contentLanguage;
|
|
378
378
|
pipelineString += '\n';
|
|
379
379
|
pipelineString += spaceTrim__default["default"](content);
|
|
380
|
-
// <- TODO:[main] !!! Escape
|
|
380
|
+
// <- TODO: [main] !!! Escape
|
|
381
381
|
// <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
|
|
382
382
|
pipelineString += '\n';
|
|
383
383
|
pipelineString += '```';
|
|
384
384
|
pipelineString += '\n\n';
|
|
385
|
-
pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO:[main] !!! If the parameter here has description, add it and use templateParameterJsonToString
|
|
385
|
+
pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!! If the parameter here has description, add it and use templateParameterJsonToString
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
@@ -856,7 +856,7 @@
|
|
|
856
856
|
if ( /* version === '1.0.0' || */version === '2.0.0' || version === '3.0.0') {
|
|
857
857
|
return false;
|
|
858
858
|
}
|
|
859
|
-
// <- TODO:[main] !!! Check isValidPromptbookVersion against PROMPTBOOK_VERSIONS
|
|
859
|
+
// <- TODO: [main] !!! Check isValidPromptbookVersion against PROMPTBOOK_VERSIONS
|
|
860
860
|
return true;
|
|
861
861
|
}
|
|
862
862
|
|
|
@@ -1538,7 +1538,7 @@
|
|
|
1538
1538
|
});
|
|
1539
1539
|
}
|
|
1540
1540
|
/**
|
|
1541
|
-
* TODO:[main] !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
|
|
1541
|
+
* TODO: [main] !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
|
|
1542
1542
|
*/
|
|
1543
1543
|
|
|
1544
1544
|
/**
|
|
@@ -2857,7 +2857,7 @@
|
|
|
2857
2857
|
// Note: [🍭] Fixing dependent subparameterName from FOREACH command
|
|
2858
2858
|
if (foreach !== undefined) {
|
|
2859
2859
|
try {
|
|
2860
|
-
for (var _l = __values(foreach.
|
|
2860
|
+
for (var _l = __values(foreach.inputSubparameterNames), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
2861
2861
|
var subparameterName = _m.value;
|
|
2862
2862
|
if (parameterNames.has(subparameterName)) {
|
|
2863
2863
|
parameterNames.delete(subparameterName);
|
|
@@ -2972,6 +2972,42 @@
|
|
|
2972
2972
|
}
|
|
2973
2973
|
}
|
|
2974
2974
|
|
|
2975
|
+
/**
|
|
2976
|
+
* This error indicates problems parsing the format value
|
|
2977
|
+
*
|
|
2978
|
+
* For example, when the format value is not a valid JSON or CSV
|
|
2979
|
+
* This is not thrown directly but in extended classes
|
|
2980
|
+
*
|
|
2981
|
+
* @public exported from `@promptbook/core`
|
|
2982
|
+
*/
|
|
2983
|
+
var AbstractFormatError = /** @class */ (function (_super) {
|
|
2984
|
+
__extends(AbstractFormatError, _super);
|
|
2985
|
+
// Note: To allow instanceof do not put here error `name`
|
|
2986
|
+
// public readonly name = 'AbstractFormatError';
|
|
2987
|
+
function AbstractFormatError(message) {
|
|
2988
|
+
var _this = _super.call(this, message) || this;
|
|
2989
|
+
Object.setPrototypeOf(_this, AbstractFormatError.prototype);
|
|
2990
|
+
return _this;
|
|
2991
|
+
}
|
|
2992
|
+
return AbstractFormatError;
|
|
2993
|
+
}(Error));
|
|
2994
|
+
|
|
2995
|
+
/**
|
|
2996
|
+
* This error indicates problem with parsing of CSV
|
|
2997
|
+
*
|
|
2998
|
+
* @public exported from `@promptbook/core`
|
|
2999
|
+
*/
|
|
3000
|
+
var CsvFormatError = /** @class */ (function (_super) {
|
|
3001
|
+
__extends(CsvFormatError, _super);
|
|
3002
|
+
function CsvFormatError(message) {
|
|
3003
|
+
var _this = _super.call(this, message) || this;
|
|
3004
|
+
_this.name = 'CsvFormatError';
|
|
3005
|
+
Object.setPrototypeOf(_this, CsvFormatError.prototype);
|
|
3006
|
+
return _this;
|
|
3007
|
+
}
|
|
3008
|
+
return CsvFormatError;
|
|
3009
|
+
}(AbstractFormatError));
|
|
3010
|
+
|
|
2975
3011
|
/**
|
|
2976
3012
|
* @@@
|
|
2977
3013
|
*
|
|
@@ -2992,7 +3028,7 @@
|
|
|
2992
3028
|
formatName: 'CSV',
|
|
2993
3029
|
aliases: ['SPREADSHEET', 'TABLE'],
|
|
2994
3030
|
isValid: function (value, settings, schema) {
|
|
2995
|
-
// TODO:
|
|
3031
|
+
// TODO: Implement CSV validation
|
|
2996
3032
|
TODO_USE(value /* <- TODO: Use value here */);
|
|
2997
3033
|
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2998
3034
|
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
@@ -3013,7 +3049,7 @@
|
|
|
3013
3049
|
subvalueDefinitions: [
|
|
3014
3050
|
{
|
|
3015
3051
|
subvalueName: 'ROW',
|
|
3016
|
-
mapValues: function (value, settings, mapCallback) {
|
|
3052
|
+
mapValues: function (value, outputParameterName, settings, mapCallback) {
|
|
3017
3053
|
return __awaiter(this, void 0, void 0, function () {
|
|
3018
3054
|
var csv, mappedData;
|
|
3019
3055
|
var _this = this;
|
|
@@ -3022,24 +3058,22 @@
|
|
|
3022
3058
|
case 0:
|
|
3023
3059
|
csv = papaparse.parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
|
|
3024
3060
|
if (csv.errors.length !== 0) {
|
|
3025
|
-
throw new
|
|
3026
|
-
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 "); }));
|
|
3061
|
+
throw new CsvFormatError(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 "); }));
|
|
3027
3062
|
}
|
|
3028
3063
|
return [4 /*yield*/, Promise.all(csv.data.map(function (row, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
3029
|
-
var _a;
|
|
3030
|
-
var
|
|
3031
|
-
return __generator(this, function (
|
|
3032
|
-
switch (
|
|
3064
|
+
var _a, _b;
|
|
3065
|
+
var _c;
|
|
3066
|
+
return __generator(this, function (_d) {
|
|
3067
|
+
switch (_d.label) {
|
|
3033
3068
|
case 0:
|
|
3069
|
+
if (row[outputParameterName]) {
|
|
3070
|
+
throw new CsvFormatError("Can not overwrite existing column \"".concat(outputParameterName, "\" in CSV row"));
|
|
3071
|
+
}
|
|
3034
3072
|
_a = [__assign({}, row)];
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
// <- TODO: !!!!!! Check name collisions
|
|
3073
|
+
_c = {};
|
|
3074
|
+
_b = outputParameterName;
|
|
3038
3075
|
return [4 /*yield*/, mapCallback(row, index)];
|
|
3039
|
-
case 1: return [2 /*return*/,
|
|
3040
|
-
// <- TODO: !!!!!! Dynamic new column name and position
|
|
3041
|
-
// <- TODO: !!!!!! Check name collisions
|
|
3042
|
-
_c.sent(), _b)])))];
|
|
3076
|
+
case 1: return [2 /*return*/, __assign.apply(void 0, _a.concat([(_c[_b] = _d.sent(), _c)]))];
|
|
3043
3077
|
}
|
|
3044
3078
|
});
|
|
3045
3079
|
}); }))];
|
|
@@ -3053,7 +3087,7 @@
|
|
|
3053
3087
|
},
|
|
3054
3088
|
{
|
|
3055
3089
|
subvalueName: 'CELL',
|
|
3056
|
-
mapValues: function (value, settings, mapCallback) {
|
|
3090
|
+
mapValues: function (value, outputParameterName, settings, mapCallback) {
|
|
3057
3091
|
return __awaiter(this, void 0, void 0, function () {
|
|
3058
3092
|
var csv, mappedData;
|
|
3059
3093
|
var _this = this;
|
|
@@ -3062,8 +3096,7 @@
|
|
|
3062
3096
|
case 0:
|
|
3063
3097
|
csv = papaparse.parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
|
|
3064
3098
|
if (csv.errors.length !== 0) {
|
|
3065
|
-
throw new
|
|
3066
|
-
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 "); }));
|
|
3099
|
+
throw new CsvFormatError(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 "); }));
|
|
3067
3100
|
}
|
|
3068
3101
|
return [4 /*yield*/, Promise.all(csv.data.map(function (row, rowIndex) { return __awaiter(_this, void 0, void 0, function () {
|
|
3069
3102
|
var _this = this;
|
|
@@ -3180,7 +3213,7 @@
|
|
|
3180
3213
|
subvalueDefinitions: [
|
|
3181
3214
|
{
|
|
3182
3215
|
subvalueName: 'LINE',
|
|
3183
|
-
mapValues: function (value, settings, mapCallback) {
|
|
3216
|
+
mapValues: function (value, outputParameterName, settings, mapCallback) {
|
|
3184
3217
|
return __awaiter(this, void 0, void 0, function () {
|
|
3185
3218
|
var lines, mappedLines;
|
|
3186
3219
|
return __generator(this, function (_a) {
|
|
@@ -3770,7 +3803,9 @@
|
|
|
3770
3803
|
title: template.title,
|
|
3771
3804
|
pipelineUrl: "".concat(preparedPipeline.pipelineUrl
|
|
3772
3805
|
? preparedPipeline.pipelineUrl
|
|
3773
|
-
: 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(template.name
|
|
3806
|
+
: 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(template.name
|
|
3807
|
+
// <- TODO: Here should be maybe also subformat index to distinguish between same template with different subformat values
|
|
3808
|
+
),
|
|
3774
3809
|
parameters: parameters,
|
|
3775
3810
|
content: preparedContent,
|
|
3776
3811
|
modelRequirements: modelRequirements,
|
|
@@ -4074,7 +4109,7 @@
|
|
|
4074
4109
|
*
|
|
4075
4110
|
* @private internal utility of `createPipelineExecutor`
|
|
4076
4111
|
*/
|
|
4077
|
-
function
|
|
4112
|
+
function executeFormatSubvalues(options) {
|
|
4078
4113
|
return __awaiter(this, void 0, void 0, function () {
|
|
4079
4114
|
var template, jokerParameterNames, parameters, priority, pipelineIdentification, settings, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
|
|
4080
4115
|
var _this = this;
|
|
@@ -4112,18 +4147,18 @@
|
|
|
4112
4147
|
}
|
|
4113
4148
|
if (formatDefinition.formatName === 'CSV') {
|
|
4114
4149
|
formatSettings = settings.csvSettings;
|
|
4115
|
-
// <- TODO:
|
|
4150
|
+
// <- TODO: [🤹♂️] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
|
|
4116
4151
|
}
|
|
4117
|
-
return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
4152
|
+
return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, template.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
4118
4153
|
var mappedParameters, allSubparameters, subresultString;
|
|
4119
4154
|
return __generator(this, function (_a) {
|
|
4120
4155
|
switch (_a.label) {
|
|
4121
4156
|
case 0:
|
|
4122
|
-
// TODO:
|
|
4123
|
-
// TODO:
|
|
4157
|
+
// TODO: [🤹♂️][🪂] Limit to N concurrent executions
|
|
4158
|
+
// TODO: When done [🐚] Report progress also for each subvalue here
|
|
4124
4159
|
try {
|
|
4125
4160
|
mappedParameters = mapAvailableToExpectedParameters({
|
|
4126
|
-
expectedParameters: Object.fromEntries(template.foreach.
|
|
4161
|
+
expectedParameters: Object.fromEntries(template.foreach.inputSubparameterNames.map(function (subparameterName) { return [subparameterName, null]; })),
|
|
4127
4162
|
availableParameters: subparameters,
|
|
4128
4163
|
});
|
|
4129
4164
|
}
|
|
@@ -4150,10 +4185,6 @@
|
|
|
4150
4185
|
});
|
|
4151
4186
|
});
|
|
4152
4187
|
}
|
|
4153
|
-
/**
|
|
4154
|
-
* TODO: !!!!!! Make pipelineIdentification more precise
|
|
4155
|
-
* TODO: !!!!!! How FOREACH execution looks in the report
|
|
4156
|
-
*/
|
|
4157
4188
|
|
|
4158
4189
|
/**
|
|
4159
4190
|
* @@@
|
|
@@ -4347,7 +4378,7 @@
|
|
|
4347
4378
|
preparedContent = (currentTemplate.preparedContent || '{content}')
|
|
4348
4379
|
.split('{content}')
|
|
4349
4380
|
.join(currentTemplate.content);
|
|
4350
|
-
return [4 /*yield*/,
|
|
4381
|
+
return [4 /*yield*/, executeFormatSubvalues({
|
|
4351
4382
|
jokerParameterNames: jokerParameterNames,
|
|
4352
4383
|
priority: priority,
|
|
4353
4384
|
maxAttempts: maxAttempts,
|
|
@@ -4387,6 +4418,9 @@
|
|
|
4387
4418
|
/**
|
|
4388
4419
|
* TODO: [🤹♂️]
|
|
4389
4420
|
*/
|
|
4421
|
+
/**
|
|
4422
|
+
* TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
|
|
4423
|
+
*/
|
|
4390
4424
|
|
|
4391
4425
|
/**
|
|
4392
4426
|
* @@@
|
|
@@ -4738,6 +4772,9 @@
|
|
|
4738
4772
|
});
|
|
4739
4773
|
});
|
|
4740
4774
|
}
|
|
4775
|
+
/**
|
|
4776
|
+
* TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
|
|
4777
|
+
*/
|
|
4741
4778
|
|
|
4742
4779
|
/**
|
|
4743
4780
|
* Creates executor function from pipeline and execution tools.
|
|
@@ -4795,6 +4832,9 @@
|
|
|
4795
4832
|
}); };
|
|
4796
4833
|
return pipelineExecutor;
|
|
4797
4834
|
}
|
|
4835
|
+
/**
|
|
4836
|
+
* TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
|
|
4837
|
+
*/
|
|
4798
4838
|
|
|
4799
4839
|
/**
|
|
4800
4840
|
* @@@
|
|
@@ -4846,7 +4886,7 @@
|
|
|
4846
4886
|
outputParameters = result.outputParameters;
|
|
4847
4887
|
knowledgePiecesRaw = outputParameters.knowledgePieces;
|
|
4848
4888
|
knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
4849
|
-
// <- TODO:[main] !!!!! Smarter split and filter out empty pieces
|
|
4889
|
+
// <- TODO: [main] !!!!! Smarter split and filter out empty pieces
|
|
4850
4890
|
if (isVerbose) {
|
|
4851
4891
|
console.info('knowledgeTextPieces:', knowledgeTextPieces);
|
|
4852
4892
|
}
|
|
@@ -5196,7 +5236,7 @@
|
|
|
5196
5236
|
case 0:
|
|
5197
5237
|
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a;
|
|
5198
5238
|
templates = pipeline.templates, parameters = pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
|
|
5199
|
-
// TODO:[main] !!!!! Apply samples to each template (if missing and is for the template defined)
|
|
5239
|
+
// TODO: [main] !!!!! Apply samples to each template (if missing and is for the template defined)
|
|
5200
5240
|
TODO_USE(parameters);
|
|
5201
5241
|
templatesPrepared = new Array(
|
|
5202
5242
|
// <- TODO: [🧱] Implement in a functional (not new Class) way
|
|
@@ -5400,7 +5440,7 @@
|
|
|
5400
5440
|
if (sourceContent === '') {
|
|
5401
5441
|
throw new ParseError("Source is not defined");
|
|
5402
5442
|
}
|
|
5403
|
-
// TODO:[main] !!!! Following checks should be applied every link in the `sourceContent`
|
|
5443
|
+
// TODO: [main] !!!! Following checks should be applied every link in the `sourceContent`
|
|
5404
5444
|
if (sourceContent.startsWith('http://')) {
|
|
5405
5445
|
throw new ParseError("Source is not secure");
|
|
5406
5446
|
}
|
|
@@ -6135,8 +6175,10 @@
|
|
|
6135
6175
|
*/
|
|
6136
6176
|
examples: [
|
|
6137
6177
|
'FOREACH Text Line `{customers}` -> `{customer}`',
|
|
6138
|
-
'
|
|
6139
|
-
'
|
|
6178
|
+
'FOREACH Csv Cell `{customers}` -> `{cell}`',
|
|
6179
|
+
'FOREACH Csv Row `{customers}` -> `{firstName}`, `{lastName}`, `+{email}`',
|
|
6180
|
+
'FOR Text Line `{customers}` -> `{customer}`',
|
|
6181
|
+
'EACH Text Line `{customers}` -> `{customer}`',
|
|
6140
6182
|
],
|
|
6141
6183
|
/**
|
|
6142
6184
|
* Parses the FOREACH command
|
|
@@ -6170,20 +6212,49 @@
|
|
|
6170
6212
|
throw new ParseError("FOREACH command must have '->' to assign the value to the parameter");
|
|
6171
6213
|
}
|
|
6172
6214
|
var parameterName = validateParameterName(parameterNameArg);
|
|
6173
|
-
var
|
|
6215
|
+
var outputSubparameterName = null;
|
|
6216
|
+
// TODO: [4] DRY
|
|
6217
|
+
var inputSubparameterNames = args
|
|
6174
6218
|
.slice(4)
|
|
6175
6219
|
.map(function (parameterName) { return parameterName.split(',').join(' ').trim(); })
|
|
6220
|
+
.filter(function (parameterName) { return !parameterName.includes('+'); })
|
|
6176
6221
|
.filter(function (parameterName) { return parameterName !== ''; })
|
|
6177
6222
|
.map(validateParameterName);
|
|
6178
|
-
|
|
6179
|
-
|
|
6223
|
+
// TODO: [4] DRY
|
|
6224
|
+
var outputSubparameterNames = args
|
|
6225
|
+
.slice(4)
|
|
6226
|
+
.map(function (parameterName) { return parameterName.split(',').join(' ').trim(); })
|
|
6227
|
+
.filter(function (parameterName) { return parameterName.includes('+'); })
|
|
6228
|
+
.map(function (parameterName) { return parameterName.split('+').join(''); })
|
|
6229
|
+
.map(validateParameterName);
|
|
6230
|
+
if (outputSubparameterNames.length === 1) {
|
|
6231
|
+
outputSubparameterName = outputSubparameterNames[0];
|
|
6232
|
+
}
|
|
6233
|
+
else if (outputSubparameterNames.length > 1) {
|
|
6234
|
+
throw new ParseError("FOREACH command can not have more than one output subparameter");
|
|
6235
|
+
}
|
|
6236
|
+
if (inputSubparameterNames.length === 0) {
|
|
6237
|
+
throw new ParseError("FOREACH command must have at least one input subparameter");
|
|
6238
|
+
}
|
|
6239
|
+
if (outputSubparameterName === null) {
|
|
6240
|
+
// TODO: Following code should be unhardcoded from here and moved to the format definition
|
|
6241
|
+
if (formatName === 'CSV' && subformatName === 'CELL') {
|
|
6242
|
+
outputSubparameterName = 'newCell';
|
|
6243
|
+
}
|
|
6244
|
+
else if (formatName === 'TEXT' && subformatName === 'LINE') {
|
|
6245
|
+
outputSubparameterName = 'newLine';
|
|
6246
|
+
}
|
|
6247
|
+
else {
|
|
6248
|
+
throw new ParseError(spaceTrim__default["default"]("\n FOREACH ".concat(formatName, " ").concat(subformatName, " must specify output subparameter\n\n Correct example:\n - FOREACH ").concat(formatName, " ").concat(subformatName, " {").concat(parameterName, "} -> {inputSubparameterName1}, {inputSubparameterName2}, +{outputSubparameterName}\n\n ")));
|
|
6249
|
+
}
|
|
6180
6250
|
}
|
|
6181
6251
|
return {
|
|
6182
6252
|
type: 'FOREACH',
|
|
6183
6253
|
formatName: formatName,
|
|
6184
6254
|
subformatName: subformatName,
|
|
6185
6255
|
parameterName: parameterName,
|
|
6186
|
-
|
|
6256
|
+
inputSubparameterNames: inputSubparameterNames,
|
|
6257
|
+
outputSubparameterName: outputSubparameterName,
|
|
6187
6258
|
};
|
|
6188
6259
|
},
|
|
6189
6260
|
/**
|
|
@@ -6192,10 +6263,16 @@
|
|
|
6192
6263
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
6193
6264
|
*/
|
|
6194
6265
|
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
6195
|
-
var formatName = command.formatName, subformatName = command.subformatName, parameterName = command.parameterName,
|
|
6266
|
+
var formatName = command.formatName, subformatName = command.subformatName, parameterName = command.parameterName, inputSubparameterNames = command.inputSubparameterNames, outputSubparameterName = command.outputSubparameterName;
|
|
6196
6267
|
// TODO: [🍭] Detect double use
|
|
6197
6268
|
// TODO: [🍭] Detect usage with JOKER and don't allow it
|
|
6198
|
-
$templateJson.foreach = {
|
|
6269
|
+
$templateJson.foreach = {
|
|
6270
|
+
formatName: formatName,
|
|
6271
|
+
subformatName: subformatName,
|
|
6272
|
+
parameterName: parameterName,
|
|
6273
|
+
inputSubparameterNames: inputSubparameterNames,
|
|
6274
|
+
outputSubparameterName: outputSubparameterName,
|
|
6275
|
+
};
|
|
6199
6276
|
keepUnused($pipelineJson); // <- TODO: [🧠] Maybe register subparameter from foreach into parameters of the pipeline
|
|
6200
6277
|
// Note: [🍭] FOREACH apply has some sideeffects on different places in codebase
|
|
6201
6278
|
},
|
|
@@ -8017,7 +8094,7 @@
|
|
|
8017
8094
|
return $asDeeplyFrozenSerializableJson('pipelineJson', $pipelineJson);
|
|
8018
8095
|
}
|
|
8019
8096
|
/**
|
|
8020
|
-
* TODO:[main] !!!! Warn if used only sync version
|
|
8097
|
+
* TODO: [main] !!!! Warn if used only sync version
|
|
8021
8098
|
* TODO: [🚞] Report here line/column of error
|
|
8022
8099
|
* TODO: Use spaceTrim more effectively
|
|
8023
8100
|
* TODO: [🧠] Parameter flags - isInput, isOutput, isInternal
|
|
@@ -9320,10 +9397,12 @@
|
|
|
9320
9397
|
|
|
9321
9398
|
exports.$llmToolsMetadataRegister = $llmToolsMetadataRegister;
|
|
9322
9399
|
exports.$llmToolsRegister = $llmToolsRegister;
|
|
9400
|
+
exports.AbstractFormatError = AbstractFormatError;
|
|
9323
9401
|
exports.CLAIM = CLAIM;
|
|
9324
9402
|
exports.CallbackInterfaceTools = CallbackInterfaceTools;
|
|
9325
9403
|
exports.CollectionError = CollectionError;
|
|
9326
9404
|
exports.CsvFormatDefinition = CsvFormatDefinition;
|
|
9405
|
+
exports.CsvFormatError = CsvFormatError;
|
|
9327
9406
|
exports.DEFAULT_CSV_SETTINGS = DEFAULT_CSV_SETTINGS;
|
|
9328
9407
|
exports.DEFAULT_REMOTE_URL = DEFAULT_REMOTE_URL;
|
|
9329
9408
|
exports.DEFAULT_REMOTE_URL_PATH = DEFAULT_REMOTE_URL_PATH;
|