@promptbook/cli 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 +134 -57
- 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 +2 -2
- package/umd/index.umd.js +134 -57
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -21,8 +21,8 @@ import OpenAI from 'openai';
|
|
|
21
21
|
/**
|
|
22
22
|
* The version of the Promptbook library
|
|
23
23
|
*/
|
|
24
|
-
var PROMPTBOOK_VERSION = '0.72.0-
|
|
25
|
-
// TODO:[main] !!!! List here all the versions and annotate + put into script
|
|
24
|
+
var PROMPTBOOK_VERSION = '0.72.0-4';
|
|
25
|
+
// TODO: [main] !!!! List here all the versions and annotate + put into script
|
|
26
26
|
|
|
27
27
|
/*! *****************************************************************************
|
|
28
28
|
Copyright (c) Microsoft Corporation.
|
|
@@ -682,7 +682,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
682
682
|
commands.push("PIPELINE URL ".concat(pipelineUrl));
|
|
683
683
|
}
|
|
684
684
|
commands.push("PROMPTBOOK VERSION ".concat(promptbookVersion));
|
|
685
|
-
// TODO:[main] !!! This increase size of the bundle and is probbably not necessary
|
|
685
|
+
// TODO: [main] !!! This increase size of the bundle and is probbably not necessary
|
|
686
686
|
pipelineString = prettifyMarkdown(pipelineString);
|
|
687
687
|
try {
|
|
688
688
|
for (var _g = __values(parameters.filter(function (_a) {
|
|
@@ -830,12 +830,12 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
830
830
|
pipelineString += '```' + contentLanguage;
|
|
831
831
|
pipelineString += '\n';
|
|
832
832
|
pipelineString += spaceTrim$1(content);
|
|
833
|
-
// <- TODO:[main] !!! Escape
|
|
833
|
+
// <- TODO: [main] !!! Escape
|
|
834
834
|
// <- TODO: [๐ง ] Some clear strategy how to spaceTrim the blocks
|
|
835
835
|
pipelineString += '\n';
|
|
836
836
|
pipelineString += '```';
|
|
837
837
|
pipelineString += '\n\n';
|
|
838
|
-
pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO:[main] !!! If the parameter here has description, add it and use templateParameterJsonToString
|
|
838
|
+
pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!! If the parameter here has description, add it and use templateParameterJsonToString
|
|
839
839
|
}
|
|
840
840
|
}
|
|
841
841
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
@@ -1069,7 +1069,7 @@ function isValidPromptbookVersion(version) {
|
|
|
1069
1069
|
if ( /* version === '1.0.0' || */version === '2.0.0' || version === '3.0.0') {
|
|
1070
1070
|
return false;
|
|
1071
1071
|
}
|
|
1072
|
-
// <- TODO:[main] !!! Check isValidPromptbookVersion against PROMPTBOOK_VERSIONS
|
|
1072
|
+
// <- TODO: [main] !!! Check isValidPromptbookVersion against PROMPTBOOK_VERSIONS
|
|
1073
1073
|
return true;
|
|
1074
1074
|
}
|
|
1075
1075
|
|
|
@@ -2704,7 +2704,7 @@ function extractParameterNamesFromTemplate(template) {
|
|
|
2704
2704
|
// Note: [๐ญ] Fixing dependent subparameterName from FOREACH command
|
|
2705
2705
|
if (foreach !== undefined) {
|
|
2706
2706
|
try {
|
|
2707
|
-
for (var _l = __values(foreach.
|
|
2707
|
+
for (var _l = __values(foreach.inputSubparameterNames), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
2708
2708
|
var subparameterName = _m.value;
|
|
2709
2709
|
if (parameterNames.has(subparameterName)) {
|
|
2710
2710
|
parameterNames.delete(subparameterName);
|
|
@@ -2819,6 +2819,42 @@ function TODO_USE() {
|
|
|
2819
2819
|
}
|
|
2820
2820
|
}
|
|
2821
2821
|
|
|
2822
|
+
/**
|
|
2823
|
+
* This error indicates problems parsing the format value
|
|
2824
|
+
*
|
|
2825
|
+
* For example, when the format value is not a valid JSON or CSV
|
|
2826
|
+
* This is not thrown directly but in extended classes
|
|
2827
|
+
*
|
|
2828
|
+
* @public exported from `@promptbook/core`
|
|
2829
|
+
*/
|
|
2830
|
+
var AbstractFormatError = /** @class */ (function (_super) {
|
|
2831
|
+
__extends(AbstractFormatError, _super);
|
|
2832
|
+
// Note: To allow instanceof do not put here error `name`
|
|
2833
|
+
// public readonly name = 'AbstractFormatError';
|
|
2834
|
+
function AbstractFormatError(message) {
|
|
2835
|
+
var _this = _super.call(this, message) || this;
|
|
2836
|
+
Object.setPrototypeOf(_this, AbstractFormatError.prototype);
|
|
2837
|
+
return _this;
|
|
2838
|
+
}
|
|
2839
|
+
return AbstractFormatError;
|
|
2840
|
+
}(Error));
|
|
2841
|
+
|
|
2842
|
+
/**
|
|
2843
|
+
* This error indicates problem with parsing of CSV
|
|
2844
|
+
*
|
|
2845
|
+
* @public exported from `@promptbook/core`
|
|
2846
|
+
*/
|
|
2847
|
+
var CsvFormatError = /** @class */ (function (_super) {
|
|
2848
|
+
__extends(CsvFormatError, _super);
|
|
2849
|
+
function CsvFormatError(message) {
|
|
2850
|
+
var _this = _super.call(this, message) || this;
|
|
2851
|
+
_this.name = 'CsvFormatError';
|
|
2852
|
+
Object.setPrototypeOf(_this, CsvFormatError.prototype);
|
|
2853
|
+
return _this;
|
|
2854
|
+
}
|
|
2855
|
+
return CsvFormatError;
|
|
2856
|
+
}(AbstractFormatError));
|
|
2857
|
+
|
|
2822
2858
|
/**
|
|
2823
2859
|
* @@@
|
|
2824
2860
|
*
|
|
@@ -2839,7 +2875,7 @@ var CsvFormatDefinition = {
|
|
|
2839
2875
|
formatName: 'CSV',
|
|
2840
2876
|
aliases: ['SPREADSHEET', 'TABLE'],
|
|
2841
2877
|
isValid: function (value, settings, schema) {
|
|
2842
|
-
// TODO:
|
|
2878
|
+
// TODO: Implement CSV validation
|
|
2843
2879
|
TODO_USE(value /* <- TODO: Use value here */);
|
|
2844
2880
|
TODO_USE(settings /* <- TODO: Use settings here */);
|
|
2845
2881
|
TODO_USE(schema /* <- TODO: Use schema here */);
|
|
@@ -2860,7 +2896,7 @@ var CsvFormatDefinition = {
|
|
|
2860
2896
|
subvalueDefinitions: [
|
|
2861
2897
|
{
|
|
2862
2898
|
subvalueName: 'ROW',
|
|
2863
|
-
mapValues: function (value, settings, mapCallback) {
|
|
2899
|
+
mapValues: function (value, outputParameterName, settings, mapCallback) {
|
|
2864
2900
|
return __awaiter(this, void 0, void 0, function () {
|
|
2865
2901
|
var csv, mappedData;
|
|
2866
2902
|
var _this = this;
|
|
@@ -2869,24 +2905,22 @@ var CsvFormatDefinition = {
|
|
|
2869
2905
|
case 0:
|
|
2870
2906
|
csv = parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
|
|
2871
2907
|
if (csv.errors.length !== 0) {
|
|
2872
|
-
throw new
|
|
2873
|
-
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 "); }));
|
|
2908
|
+
throw new CsvFormatError(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 "); }));
|
|
2874
2909
|
}
|
|
2875
2910
|
return [4 /*yield*/, Promise.all(csv.data.map(function (row, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
2876
|
-
var _a;
|
|
2877
|
-
var
|
|
2878
|
-
return __generator(this, function (
|
|
2879
|
-
switch (
|
|
2911
|
+
var _a, _b;
|
|
2912
|
+
var _c;
|
|
2913
|
+
return __generator(this, function (_d) {
|
|
2914
|
+
switch (_d.label) {
|
|
2880
2915
|
case 0:
|
|
2916
|
+
if (row[outputParameterName]) {
|
|
2917
|
+
throw new CsvFormatError("Can not overwrite existing column \"".concat(outputParameterName, "\" in CSV row"));
|
|
2918
|
+
}
|
|
2881
2919
|
_a = [__assign({}, row)];
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
// <- TODO: !!!!!! Check name collisions
|
|
2920
|
+
_c = {};
|
|
2921
|
+
_b = outputParameterName;
|
|
2885
2922
|
return [4 /*yield*/, mapCallback(row, index)];
|
|
2886
|
-
case 1: return [2 /*return*/,
|
|
2887
|
-
// <- TODO: !!!!!! Dynamic new column name and position
|
|
2888
|
-
// <- TODO: !!!!!! Check name collisions
|
|
2889
|
-
_c.sent(), _b)])))];
|
|
2923
|
+
case 1: return [2 /*return*/, __assign.apply(void 0, _a.concat([(_c[_b] = _d.sent(), _c)]))];
|
|
2890
2924
|
}
|
|
2891
2925
|
});
|
|
2892
2926
|
}); }))];
|
|
@@ -2900,7 +2934,7 @@ var CsvFormatDefinition = {
|
|
|
2900
2934
|
},
|
|
2901
2935
|
{
|
|
2902
2936
|
subvalueName: 'CELL',
|
|
2903
|
-
mapValues: function (value, settings, mapCallback) {
|
|
2937
|
+
mapValues: function (value, outputParameterName, settings, mapCallback) {
|
|
2904
2938
|
return __awaiter(this, void 0, void 0, function () {
|
|
2905
2939
|
var csv, mappedData;
|
|
2906
2940
|
var _this = this;
|
|
@@ -2909,8 +2943,7 @@ var CsvFormatDefinition = {
|
|
|
2909
2943
|
case 0:
|
|
2910
2944
|
csv = parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
|
|
2911
2945
|
if (csv.errors.length !== 0) {
|
|
2912
|
-
throw new
|
|
2913
|
-
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 "); }));
|
|
2946
|
+
throw new CsvFormatError(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 "); }));
|
|
2914
2947
|
}
|
|
2915
2948
|
return [4 /*yield*/, Promise.all(csv.data.map(function (row, rowIndex) { return __awaiter(_this, void 0, void 0, function () {
|
|
2916
2949
|
var _this = this;
|
|
@@ -3027,7 +3060,7 @@ var TextFormatDefinition = {
|
|
|
3027
3060
|
subvalueDefinitions: [
|
|
3028
3061
|
{
|
|
3029
3062
|
subvalueName: 'LINE',
|
|
3030
|
-
mapValues: function (value, settings, mapCallback) {
|
|
3063
|
+
mapValues: function (value, outputParameterName, settings, mapCallback) {
|
|
3031
3064
|
return __awaiter(this, void 0, void 0, function () {
|
|
3032
3065
|
var lines, mappedLines;
|
|
3033
3066
|
return __generator(this, function (_a) {
|
|
@@ -3595,7 +3628,9 @@ function executeAttempts(options) {
|
|
|
3595
3628
|
title: template.title,
|
|
3596
3629
|
pipelineUrl: "".concat(preparedPipeline.pipelineUrl
|
|
3597
3630
|
? preparedPipeline.pipelineUrl
|
|
3598
|
-
: 'anonymous' /* <- TODO: [๐ง ] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(template.name
|
|
3631
|
+
: 'anonymous' /* <- TODO: [๐ง ] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(template.name
|
|
3632
|
+
// <- TODO: Here should be maybe also subformat index to distinguish between same template with different subformat values
|
|
3633
|
+
),
|
|
3599
3634
|
parameters: parameters,
|
|
3600
3635
|
content: preparedContent,
|
|
3601
3636
|
modelRequirements: modelRequirements,
|
|
@@ -3899,7 +3934,7 @@ function executeAttempts(options) {
|
|
|
3899
3934
|
*
|
|
3900
3935
|
* @private internal utility of `createPipelineExecutor`
|
|
3901
3936
|
*/
|
|
3902
|
-
function
|
|
3937
|
+
function executeFormatSubvalues(options) {
|
|
3903
3938
|
return __awaiter(this, void 0, void 0, function () {
|
|
3904
3939
|
var template, jokerParameterNames, parameters, priority, pipelineIdentification, settings, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
|
|
3905
3940
|
var _this = this;
|
|
@@ -3937,18 +3972,18 @@ function executeFormatCells(options) {
|
|
|
3937
3972
|
}
|
|
3938
3973
|
if (formatDefinition.formatName === 'CSV') {
|
|
3939
3974
|
formatSettings = settings.csvSettings;
|
|
3940
|
-
// <- TODO:
|
|
3975
|
+
// <- TODO: [๐คนโโ๏ธ] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
|
|
3941
3976
|
}
|
|
3942
|
-
return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
3977
|
+
return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, template.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
3943
3978
|
var mappedParameters, allSubparameters, subresultString;
|
|
3944
3979
|
return __generator(this, function (_a) {
|
|
3945
3980
|
switch (_a.label) {
|
|
3946
3981
|
case 0:
|
|
3947
|
-
// TODO:
|
|
3948
|
-
// TODO:
|
|
3982
|
+
// TODO: [๐คนโโ๏ธ][๐ช] Limit to N concurrent executions
|
|
3983
|
+
// TODO: When done [๐] Report progress also for each subvalue here
|
|
3949
3984
|
try {
|
|
3950
3985
|
mappedParameters = mapAvailableToExpectedParameters({
|
|
3951
|
-
expectedParameters: Object.fromEntries(template.foreach.
|
|
3986
|
+
expectedParameters: Object.fromEntries(template.foreach.inputSubparameterNames.map(function (subparameterName) { return [subparameterName, null]; })),
|
|
3952
3987
|
availableParameters: subparameters,
|
|
3953
3988
|
});
|
|
3954
3989
|
}
|
|
@@ -3975,10 +4010,6 @@ function executeFormatCells(options) {
|
|
|
3975
4010
|
});
|
|
3976
4011
|
});
|
|
3977
4012
|
}
|
|
3978
|
-
/**
|
|
3979
|
-
* TODO: !!!!!! Make pipelineIdentification more precise
|
|
3980
|
-
* TODO: !!!!!! How FOREACH execution looks in the report
|
|
3981
|
-
*/
|
|
3982
4013
|
|
|
3983
4014
|
/**
|
|
3984
4015
|
* @@@
|
|
@@ -4172,7 +4203,7 @@ function executeTemplate(options) {
|
|
|
4172
4203
|
preparedContent = (currentTemplate.preparedContent || '{content}')
|
|
4173
4204
|
.split('{content}')
|
|
4174
4205
|
.join(currentTemplate.content);
|
|
4175
|
-
return [4 /*yield*/,
|
|
4206
|
+
return [4 /*yield*/, executeFormatSubvalues({
|
|
4176
4207
|
jokerParameterNames: jokerParameterNames,
|
|
4177
4208
|
priority: priority,
|
|
4178
4209
|
maxAttempts: maxAttempts,
|
|
@@ -4212,6 +4243,9 @@ function executeTemplate(options) {
|
|
|
4212
4243
|
/**
|
|
4213
4244
|
* TODO: [๐คนโโ๏ธ]
|
|
4214
4245
|
*/
|
|
4246
|
+
/**
|
|
4247
|
+
* TODO: [๐] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
|
|
4248
|
+
*/
|
|
4215
4249
|
|
|
4216
4250
|
/**
|
|
4217
4251
|
* @@@
|
|
@@ -4563,6 +4597,9 @@ function executePipeline(options) {
|
|
|
4563
4597
|
});
|
|
4564
4598
|
});
|
|
4565
4599
|
}
|
|
4600
|
+
/**
|
|
4601
|
+
* TODO: [๐] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
|
|
4602
|
+
*/
|
|
4566
4603
|
|
|
4567
4604
|
/**
|
|
4568
4605
|
* Creates executor function from pipeline and execution tools.
|
|
@@ -4620,6 +4657,9 @@ function createPipelineExecutor(options) {
|
|
|
4620
4657
|
}); };
|
|
4621
4658
|
return pipelineExecutor;
|
|
4622
4659
|
}
|
|
4660
|
+
/**
|
|
4661
|
+
* TODO: [๐] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
|
|
4662
|
+
*/
|
|
4623
4663
|
|
|
4624
4664
|
/**
|
|
4625
4665
|
* @@@
|
|
@@ -4671,7 +4711,7 @@ function prepareKnowledgeFromMarkdown(knowledgeContent /* <- TODO: [๐] (?mayb
|
|
|
4671
4711
|
outputParameters = result.outputParameters;
|
|
4672
4712
|
knowledgePiecesRaw = outputParameters.knowledgePieces;
|
|
4673
4713
|
knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
4674
|
-
// <- TODO:[main] !!!!! Smarter split and filter out empty pieces
|
|
4714
|
+
// <- TODO: [main] !!!!! Smarter split and filter out empty pieces
|
|
4675
4715
|
if (isVerbose) {
|
|
4676
4716
|
console.info('knowledgeTextPieces:', knowledgeTextPieces);
|
|
4677
4717
|
}
|
|
@@ -5021,7 +5061,7 @@ function prepareTemplates(pipeline, options) {
|
|
|
5021
5061
|
case 0:
|
|
5022
5062
|
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a;
|
|
5023
5063
|
templates = pipeline.templates, parameters = pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
|
|
5024
|
-
// TODO:[main] !!!!! Apply samples to each template (if missing and is for the template defined)
|
|
5064
|
+
// TODO: [main] !!!!! Apply samples to each template (if missing and is for the template defined)
|
|
5025
5065
|
TODO_USE(parameters);
|
|
5026
5066
|
templatesPrepared = new Array(
|
|
5027
5067
|
// <- TODO: [๐งฑ] Implement in a functional (not new Class) way
|
|
@@ -5225,7 +5265,7 @@ var knowledgeCommandParser = {
|
|
|
5225
5265
|
if (sourceContent === '') {
|
|
5226
5266
|
throw new ParseError("Source is not defined");
|
|
5227
5267
|
}
|
|
5228
|
-
// TODO:[main] !!!! Following checks should be applied every link in the `sourceContent`
|
|
5268
|
+
// TODO: [main] !!!! Following checks should be applied every link in the `sourceContent`
|
|
5229
5269
|
if (sourceContent.startsWith('http://')) {
|
|
5230
5270
|
throw new ParseError("Source is not secure");
|
|
5231
5271
|
}
|
|
@@ -5978,8 +6018,10 @@ var foreachCommandParser = {
|
|
|
5978
6018
|
*/
|
|
5979
6019
|
examples: [
|
|
5980
6020
|
'FOREACH Text Line `{customers}` -> `{customer}`',
|
|
5981
|
-
'
|
|
5982
|
-
'
|
|
6021
|
+
'FOREACH Csv Cell `{customers}` -> `{cell}`',
|
|
6022
|
+
'FOREACH Csv Row `{customers}` -> `{firstName}`, `{lastName}`, `+{email}`',
|
|
6023
|
+
'FOR Text Line `{customers}` -> `{customer}`',
|
|
6024
|
+
'EACH Text Line `{customers}` -> `{customer}`',
|
|
5983
6025
|
],
|
|
5984
6026
|
/**
|
|
5985
6027
|
* Parses the FOREACH command
|
|
@@ -6013,20 +6055,49 @@ var foreachCommandParser = {
|
|
|
6013
6055
|
throw new ParseError("FOREACH command must have '->' to assign the value to the parameter");
|
|
6014
6056
|
}
|
|
6015
6057
|
var parameterName = validateParameterName(parameterNameArg);
|
|
6016
|
-
var
|
|
6058
|
+
var outputSubparameterName = null;
|
|
6059
|
+
// TODO: [4] DRY
|
|
6060
|
+
var inputSubparameterNames = args
|
|
6017
6061
|
.slice(4)
|
|
6018
6062
|
.map(function (parameterName) { return parameterName.split(',').join(' ').trim(); })
|
|
6063
|
+
.filter(function (parameterName) { return !parameterName.includes('+'); })
|
|
6019
6064
|
.filter(function (parameterName) { return parameterName !== ''; })
|
|
6020
6065
|
.map(validateParameterName);
|
|
6021
|
-
|
|
6022
|
-
|
|
6066
|
+
// TODO: [4] DRY
|
|
6067
|
+
var outputSubparameterNames = args
|
|
6068
|
+
.slice(4)
|
|
6069
|
+
.map(function (parameterName) { return parameterName.split(',').join(' ').trim(); })
|
|
6070
|
+
.filter(function (parameterName) { return parameterName.includes('+'); })
|
|
6071
|
+
.map(function (parameterName) { return parameterName.split('+').join(''); })
|
|
6072
|
+
.map(validateParameterName);
|
|
6073
|
+
if (outputSubparameterNames.length === 1) {
|
|
6074
|
+
outputSubparameterName = outputSubparameterNames[0];
|
|
6075
|
+
}
|
|
6076
|
+
else if (outputSubparameterNames.length > 1) {
|
|
6077
|
+
throw new ParseError("FOREACH command can not have more than one output subparameter");
|
|
6078
|
+
}
|
|
6079
|
+
if (inputSubparameterNames.length === 0) {
|
|
6080
|
+
throw new ParseError("FOREACH command must have at least one input subparameter");
|
|
6081
|
+
}
|
|
6082
|
+
if (outputSubparameterName === null) {
|
|
6083
|
+
// TODO: Following code should be unhardcoded from here and moved to the format definition
|
|
6084
|
+
if (formatName === 'CSV' && subformatName === 'CELL') {
|
|
6085
|
+
outputSubparameterName = 'newCell';
|
|
6086
|
+
}
|
|
6087
|
+
else if (formatName === 'TEXT' && subformatName === 'LINE') {
|
|
6088
|
+
outputSubparameterName = 'newLine';
|
|
6089
|
+
}
|
|
6090
|
+
else {
|
|
6091
|
+
throw new ParseError(spaceTrim$1("\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 ")));
|
|
6092
|
+
}
|
|
6023
6093
|
}
|
|
6024
6094
|
return {
|
|
6025
6095
|
type: 'FOREACH',
|
|
6026
6096
|
formatName: formatName,
|
|
6027
6097
|
subformatName: subformatName,
|
|
6028
6098
|
parameterName: parameterName,
|
|
6029
|
-
|
|
6099
|
+
inputSubparameterNames: inputSubparameterNames,
|
|
6100
|
+
outputSubparameterName: outputSubparameterName,
|
|
6030
6101
|
};
|
|
6031
6102
|
},
|
|
6032
6103
|
/**
|
|
@@ -6035,10 +6106,16 @@ var foreachCommandParser = {
|
|
|
6035
6106
|
* Note: `$` is used to indicate that this function mutates given `templateJson`
|
|
6036
6107
|
*/
|
|
6037
6108
|
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
6038
|
-
var formatName = command.formatName, subformatName = command.subformatName, parameterName = command.parameterName,
|
|
6109
|
+
var formatName = command.formatName, subformatName = command.subformatName, parameterName = command.parameterName, inputSubparameterNames = command.inputSubparameterNames, outputSubparameterName = command.outputSubparameterName;
|
|
6039
6110
|
// TODO: [๐ญ] Detect double use
|
|
6040
6111
|
// TODO: [๐ญ] Detect usage with JOKER and don't allow it
|
|
6041
|
-
$templateJson.foreach = {
|
|
6112
|
+
$templateJson.foreach = {
|
|
6113
|
+
formatName: formatName,
|
|
6114
|
+
subformatName: subformatName,
|
|
6115
|
+
parameterName: parameterName,
|
|
6116
|
+
inputSubparameterNames: inputSubparameterNames,
|
|
6117
|
+
outputSubparameterName: outputSubparameterName,
|
|
6118
|
+
};
|
|
6042
6119
|
keepUnused($pipelineJson); // <- TODO: [๐ง ] Maybe register subparameter from foreach into parameters of the pipeline
|
|
6043
6120
|
// Note: [๐ญ] FOREACH apply has some sideeffects on different places in codebase
|
|
6044
6121
|
},
|
|
@@ -7860,7 +7937,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
7860
7937
|
return $asDeeplyFrozenSerializableJson('pipelineJson', $pipelineJson);
|
|
7861
7938
|
}
|
|
7862
7939
|
/**
|
|
7863
|
-
* TODO:[main] !!!! Warn if used only sync version
|
|
7940
|
+
* TODO: [main] !!!! Warn if used only sync version
|
|
7864
7941
|
* TODO: [๐] Report here line/column of error
|
|
7865
7942
|
* TODO: Use spaceTrim more effectively
|
|
7866
7943
|
* TODO: [๐ง ] Parameter flags - isInput, isOutput, isInternal
|
|
@@ -9645,7 +9722,7 @@ var RemoteLlmExecutionTools = /** @class */ (function () {
|
|
|
9645
9722
|
socket.on('connect', function () {
|
|
9646
9723
|
resolve(socket);
|
|
9647
9724
|
});
|
|
9648
|
-
// TODO:[main] !!!! Better timeout handling
|
|
9725
|
+
// TODO: [main] !!!! Better timeout handling
|
|
9649
9726
|
setTimeout(function () {
|
|
9650
9727
|
reject(new Error("Timeout while connecting to ".concat(_this.options.remoteUrl)));
|
|
9651
9728
|
}, CONNECTION_TIMEOUT_MS);
|
|
@@ -9825,7 +9902,7 @@ var ANTHROPIC_CLAUDE_MODELS = $asDeeplyFrozenSerializableJson('ANTHROPIC_CLAUDE_
|
|
|
9825
9902
|
output: computeUsage("$2.40 / 1M tokens"),
|
|
9826
9903
|
},
|
|
9827
9904
|
},
|
|
9828
|
-
// TODO:[main] !!! Claude 1 and 2 has also completion versions - ask Hoagy
|
|
9905
|
+
// TODO: [main] !!! Claude 1 and 2 has also completion versions - ask Hoagy
|
|
9829
9906
|
]);
|
|
9830
9907
|
/**
|
|
9831
9908
|
* Note: [๐ค] Add models of new variant
|
|
@@ -10565,7 +10642,7 @@ var OPENAI_MODELS = $asDeeplyFrozenSerializableJson('OPENAI_MODELS', [
|
|
|
10565
10642
|
prompt: computeUsage("$5.00 / 1M tokens"),
|
|
10566
10643
|
output: computeUsage("$15.00 / 1M tokens"),
|
|
10567
10644
|
},
|
|
10568
|
-
//TODO:[main]
|
|
10645
|
+
//TODO: [main] !!! Add gpt-4o-mini-2024-07-18 and all others to be up to date
|
|
10569
10646
|
},
|
|
10570
10647
|
/**/
|
|
10571
10648
|
/**/
|
|
@@ -10595,7 +10672,7 @@ var OPENAI_MODELS = $asDeeplyFrozenSerializableJson('OPENAI_MODELS', [
|
|
|
10595
10672
|
modelVariant: 'CHAT',
|
|
10596
10673
|
modelTitle: 'o1-preview-2024-09-12',
|
|
10597
10674
|
modelName: 'o1-preview-2024-09-12',
|
|
10598
|
-
// <- TODO:[main]
|
|
10675
|
+
// <- TODO: [main] !!! Some better system to organize theese date suffixes and versions
|
|
10599
10676
|
pricing: {
|
|
10600
10677
|
prompt: computeUsage("$15.00 / 1M tokens"),
|
|
10601
10678
|
output: computeUsage("$60.00 / 1M tokens"),
|
|
@@ -10713,7 +10790,7 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
|
|
|
10713
10790
|
AzureOpenAiExecutionTools.prototype.listModels = function () {
|
|
10714
10791
|
return __awaiter(this, void 0, void 0, function () {
|
|
10715
10792
|
return __generator(this, function (_a) {
|
|
10716
|
-
// TODO:[main] !!! Do here some filtering which models are really available as deployment
|
|
10793
|
+
// TODO: [main] !!! Do here some filtering which models are really available as deployment
|
|
10717
10794
|
// @see https://management.azure.com/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/deployments?api-version=2023-05-01
|
|
10718
10795
|
return [2 /*return*/, OPENAI_MODELS.map(function (_a) {
|
|
10719
10796
|
var modelTitle = _a.modelTitle, modelName = _a.modelName, modelVariant = _a.modelVariant;
|
|
@@ -11527,8 +11604,7 @@ var OpenAiAssistantExecutionTools = /** @class */ (function (_super) {
|
|
|
11527
11604
|
rawPromptContent = replaceParameters(content, __assign(__assign({}, parameters), { modelName: 'assistant' }));
|
|
11528
11605
|
rawRequest = {
|
|
11529
11606
|
// [๐จโ๐จโ๐งโ๐ง] ...modelSettings,
|
|
11530
|
-
assistant_id:
|
|
11531
|
-
// <- Note: This is not a private information, just ID of the assistant which is accessible only with correct API key
|
|
11607
|
+
assistant_id: this.assistantId,
|
|
11532
11608
|
thread: {
|
|
11533
11609
|
messages: [
|
|
11534
11610
|
// TODO: !!!!!! Unhardcode
|
|
@@ -11542,6 +11618,7 @@ var OpenAiAssistantExecutionTools = /** @class */ (function (_super) {
|
|
|
11542
11618
|
if (this.options.isVerbose) {
|
|
11543
11619
|
console.info(colors.bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
|
11544
11620
|
}
|
|
11621
|
+
console.log('!!!!!! OpenAI client', client);
|
|
11545
11622
|
return [4 /*yield*/, client.beta.threads.createAndRunStream(rawRequest)];
|
|
11546
11623
|
case 2:
|
|
11547
11624
|
stream = _g.sent();
|