@promptbook/core 0.72.0-4 → 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/esm/index.es.js
CHANGED
|
@@ -11,8 +11,8 @@ import moment from 'moment';
|
|
|
11
11
|
/**
|
|
12
12
|
* The version of the Promptbook library
|
|
13
13
|
*/
|
|
14
|
-
var PROMPTBOOK_VERSION = '0.72.0-
|
|
15
|
-
// TODO:[main] !!!! List here all the versions and annotate + put into script
|
|
14
|
+
var PROMPTBOOK_VERSION = '0.72.0-4';
|
|
15
|
+
// TODO: [main] !!!! List here all the versions and annotate + put into script
|
|
16
16
|
|
|
17
17
|
/*! *****************************************************************************
|
|
18
18
|
Copyright (c) Microsoft Corporation.
|
|
@@ -224,7 +224,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
224
224
|
commands.push("PIPELINE URL ".concat(pipelineUrl));
|
|
225
225
|
}
|
|
226
226
|
commands.push("PROMPTBOOK VERSION ".concat(promptbookVersion));
|
|
227
|
-
// TODO:[main] !!! This increase size of the bundle and is probbably not necessary
|
|
227
|
+
// TODO: [main] !!! This increase size of the bundle and is probbably not necessary
|
|
228
228
|
pipelineString = prettifyMarkdown(pipelineString);
|
|
229
229
|
try {
|
|
230
230
|
for (var _g = __values(parameters.filter(function (_a) {
|
|
@@ -372,12 +372,12 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
372
372
|
pipelineString += '```' + contentLanguage;
|
|
373
373
|
pipelineString += '\n';
|
|
374
374
|
pipelineString += spaceTrim(content);
|
|
375
|
-
// <- TODO:[main] !!! Escape
|
|
375
|
+
// <- TODO: [main] !!! Escape
|
|
376
376
|
// <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
|
|
377
377
|
pipelineString += '\n';
|
|
378
378
|
pipelineString += '```';
|
|
379
379
|
pipelineString += '\n\n';
|
|
380
|
-
pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO:[main] !!! If the parameter here has description, add it and use templateParameterJsonToString
|
|
380
|
+
pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!! If the parameter here has description, add it and use templateParameterJsonToString
|
|
381
381
|
}
|
|
382
382
|
}
|
|
383
383
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
@@ -851,7 +851,7 @@ function isValidPromptbookVersion(version) {
|
|
|
851
851
|
if ( /* version === '1.0.0' || */version === '2.0.0' || version === '3.0.0') {
|
|
852
852
|
return false;
|
|
853
853
|
}
|
|
854
|
-
// <- TODO:[main] !!! Check isValidPromptbookVersion against PROMPTBOOK_VERSIONS
|
|
854
|
+
// <- TODO: [main] !!! Check isValidPromptbookVersion against PROMPTBOOK_VERSIONS
|
|
855
855
|
return true;
|
|
856
856
|
}
|
|
857
857
|
|
|
@@ -1533,7 +1533,7 @@ function createCollectionFromUrl(url, options) {
|
|
|
1533
1533
|
});
|
|
1534
1534
|
}
|
|
1535
1535
|
/**
|
|
1536
|
-
* TODO:[main] !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
|
|
1536
|
+
* TODO: [main] !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
|
|
1537
1537
|
*/
|
|
1538
1538
|
|
|
1539
1539
|
/**
|
|
@@ -2852,7 +2852,7 @@ function extractParameterNamesFromTemplate(template) {
|
|
|
2852
2852
|
// Note: [🍭] Fixing dependent subparameterName from FOREACH command
|
|
2853
2853
|
if (foreach !== undefined) {
|
|
2854
2854
|
try {
|
|
2855
|
-
for (var _l = __values(foreach.
|
|
2855
|
+
for (var _l = __values(foreach.inputSubparameterNames), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
2856
2856
|
var subparameterName = _m.value;
|
|
2857
2857
|
if (parameterNames.has(subparameterName)) {
|
|
2858
2858
|
parameterNames.delete(subparameterName);
|
|
@@ -2967,6 +2967,42 @@ function TODO_USE() {
|
|
|
2967
2967
|
}
|
|
2968
2968
|
}
|
|
2969
2969
|
|
|
2970
|
+
/**
|
|
2971
|
+
* This error indicates problems parsing the format value
|
|
2972
|
+
*
|
|
2973
|
+
* For example, when the format value is not a valid JSON or CSV
|
|
2974
|
+
* This is not thrown directly but in extended classes
|
|
2975
|
+
*
|
|
2976
|
+
* @public exported from `@promptbook/core`
|
|
2977
|
+
*/
|
|
2978
|
+
var AbstractFormatError = /** @class */ (function (_super) {
|
|
2979
|
+
__extends(AbstractFormatError, _super);
|
|
2980
|
+
// Note: To allow instanceof do not put here error `name`
|
|
2981
|
+
// public readonly name = 'AbstractFormatError';
|
|
2982
|
+
function AbstractFormatError(message) {
|
|
2983
|
+
var _this = _super.call(this, message) || this;
|
|
2984
|
+
Object.setPrototypeOf(_this, AbstractFormatError.prototype);
|
|
2985
|
+
return _this;
|
|
2986
|
+
}
|
|
2987
|
+
return AbstractFormatError;
|
|
2988
|
+
}(Error));
|
|
2989
|
+
|
|
2990
|
+
/**
|
|
2991
|
+
* This error indicates problem with parsing of CSV
|
|
2992
|
+
*
|
|
2993
|
+
* @public exported from `@promptbook/core`
|
|
2994
|
+
*/
|
|
2995
|
+
var CsvFormatError = /** @class */ (function (_super) {
|
|
2996
|
+
__extends(CsvFormatError, _super);
|
|
2997
|
+
function CsvFormatError(message) {
|
|
2998
|
+
var _this = _super.call(this, message) || this;
|
|
2999
|
+
_this.name = 'CsvFormatError';
|
|
3000
|
+
Object.setPrototypeOf(_this, CsvFormatError.prototype);
|
|
3001
|
+
return _this;
|
|
3002
|
+
}
|
|
3003
|
+
return CsvFormatError;
|
|
3004
|
+
}(AbstractFormatError));
|
|
3005
|
+
|
|
2970
3006
|
/**
|
|
2971
3007
|
* @@@
|
|
2972
3008
|
*
|
|
@@ -2987,7 +3023,7 @@ var CsvFormatDefinition = {
|
|
|
2987
3023
|
formatName: 'CSV',
|
|
2988
3024
|
aliases: ['SPREADSHEET', 'TABLE'],
|
|
2989
3025
|
isValid: function (value, settings, schema) {
|
|
2990
|
-
// TODO:
|
|
3026
|
+
// TODO: Implement CSV validation
|
|
2991
3027
|
TODO_USE(value /* <- TODO: Use value here */);
|
|
2992
3028
|
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2993
3029
|
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
@@ -3008,7 +3044,7 @@ var CsvFormatDefinition = {
|
|
|
3008
3044
|
subvalueDefinitions: [
|
|
3009
3045
|
{
|
|
3010
3046
|
subvalueName: 'ROW',
|
|
3011
|
-
mapValues: function (value, settings, mapCallback) {
|
|
3047
|
+
mapValues: function (value, outputParameterName, settings, mapCallback) {
|
|
3012
3048
|
return __awaiter(this, void 0, void 0, function () {
|
|
3013
3049
|
var csv, mappedData;
|
|
3014
3050
|
var _this = this;
|
|
@@ -3017,24 +3053,22 @@ var CsvFormatDefinition = {
|
|
|
3017
3053
|
case 0:
|
|
3018
3054
|
csv = parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
|
|
3019
3055
|
if (csv.errors.length !== 0) {
|
|
3020
|
-
throw new
|
|
3021
|
-
spaceTrim(function (block) { return "\n CSV parsing error\n\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n "); }));
|
|
3056
|
+
throw new CsvFormatError(spaceTrim(function (block) { return "\n CSV parsing error\n\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n "); }));
|
|
3022
3057
|
}
|
|
3023
3058
|
return [4 /*yield*/, Promise.all(csv.data.map(function (row, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
3024
|
-
var _a;
|
|
3025
|
-
var
|
|
3026
|
-
return __generator(this, function (
|
|
3027
|
-
switch (
|
|
3059
|
+
var _a, _b;
|
|
3060
|
+
var _c;
|
|
3061
|
+
return __generator(this, function (_d) {
|
|
3062
|
+
switch (_d.label) {
|
|
3028
3063
|
case 0:
|
|
3064
|
+
if (row[outputParameterName]) {
|
|
3065
|
+
throw new CsvFormatError("Can not overwrite existing column \"".concat(outputParameterName, "\" in CSV row"));
|
|
3066
|
+
}
|
|
3029
3067
|
_a = [__assign({}, row)];
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
// <- TODO: !!!!!! Check name collisions
|
|
3068
|
+
_c = {};
|
|
3069
|
+
_b = outputParameterName;
|
|
3033
3070
|
return [4 /*yield*/, mapCallback(row, index)];
|
|
3034
|
-
case 1: return [2 /*return*/,
|
|
3035
|
-
// <- TODO: !!!!!! Dynamic new column name and position
|
|
3036
|
-
// <- TODO: !!!!!! Check name collisions
|
|
3037
|
-
_c.sent(), _b)])))];
|
|
3071
|
+
case 1: return [2 /*return*/, __assign.apply(void 0, _a.concat([(_c[_b] = _d.sent(), _c)]))];
|
|
3038
3072
|
}
|
|
3039
3073
|
});
|
|
3040
3074
|
}); }))];
|
|
@@ -3048,7 +3082,7 @@ var CsvFormatDefinition = {
|
|
|
3048
3082
|
},
|
|
3049
3083
|
{
|
|
3050
3084
|
subvalueName: 'CELL',
|
|
3051
|
-
mapValues: function (value, settings, mapCallback) {
|
|
3085
|
+
mapValues: function (value, outputParameterName, settings, mapCallback) {
|
|
3052
3086
|
return __awaiter(this, void 0, void 0, function () {
|
|
3053
3087
|
var csv, mappedData;
|
|
3054
3088
|
var _this = this;
|
|
@@ -3057,8 +3091,7 @@ var CsvFormatDefinition = {
|
|
|
3057
3091
|
case 0:
|
|
3058
3092
|
csv = parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
|
|
3059
3093
|
if (csv.errors.length !== 0) {
|
|
3060
|
-
throw new
|
|
3061
|
-
spaceTrim(function (block) { return "\n CSV parsing error\n\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n "); }));
|
|
3094
|
+
throw new CsvFormatError(spaceTrim(function (block) { return "\n CSV parsing error\n\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n "); }));
|
|
3062
3095
|
}
|
|
3063
3096
|
return [4 /*yield*/, Promise.all(csv.data.map(function (row, rowIndex) { return __awaiter(_this, void 0, void 0, function () {
|
|
3064
3097
|
var _this = this;
|
|
@@ -3175,7 +3208,7 @@ var TextFormatDefinition = {
|
|
|
3175
3208
|
subvalueDefinitions: [
|
|
3176
3209
|
{
|
|
3177
3210
|
subvalueName: 'LINE',
|
|
3178
|
-
mapValues: function (value, settings, mapCallback) {
|
|
3211
|
+
mapValues: function (value, outputParameterName, settings, mapCallback) {
|
|
3179
3212
|
return __awaiter(this, void 0, void 0, function () {
|
|
3180
3213
|
var lines, mappedLines;
|
|
3181
3214
|
return __generator(this, function (_a) {
|
|
@@ -3765,7 +3798,9 @@ function executeAttempts(options) {
|
|
|
3765
3798
|
title: template.title,
|
|
3766
3799
|
pipelineUrl: "".concat(preparedPipeline.pipelineUrl
|
|
3767
3800
|
? preparedPipeline.pipelineUrl
|
|
3768
|
-
: 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(template.name
|
|
3801
|
+
: 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(template.name
|
|
3802
|
+
// <- TODO: Here should be maybe also subformat index to distinguish between same template with different subformat values
|
|
3803
|
+
),
|
|
3769
3804
|
parameters: parameters,
|
|
3770
3805
|
content: preparedContent,
|
|
3771
3806
|
modelRequirements: modelRequirements,
|
|
@@ -4069,7 +4104,7 @@ function executeAttempts(options) {
|
|
|
4069
4104
|
*
|
|
4070
4105
|
* @private internal utility of `createPipelineExecutor`
|
|
4071
4106
|
*/
|
|
4072
|
-
function
|
|
4107
|
+
function executeFormatSubvalues(options) {
|
|
4073
4108
|
return __awaiter(this, void 0, void 0, function () {
|
|
4074
4109
|
var template, jokerParameterNames, parameters, priority, pipelineIdentification, settings, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
|
|
4075
4110
|
var _this = this;
|
|
@@ -4107,18 +4142,18 @@ function executeFormatCells(options) {
|
|
|
4107
4142
|
}
|
|
4108
4143
|
if (formatDefinition.formatName === 'CSV') {
|
|
4109
4144
|
formatSettings = settings.csvSettings;
|
|
4110
|
-
// <- TODO:
|
|
4145
|
+
// <- TODO: [🤹♂️] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
|
|
4111
4146
|
}
|
|
4112
|
-
return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
4147
|
+
return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, template.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
4113
4148
|
var mappedParameters, allSubparameters, subresultString;
|
|
4114
4149
|
return __generator(this, function (_a) {
|
|
4115
4150
|
switch (_a.label) {
|
|
4116
4151
|
case 0:
|
|
4117
|
-
// TODO:
|
|
4118
|
-
// TODO:
|
|
4152
|
+
// TODO: [🤹♂️][🪂] Limit to N concurrent executions
|
|
4153
|
+
// TODO: When done [🐚] Report progress also for each subvalue here
|
|
4119
4154
|
try {
|
|
4120
4155
|
mappedParameters = mapAvailableToExpectedParameters({
|
|
4121
|
-
expectedParameters: Object.fromEntries(template.foreach.
|
|
4156
|
+
expectedParameters: Object.fromEntries(template.foreach.inputSubparameterNames.map(function (subparameterName) { return [subparameterName, null]; })),
|
|
4122
4157
|
availableParameters: subparameters,
|
|
4123
4158
|
});
|
|
4124
4159
|
}
|
|
@@ -4145,10 +4180,6 @@ function executeFormatCells(options) {
|
|
|
4145
4180
|
});
|
|
4146
4181
|
});
|
|
4147
4182
|
}
|
|
4148
|
-
/**
|
|
4149
|
-
* TODO: !!!!!! Make pipelineIdentification more precise
|
|
4150
|
-
* TODO: !!!!!! How FOREACH execution looks in the report
|
|
4151
|
-
*/
|
|
4152
4183
|
|
|
4153
4184
|
/**
|
|
4154
4185
|
* @@@
|
|
@@ -4342,7 +4373,7 @@ function executeTemplate(options) {
|
|
|
4342
4373
|
preparedContent = (currentTemplate.preparedContent || '{content}')
|
|
4343
4374
|
.split('{content}')
|
|
4344
4375
|
.join(currentTemplate.content);
|
|
4345
|
-
return [4 /*yield*/,
|
|
4376
|
+
return [4 /*yield*/, executeFormatSubvalues({
|
|
4346
4377
|
jokerParameterNames: jokerParameterNames,
|
|
4347
4378
|
priority: priority,
|
|
4348
4379
|
maxAttempts: maxAttempts,
|
|
@@ -4382,6 +4413,9 @@ function executeTemplate(options) {
|
|
|
4382
4413
|
/**
|
|
4383
4414
|
* TODO: [🤹♂️]
|
|
4384
4415
|
*/
|
|
4416
|
+
/**
|
|
4417
|
+
* TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
|
|
4418
|
+
*/
|
|
4385
4419
|
|
|
4386
4420
|
/**
|
|
4387
4421
|
* @@@
|
|
@@ -4733,6 +4767,9 @@ function executePipeline(options) {
|
|
|
4733
4767
|
});
|
|
4734
4768
|
});
|
|
4735
4769
|
}
|
|
4770
|
+
/**
|
|
4771
|
+
* TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
|
|
4772
|
+
*/
|
|
4736
4773
|
|
|
4737
4774
|
/**
|
|
4738
4775
|
* Creates executor function from pipeline and execution tools.
|
|
@@ -4790,6 +4827,9 @@ function createPipelineExecutor(options) {
|
|
|
4790
4827
|
}); };
|
|
4791
4828
|
return pipelineExecutor;
|
|
4792
4829
|
}
|
|
4830
|
+
/**
|
|
4831
|
+
* TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
|
|
4832
|
+
*/
|
|
4793
4833
|
|
|
4794
4834
|
/**
|
|
4795
4835
|
* @@@
|
|
@@ -4841,7 +4881,7 @@ function prepareKnowledgeFromMarkdown(knowledgeContent /* <- TODO: [🖖] (?mayb
|
|
|
4841
4881
|
outputParameters = result.outputParameters;
|
|
4842
4882
|
knowledgePiecesRaw = outputParameters.knowledgePieces;
|
|
4843
4883
|
knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
4844
|
-
// <- TODO:[main] !!!!! Smarter split and filter out empty pieces
|
|
4884
|
+
// <- TODO: [main] !!!!! Smarter split and filter out empty pieces
|
|
4845
4885
|
if (isVerbose) {
|
|
4846
4886
|
console.info('knowledgeTextPieces:', knowledgeTextPieces);
|
|
4847
4887
|
}
|
|
@@ -5191,7 +5231,7 @@ function prepareTemplates(pipeline, options) {
|
|
|
5191
5231
|
case 0:
|
|
5192
5232
|
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a;
|
|
5193
5233
|
templates = pipeline.templates, parameters = pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
|
|
5194
|
-
// TODO:[main] !!!!! Apply samples to each template (if missing and is for the template defined)
|
|
5234
|
+
// TODO: [main] !!!!! Apply samples to each template (if missing and is for the template defined)
|
|
5195
5235
|
TODO_USE(parameters);
|
|
5196
5236
|
templatesPrepared = new Array(
|
|
5197
5237
|
// <- TODO: [🧱] Implement in a functional (not new Class) way
|
|
@@ -5395,7 +5435,7 @@ var knowledgeCommandParser = {
|
|
|
5395
5435
|
if (sourceContent === '') {
|
|
5396
5436
|
throw new ParseError("Source is not defined");
|
|
5397
5437
|
}
|
|
5398
|
-
// TODO:[main] !!!! Following checks should be applied every link in the `sourceContent`
|
|
5438
|
+
// TODO: [main] !!!! Following checks should be applied every link in the `sourceContent`
|
|
5399
5439
|
if (sourceContent.startsWith('http://')) {
|
|
5400
5440
|
throw new ParseError("Source is not secure");
|
|
5401
5441
|
}
|
|
@@ -6130,8 +6170,10 @@ var foreachCommandParser = {
|
|
|
6130
6170
|
*/
|
|
6131
6171
|
examples: [
|
|
6132
6172
|
'FOREACH Text Line `{customers}` -> `{customer}`',
|
|
6133
|
-
'
|
|
6134
|
-
'
|
|
6173
|
+
'FOREACH Csv Cell `{customers}` -> `{cell}`',
|
|
6174
|
+
'FOREACH Csv Row `{customers}` -> `{firstName}`, `{lastName}`, `+{email}`',
|
|
6175
|
+
'FOR Text Line `{customers}` -> `{customer}`',
|
|
6176
|
+
'EACH Text Line `{customers}` -> `{customer}`',
|
|
6135
6177
|
],
|
|
6136
6178
|
/**
|
|
6137
6179
|
* Parses the FOREACH command
|
|
@@ -6165,20 +6207,49 @@ var foreachCommandParser = {
|
|
|
6165
6207
|
throw new ParseError("FOREACH command must have '->' to assign the value to the parameter");
|
|
6166
6208
|
}
|
|
6167
6209
|
var parameterName = validateParameterName(parameterNameArg);
|
|
6168
|
-
var
|
|
6210
|
+
var outputSubparameterName = null;
|
|
6211
|
+
// TODO: [4] DRY
|
|
6212
|
+
var inputSubparameterNames = args
|
|
6169
6213
|
.slice(4)
|
|
6170
6214
|
.map(function (parameterName) { return parameterName.split(',').join(' ').trim(); })
|
|
6215
|
+
.filter(function (parameterName) { return !parameterName.includes('+'); })
|
|
6171
6216
|
.filter(function (parameterName) { return parameterName !== ''; })
|
|
6172
6217
|
.map(validateParameterName);
|
|
6173
|
-
|
|
6174
|
-
|
|
6218
|
+
// TODO: [4] DRY
|
|
6219
|
+
var outputSubparameterNames = args
|
|
6220
|
+
.slice(4)
|
|
6221
|
+
.map(function (parameterName) { return parameterName.split(',').join(' ').trim(); })
|
|
6222
|
+
.filter(function (parameterName) { return parameterName.includes('+'); })
|
|
6223
|
+
.map(function (parameterName) { return parameterName.split('+').join(''); })
|
|
6224
|
+
.map(validateParameterName);
|
|
6225
|
+
if (outputSubparameterNames.length === 1) {
|
|
6226
|
+
outputSubparameterName = outputSubparameterNames[0];
|
|
6227
|
+
}
|
|
6228
|
+
else if (outputSubparameterNames.length > 1) {
|
|
6229
|
+
throw new ParseError("FOREACH command can not have more than one output subparameter");
|
|
6230
|
+
}
|
|
6231
|
+
if (inputSubparameterNames.length === 0) {
|
|
6232
|
+
throw new ParseError("FOREACH command must have at least one input subparameter");
|
|
6233
|
+
}
|
|
6234
|
+
if (outputSubparameterName === null) {
|
|
6235
|
+
// TODO: Following code should be unhardcoded from here and moved to the format definition
|
|
6236
|
+
if (formatName === 'CSV' && subformatName === 'CELL') {
|
|
6237
|
+
outputSubparameterName = 'newCell';
|
|
6238
|
+
}
|
|
6239
|
+
else if (formatName === 'TEXT' && subformatName === 'LINE') {
|
|
6240
|
+
outputSubparameterName = 'newLine';
|
|
6241
|
+
}
|
|
6242
|
+
else {
|
|
6243
|
+
throw new ParseError(spaceTrim("\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 ")));
|
|
6244
|
+
}
|
|
6175
6245
|
}
|
|
6176
6246
|
return {
|
|
6177
6247
|
type: 'FOREACH',
|
|
6178
6248
|
formatName: formatName,
|
|
6179
6249
|
subformatName: subformatName,
|
|
6180
6250
|
parameterName: parameterName,
|
|
6181
|
-
|
|
6251
|
+
inputSubparameterNames: inputSubparameterNames,
|
|
6252
|
+
outputSubparameterName: outputSubparameterName,
|
|
6182
6253
|
};
|
|
6183
6254
|
},
|
|
6184
6255
|
/**
|
|
@@ -6187,10 +6258,16 @@ var foreachCommandParser = {
|
|
|
6187
6258
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
6188
6259
|
*/
|
|
6189
6260
|
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
6190
|
-
var formatName = command.formatName, subformatName = command.subformatName, parameterName = command.parameterName,
|
|
6261
|
+
var formatName = command.formatName, subformatName = command.subformatName, parameterName = command.parameterName, inputSubparameterNames = command.inputSubparameterNames, outputSubparameterName = command.outputSubparameterName;
|
|
6191
6262
|
// TODO: [🍭] Detect double use
|
|
6192
6263
|
// TODO: [🍭] Detect usage with JOKER and don't allow it
|
|
6193
|
-
$templateJson.foreach = {
|
|
6264
|
+
$templateJson.foreach = {
|
|
6265
|
+
formatName: formatName,
|
|
6266
|
+
subformatName: subformatName,
|
|
6267
|
+
parameterName: parameterName,
|
|
6268
|
+
inputSubparameterNames: inputSubparameterNames,
|
|
6269
|
+
outputSubparameterName: outputSubparameterName,
|
|
6270
|
+
};
|
|
6194
6271
|
keepUnused($pipelineJson); // <- TODO: [🧠] Maybe register subparameter from foreach into parameters of the pipeline
|
|
6195
6272
|
// Note: [🍭] FOREACH apply has some sideeffects on different places in codebase
|
|
6196
6273
|
},
|
|
@@ -8012,7 +8089,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8012
8089
|
return $asDeeplyFrozenSerializableJson('pipelineJson', $pipelineJson);
|
|
8013
8090
|
}
|
|
8014
8091
|
/**
|
|
8015
|
-
* TODO:[main] !!!! Warn if used only sync version
|
|
8092
|
+
* TODO: [main] !!!! Warn if used only sync version
|
|
8016
8093
|
* TODO: [🚞] Report here line/column of error
|
|
8017
8094
|
* TODO: Use spaceTrim more effectively
|
|
8018
8095
|
* TODO: [🧠] Parameter flags - isInput, isOutput, isInternal
|
|
@@ -9313,5 +9390,5 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
9313
9390
|
* TODO: [🧠] Should be in generated file GENERATOR_WARNING
|
|
9314
9391
|
*/
|
|
9315
9392
|
|
|
9316
|
-
export { $llmToolsMetadataRegister, $llmToolsRegister, CLAIM, CallbackInterfaceTools, CollectionError, CsvFormatDefinition, DEFAULT_CSV_SETTINGS, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, ERRORS, EXECUTIONS_CACHE_DIRNAME, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, IS_VERBOSE, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_EXECUTION_ATTEMPTS, MAX_FILENAME_LENGTH, MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, MAX_PARALLEL_COUNT, MODEL_VARIANTS, MemoryStorage, NotFoundError, NotYetImplementedError, PIPELINE_COLLECTION_BASE_FILENAME, PROMPTBOOK_VERSION, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, TemplateTypes, TextFormatDefinition, UNCERTAIN_USAGE, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, addUsage, assertsExecutionSuccessful, cacheLlmTools, collectionToJson, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, isPassingExpectations, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, prepareKnowledgeFromMarkdown, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTemplates, prettifyPipelineString, stringifyPipelineJson, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
|
|
9393
|
+
export { $llmToolsMetadataRegister, $llmToolsRegister, AbstractFormatError, CLAIM, CallbackInterfaceTools, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_CSV_SETTINGS, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, ERRORS, EXECUTIONS_CACHE_DIRNAME, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, IS_VERBOSE, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_EXECUTION_ATTEMPTS, MAX_FILENAME_LENGTH, MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, MAX_PARALLEL_COUNT, MODEL_VARIANTS, MemoryStorage, NotFoundError, NotYetImplementedError, PIPELINE_COLLECTION_BASE_FILENAME, PROMPTBOOK_VERSION, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, TemplateTypes, TextFormatDefinition, UNCERTAIN_USAGE, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, addUsage, assertsExecutionSuccessful, cacheLlmTools, collectionToJson, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, isPassingExpectations, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, prepareKnowledgeFromMarkdown, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTemplates, prettifyPipelineString, stringifyPipelineJson, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
|
|
9317
9394
|
//# sourceMappingURL=index.es.js.map
|