@promptbook/cli 0.67.6 → 0.67.8
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/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
/**
|
|
40
40
|
* The version of the Promptbook library
|
|
41
41
|
*/
|
|
42
|
-
var PROMPTBOOK_VERSION = '0.67.
|
|
42
|
+
var PROMPTBOOK_VERSION = '0.67.7';
|
|
43
43
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
44
44
|
|
|
45
45
|
/*! *****************************************************************************
|
|
@@ -1053,7 +1053,7 @@
|
|
|
1053
1053
|
});
|
|
1054
1054
|
}
|
|
1055
1055
|
|
|
1056
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.67.
|
|
1056
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.67.7",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT"},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}",dependentParameterNames:["knowledgeContent"],resultingParameterName:"knowledgePieces"}],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.67.7",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT"},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}",dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"keywords"}],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.67.7",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT"},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}",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"title"}],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.67.7",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}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",modelRequirements:{modelVariant:"CHAT"},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}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
|
|
1057
1057
|
|
|
1058
1058
|
/**
|
|
1059
1059
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -3222,7 +3222,7 @@
|
|
|
3222
3222
|
}
|
|
3223
3223
|
function executeSingleTemplate(currentTemplate) {
|
|
3224
3224
|
return __awaiter(this, void 0, void 0, function () {
|
|
3225
|
-
var name, title, priority, usedParameterNames, dependentParameterNames, definedParameters, _a, _b, _c, definedParameterNames, parameters, _loop_4, _d, _e, parameterName, prompt, chatResult, completionResult, embeddingResult, result, resultString, expectError, scriptPipelineExecutionErrors, maxAttempts, jokerParameterNames, preparedContent, _loop_5, attempt, state_2;
|
|
3225
|
+
var name, title, priority, progress_1, usedParameterNames, dependentParameterNames, definedParameters, _a, _b, _c, definedParameterNames, parameters, _loop_4, _d, _e, parameterName, prompt, chatResult, completionResult, embeddingResult, result, resultString, expectError, scriptPipelineExecutionErrors, maxAttempts, jokerParameterNames, preparedContent, _loop_5, attempt, state_2, progress_2;
|
|
3226
3226
|
var e_4, _f, _g;
|
|
3227
3227
|
return __generator(this, function (_h) {
|
|
3228
3228
|
switch (_h.label) {
|
|
@@ -3231,16 +3231,23 @@
|
|
|
3231
3231
|
title = currentTemplate.title;
|
|
3232
3232
|
priority = preparedPipeline.promptTemplates.length - preparedPipeline.promptTemplates.indexOf(currentTemplate);
|
|
3233
3233
|
if (!onProgress /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3234
|
+
progress_1 = {
|
|
3235
|
+
name: name,
|
|
3236
|
+
title: title,
|
|
3237
|
+
isStarted: false,
|
|
3238
|
+
isDone: false,
|
|
3239
|
+
blockType: currentTemplate.blockType,
|
|
3240
|
+
parameterName: currentTemplate.resultingParameterName,
|
|
3241
|
+
parameterValue: null,
|
|
3242
|
+
// <- [3]
|
|
3243
|
+
};
|
|
3244
|
+
if (isReturned) {
|
|
3245
|
+
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished \uD83C\uDF4F\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(progress_1, null, 4)
|
|
3246
|
+
.split('\n')
|
|
3247
|
+
.map(function (line) { return "> ".concat(line); })
|
|
3248
|
+
.join('\n')), "\n "); }));
|
|
3249
|
+
}
|
|
3250
|
+
return [4 /*yield*/, onProgress(progress_1)];
|
|
3244
3251
|
case 1:
|
|
3245
3252
|
_h.sent();
|
|
3246
3253
|
_h.label = 2;
|
|
@@ -3626,18 +3633,28 @@
|
|
|
3626
3633
|
if (resultString === null) {
|
|
3627
3634
|
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
3628
3635
|
}
|
|
3629
|
-
if (onProgress /* <- [3] */)
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3636
|
+
if (!onProgress /* <- [3] */) return [3 /*break*/, 9]; /* <- [3] */
|
|
3637
|
+
progress_2 = {
|
|
3638
|
+
name: name,
|
|
3639
|
+
title: title,
|
|
3640
|
+
isStarted: true,
|
|
3641
|
+
isDone: true,
|
|
3642
|
+
blockType: currentTemplate.blockType,
|
|
3643
|
+
parameterName: currentTemplate.resultingParameterName,
|
|
3644
|
+
parameterValue: resultString,
|
|
3645
|
+
// <- [3]
|
|
3646
|
+
};
|
|
3647
|
+
if (isReturned) {
|
|
3648
|
+
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished \uD83C\uDF4E\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(progress_2, null, 4)
|
|
3649
|
+
.split('\n')
|
|
3650
|
+
.map(function (line) { return "> ".concat(line); })
|
|
3651
|
+
.join('\n')), "\n\n "); }));
|
|
3640
3652
|
}
|
|
3653
|
+
return [4 /*yield*/, onProgress(progress_2)];
|
|
3654
|
+
case 8:
|
|
3655
|
+
_h.sent();
|
|
3656
|
+
_h.label = 9;
|
|
3657
|
+
case 9:
|
|
3641
3658
|
parametersToPass = Object.freeze(__assign(__assign({}, parametersToPass), (_g = {}, _g[currentTemplate.resultingParameterName] = resultString /* <- Note: Not need to detect parameter collision here because pipeline checks logic consistency during construction */, _g)));
|
|
3642
3659
|
return [2 /*return*/];
|
|
3643
3660
|
}
|
|
@@ -3674,7 +3691,7 @@
|
|
|
3674
3691
|
}
|
|
3675
3692
|
return outputParameters;
|
|
3676
3693
|
}
|
|
3677
|
-
var errors, warnings, executionReport, _a, _b, parameter, _loop_1, _c, _d, parameterName, state_1, parametersToPass, resovedParameterNames_1, unresovedTemplates_1, resolving_1, loopLimit, _loop_2, error_1, usage_1, outputParameters_1, usage, outputParameters;
|
|
3694
|
+
var errors, warnings, executionReport, isReturned, _a, _b, parameter, _loop_1, _c, _d, parameterName, state_1, parametersToPass, resovedParameterNames_1, unresovedTemplates_1, resolving_1, loopLimit, _loop_2, error_1, usage_1, outputParameters_1, usage, outputParameters;
|
|
3678
3695
|
var e_1, _e, e_2, _f;
|
|
3679
3696
|
return __generator(this, function (_g) {
|
|
3680
3697
|
switch (_g.label) {
|
|
@@ -3699,6 +3716,7 @@
|
|
|
3699
3716
|
description: preparedPipeline.description,
|
|
3700
3717
|
promptExecutions: [],
|
|
3701
3718
|
};
|
|
3719
|
+
isReturned = false;
|
|
3702
3720
|
try {
|
|
3703
3721
|
// Note: Check that all input input parameters are defined
|
|
3704
3722
|
for (_a = __values(preparedPipeline.parameters.filter(function (_a) {
|
|
@@ -3707,6 +3725,7 @@
|
|
|
3707
3725
|
})), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
3708
3726
|
parameter = _b.value;
|
|
3709
3727
|
if (inputParameters[parameter.name] === undefined) {
|
|
3728
|
+
isReturned = true;
|
|
3710
3729
|
return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
|
|
3711
3730
|
isSuccessful: false,
|
|
3712
3731
|
errors: __spreadArray([
|
|
@@ -3737,6 +3756,7 @@
|
|
|
3737
3756
|
warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Extra parameter {".concat(parameterName, "} is being passed which is not part of the pipeline.\n\n ").concat(block(pipelineIdentification), "\n "); })));
|
|
3738
3757
|
}
|
|
3739
3758
|
else if (parameter.isInput === false) {
|
|
3759
|
+
isReturned = true;
|
|
3740
3760
|
return { value: $asDeeplyFrozenSerializableJson(spaceTrim.spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
|
|
3741
3761
|
isSuccessful: false,
|
|
3742
3762
|
errors: __spreadArray([
|
|
@@ -3849,6 +3869,7 @@
|
|
|
3849
3869
|
return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
|
|
3850
3870
|
})), false));
|
|
3851
3871
|
outputParameters_1 = filterJustOutputParameters();
|
|
3872
|
+
isReturned = true;
|
|
3852
3873
|
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult', {
|
|
3853
3874
|
isSuccessful: false,
|
|
3854
3875
|
errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
|
|
@@ -3864,6 +3885,7 @@
|
|
|
3864
3885
|
return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
|
|
3865
3886
|
})), false));
|
|
3866
3887
|
outputParameters = filterJustOutputParameters();
|
|
3888
|
+
isReturned = true;
|
|
3867
3889
|
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Successful PipelineExecutorResult', {
|
|
3868
3890
|
isSuccessful: true,
|
|
3869
3891
|
errors: errors.map(serializeError),
|
|
@@ -5929,7 +5951,7 @@
|
|
|
5929
5951
|
personas: [],
|
|
5930
5952
|
preparations: [],
|
|
5931
5953
|
};
|
|
5932
|
-
|
|
5954
|
+
function getPipelineIdentification() {
|
|
5933
5955
|
// Note: This is a 😐 implementation of [🚞]
|
|
5934
5956
|
var _ = [];
|
|
5935
5957
|
if (pipelineJson.sourceFile !== undefined) {
|
|
@@ -5939,7 +5961,7 @@
|
|
|
5939
5961
|
_.push("Url: ".concat(pipelineJson.pipelineUrl));
|
|
5940
5962
|
}
|
|
5941
5963
|
return _.join('\n');
|
|
5942
|
-
}
|
|
5964
|
+
}
|
|
5943
5965
|
// =============================================================
|
|
5944
5966
|
// Note: 1️⃣ Parsing of the markdown into object
|
|
5945
5967
|
pipelineString = removeContentComments(pipelineString);
|
|
@@ -5948,27 +5970,27 @@
|
|
|
5948
5970
|
pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
5949
5971
|
var _c = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _c[0], pipelineSections = _c.slice(1); /* <- Note: [🥞] */
|
|
5950
5972
|
if (pipelineHead === undefined) {
|
|
5951
|
-
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(
|
|
5973
|
+
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
5952
5974
|
}
|
|
5953
5975
|
if (pipelineHead.level !== 1) {
|
|
5954
|
-
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Pipeline head is not h1\n\n ".concat(block(
|
|
5976
|
+
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Pipeline head is not h1\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
5955
5977
|
}
|
|
5956
5978
|
if (!pipelineSections.every(function (section) { return section.level === 2; })) {
|
|
5957
|
-
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Not every pipeline section is h2\n\n ".concat(block(
|
|
5979
|
+
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Not every pipeline section is h2\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
5958
5980
|
}
|
|
5959
5981
|
// =============================================================
|
|
5960
5982
|
///Note: 2️⃣ Function for defining parameters
|
|
5961
5983
|
var defineParam = function (parameterCommand) {
|
|
5962
5984
|
var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
|
|
5963
5985
|
if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
|
|
5964
|
-
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Parameter name {".concat(parameterName, "} is reserved and cannot be used as resulting parameter name\n\n ").concat(block(
|
|
5986
|
+
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Parameter name {".concat(parameterName, "} is reserved and cannot be used as resulting parameter name\n\n ").concat(block(getPipelineIdentification()), "\n "); }) /* <- TODO: [🚞] */);
|
|
5965
5987
|
}
|
|
5966
5988
|
var existingParameter = pipelineJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
|
|
5967
5989
|
if (existingParameter &&
|
|
5968
5990
|
existingParameter.description &&
|
|
5969
5991
|
existingParameter.description !== parameterDescription &&
|
|
5970
5992
|
parameterDescription) {
|
|
5971
|
-
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description:\n\n ").concat(block(
|
|
5993
|
+
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description:\n\n ").concat(block(getPipelineIdentification()), "\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
|
|
5972
5994
|
}
|
|
5973
5995
|
if (existingParameter) {
|
|
5974
5996
|
if (parameterDescription) {
|
|
@@ -6031,10 +6053,10 @@
|
|
|
6031
6053
|
// <- Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
6032
6054
|
break;
|
|
6033
6055
|
case 'BOILERPLATE':
|
|
6034
|
-
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file\n\n ".concat(block(
|
|
6056
|
+
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file\n\n ".concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
|
|
6035
6057
|
// <- [💐]
|
|
6036
6058
|
default:
|
|
6037
|
-
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the pipeline template\n\n ").concat(block(
|
|
6059
|
+
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the pipeline template\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
|
|
6038
6060
|
}
|
|
6039
6061
|
};
|
|
6040
6062
|
try {
|
|
@@ -6067,7 +6089,7 @@
|
|
|
6067
6089
|
if (resultingParameterName !== null) {
|
|
6068
6090
|
return resultingParameterName;
|
|
6069
6091
|
}
|
|
6070
|
-
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Template section must end with -> {parameterName}\n\n ".concat(block(
|
|
6092
|
+
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Template section must end with -> {parameterName}\n\n ".concat(block(getPipelineIdentification()), "\n\n Invalid section:\n ").concat(block(
|
|
6071
6093
|
// TODO: Show code of invalid sections each time + DRY
|
|
6072
6094
|
section.content
|
|
6073
6095
|
.split('\n')
|
|
@@ -6110,13 +6132,13 @@
|
|
|
6110
6132
|
// TODO: [🍧] Use here applyToPipelineJson and remove switch statement
|
|
6111
6133
|
case 'BLOCK':
|
|
6112
6134
|
if (isBlockTypeSet) {
|
|
6113
|
-
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Block type is already defined in the prompt template. It can be defined only once.\n\n ".concat(block(
|
|
6135
|
+
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Block type is already defined in the prompt template. It can be defined only once.\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
|
|
6114
6136
|
}
|
|
6115
6137
|
if (command.blockType === 'SAMPLE') {
|
|
6116
6138
|
expectResultingParameterName();
|
|
6117
6139
|
var parameter = pipelineJson.parameters.find(function (param) { return param.name === resultingParameterName; });
|
|
6118
6140
|
if (parameter === undefined) {
|
|
6119
|
-
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Can not find parameter {".concat(resultingParameterName, "} to assign sample value\n\n ").concat(block(
|
|
6141
|
+
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Can not find parameter {".concat(resultingParameterName, "} to assign sample value\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
6120
6142
|
}
|
|
6121
6143
|
parameter.sampleValues = parameter.sampleValues || [];
|
|
6122
6144
|
parameter.sampleValues.push(content);
|
|
@@ -6151,20 +6173,20 @@
|
|
|
6151
6173
|
templateJson.expectations[unit_1] = templateJson.expectations[unit_1] || {};
|
|
6152
6174
|
if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
|
|
6153
6175
|
if (templateJson.expectations[unit_1].min !== undefined) {
|
|
6154
|
-
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Already defined minumum ".concat(templateJson.expectations[unit_1].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount, "\n\n ").concat(block(
|
|
6176
|
+
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Already defined minumum ".concat(templateJson.expectations[unit_1].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount, "\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
6155
6177
|
}
|
|
6156
6178
|
templateJson.expectations[unit_1].min = command.amount;
|
|
6157
6179
|
} /* not else */
|
|
6158
6180
|
if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
|
|
6159
6181
|
if (templateJson.expectations[unit_1].max !== undefined) {
|
|
6160
|
-
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Already defined maximum ".concat(templateJson.expectations[unit_1].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount, "\n\n ").concat(block(
|
|
6182
|
+
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Already defined maximum ".concat(templateJson.expectations[unit_1].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount, "\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
6161
6183
|
}
|
|
6162
6184
|
templateJson.expectations[unit_1].max = command.amount;
|
|
6163
6185
|
}
|
|
6164
6186
|
break;
|
|
6165
6187
|
case 'EXPECT_FORMAT':
|
|
6166
6188
|
if (templateJson.expectFormat !== undefined && command.format !== templateJson.expectFormat) {
|
|
6167
|
-
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Expect format is already defined to \"".concat(templateJson.expectFormat, "\".\n Now you try to redefine it by \"").concat(command.format, "\".\n\n ").concat(block(
|
|
6189
|
+
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Expect format is already defined to \"".concat(templateJson.expectFormat, "\".\n Now you try to redefine it by \"").concat(command.format, "\".\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
6168
6190
|
}
|
|
6169
6191
|
templateJson.expectFormat = command.format;
|
|
6170
6192
|
break;
|
|
@@ -6200,11 +6222,11 @@
|
|
|
6200
6222
|
// <- Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
6201
6223
|
break;
|
|
6202
6224
|
case 'BOILERPLATE':
|
|
6203
|
-
console.error(new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file\n\n ".concat(block(
|
|
6225
|
+
console.error(new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file\n\n ".concat(block(getPipelineIdentification()), "\n "); })));
|
|
6204
6226
|
break;
|
|
6205
6227
|
// <- [💐]
|
|
6206
6228
|
default:
|
|
6207
|
-
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the pipeline\n\n ").concat(block(
|
|
6229
|
+
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the pipeline\n\n ").concat(block(getPipelineIdentification()), "\n\n "); }));
|
|
6208
6230
|
}
|
|
6209
6231
|
};
|
|
6210
6232
|
try {
|
|
@@ -6226,7 +6248,7 @@
|
|
|
6226
6248
|
// TODO: [🍧] Should be done in BLOCK command
|
|
6227
6249
|
if (templateJson.blockType === 'SCRIPT') {
|
|
6228
6250
|
if (!language) {
|
|
6229
|
-
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n You must specify the language of the script in the prompt template\n\n ".concat(block(
|
|
6251
|
+
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n You must specify the language of the script in the prompt template\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
|
|
6230
6252
|
}
|
|
6231
6253
|
if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
|
|
6232
6254
|
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Script language ".concat(language, " is not supported.\n\n Supported languages are:\n ").concat(block(SUPPORTED_SCRIPT_LANGUAGES.join(', ')), "\n\n "); }));
|