@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/esm/index.es.js
CHANGED
|
@@ -20,7 +20,7 @@ import OpenAI from 'openai';
|
|
|
20
20
|
/**
|
|
21
21
|
* The version of the Promptbook library
|
|
22
22
|
*/
|
|
23
|
-
var PROMPTBOOK_VERSION = '0.67.
|
|
23
|
+
var PROMPTBOOK_VERSION = '0.67.7';
|
|
24
24
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
25
25
|
|
|
26
26
|
/*! *****************************************************************************
|
|
@@ -1034,7 +1034,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
1034
1034
|
});
|
|
1035
1035
|
}
|
|
1036
1036
|
|
|
1037
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.67.
|
|
1037
|
+
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"}];
|
|
1038
1038
|
|
|
1039
1039
|
/**
|
|
1040
1040
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -3203,7 +3203,7 @@ function createPipelineExecutor(options) {
|
|
|
3203
3203
|
}
|
|
3204
3204
|
function executeSingleTemplate(currentTemplate) {
|
|
3205
3205
|
return __awaiter(this, void 0, void 0, function () {
|
|
3206
|
-
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;
|
|
3206
|
+
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;
|
|
3207
3207
|
var e_4, _f, _g;
|
|
3208
3208
|
return __generator(this, function (_h) {
|
|
3209
3209
|
switch (_h.label) {
|
|
@@ -3212,16 +3212,23 @@ function createPipelineExecutor(options) {
|
|
|
3212
3212
|
title = currentTemplate.title;
|
|
3213
3213
|
priority = preparedPipeline.promptTemplates.length - preparedPipeline.promptTemplates.indexOf(currentTemplate);
|
|
3214
3214
|
if (!onProgress /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3215
|
+
progress_1 = {
|
|
3216
|
+
name: name,
|
|
3217
|
+
title: title,
|
|
3218
|
+
isStarted: false,
|
|
3219
|
+
isDone: false,
|
|
3220
|
+
blockType: currentTemplate.blockType,
|
|
3221
|
+
parameterName: currentTemplate.resultingParameterName,
|
|
3222
|
+
parameterValue: null,
|
|
3223
|
+
// <- [3]
|
|
3224
|
+
};
|
|
3225
|
+
if (isReturned) {
|
|
3226
|
+
throw new UnexpectedError(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)
|
|
3227
|
+
.split('\n')
|
|
3228
|
+
.map(function (line) { return "> ".concat(line); })
|
|
3229
|
+
.join('\n')), "\n "); }));
|
|
3230
|
+
}
|
|
3231
|
+
return [4 /*yield*/, onProgress(progress_1)];
|
|
3225
3232
|
case 1:
|
|
3226
3233
|
_h.sent();
|
|
3227
3234
|
_h.label = 2;
|
|
@@ -3607,18 +3614,28 @@ function createPipelineExecutor(options) {
|
|
|
3607
3614
|
if (resultString === null) {
|
|
3608
3615
|
throw new UnexpectedError(spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
3609
3616
|
}
|
|
3610
|
-
if (onProgress /* <- [3] */)
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3617
|
+
if (!onProgress /* <- [3] */) return [3 /*break*/, 9]; /* <- [3] */
|
|
3618
|
+
progress_2 = {
|
|
3619
|
+
name: name,
|
|
3620
|
+
title: title,
|
|
3621
|
+
isStarted: true,
|
|
3622
|
+
isDone: true,
|
|
3623
|
+
blockType: currentTemplate.blockType,
|
|
3624
|
+
parameterName: currentTemplate.resultingParameterName,
|
|
3625
|
+
parameterValue: resultString,
|
|
3626
|
+
// <- [3]
|
|
3627
|
+
};
|
|
3628
|
+
if (isReturned) {
|
|
3629
|
+
throw new UnexpectedError(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)
|
|
3630
|
+
.split('\n')
|
|
3631
|
+
.map(function (line) { return "> ".concat(line); })
|
|
3632
|
+
.join('\n')), "\n\n "); }));
|
|
3621
3633
|
}
|
|
3634
|
+
return [4 /*yield*/, onProgress(progress_2)];
|
|
3635
|
+
case 8:
|
|
3636
|
+
_h.sent();
|
|
3637
|
+
_h.label = 9;
|
|
3638
|
+
case 9:
|
|
3622
3639
|
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)));
|
|
3623
3640
|
return [2 /*return*/];
|
|
3624
3641
|
}
|
|
@@ -3655,7 +3672,7 @@ function createPipelineExecutor(options) {
|
|
|
3655
3672
|
}
|
|
3656
3673
|
return outputParameters;
|
|
3657
3674
|
}
|
|
3658
|
-
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;
|
|
3675
|
+
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;
|
|
3659
3676
|
var e_1, _e, e_2, _f;
|
|
3660
3677
|
return __generator(this, function (_g) {
|
|
3661
3678
|
switch (_g.label) {
|
|
@@ -3680,6 +3697,7 @@ function createPipelineExecutor(options) {
|
|
|
3680
3697
|
description: preparedPipeline.description,
|
|
3681
3698
|
promptExecutions: [],
|
|
3682
3699
|
};
|
|
3700
|
+
isReturned = false;
|
|
3683
3701
|
try {
|
|
3684
3702
|
// Note: Check that all input input parameters are defined
|
|
3685
3703
|
for (_a = __values(preparedPipeline.parameters.filter(function (_a) {
|
|
@@ -3688,6 +3706,7 @@ function createPipelineExecutor(options) {
|
|
|
3688
3706
|
})), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
3689
3707
|
parameter = _b.value;
|
|
3690
3708
|
if (inputParameters[parameter.name] === undefined) {
|
|
3709
|
+
isReturned = true;
|
|
3691
3710
|
return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
|
|
3692
3711
|
isSuccessful: false,
|
|
3693
3712
|
errors: __spreadArray([
|
|
@@ -3718,6 +3737,7 @@ function createPipelineExecutor(options) {
|
|
|
3718
3737
|
warnings.push(new PipelineExecutionError(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 "); })));
|
|
3719
3738
|
}
|
|
3720
3739
|
else if (parameter.isInput === false) {
|
|
3740
|
+
isReturned = true;
|
|
3721
3741
|
return { value: $asDeeplyFrozenSerializableJson(spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
|
|
3722
3742
|
isSuccessful: false,
|
|
3723
3743
|
errors: __spreadArray([
|
|
@@ -3830,6 +3850,7 @@ function createPipelineExecutor(options) {
|
|
|
3830
3850
|
return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
|
|
3831
3851
|
})), false));
|
|
3832
3852
|
outputParameters_1 = filterJustOutputParameters();
|
|
3853
|
+
isReturned = true;
|
|
3833
3854
|
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult', {
|
|
3834
3855
|
isSuccessful: false,
|
|
3835
3856
|
errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
|
|
@@ -3845,6 +3866,7 @@ function createPipelineExecutor(options) {
|
|
|
3845
3866
|
return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
|
|
3846
3867
|
})), false));
|
|
3847
3868
|
outputParameters = filterJustOutputParameters();
|
|
3869
|
+
isReturned = true;
|
|
3848
3870
|
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Successful PipelineExecutorResult', {
|
|
3849
3871
|
isSuccessful: true,
|
|
3850
3872
|
errors: errors.map(serializeError),
|
|
@@ -5910,7 +5932,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
5910
5932
|
personas: [],
|
|
5911
5933
|
preparations: [],
|
|
5912
5934
|
};
|
|
5913
|
-
|
|
5935
|
+
function getPipelineIdentification() {
|
|
5914
5936
|
// Note: This is a 😐 implementation of [🚞]
|
|
5915
5937
|
var _ = [];
|
|
5916
5938
|
if (pipelineJson.sourceFile !== undefined) {
|
|
@@ -5920,7 +5942,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
5920
5942
|
_.push("Url: ".concat(pipelineJson.pipelineUrl));
|
|
5921
5943
|
}
|
|
5922
5944
|
return _.join('\n');
|
|
5923
|
-
}
|
|
5945
|
+
}
|
|
5924
5946
|
// =============================================================
|
|
5925
5947
|
// Note: 1️⃣ Parsing of the markdown into object
|
|
5926
5948
|
pipelineString = removeContentComments(pipelineString);
|
|
@@ -5929,27 +5951,27 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
5929
5951
|
pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
5930
5952
|
var _c = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _c[0], pipelineSections = _c.slice(1); /* <- Note: [🥞] */
|
|
5931
5953
|
if (pipelineHead === undefined) {
|
|
5932
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(
|
|
5954
|
+
throw new UnexpectedError(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 "); }));
|
|
5933
5955
|
}
|
|
5934
5956
|
if (pipelineHead.level !== 1) {
|
|
5935
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n Pipeline head is not h1\n\n ".concat(block(
|
|
5957
|
+
throw new UnexpectedError(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 "); }));
|
|
5936
5958
|
}
|
|
5937
5959
|
if (!pipelineSections.every(function (section) { return section.level === 2; })) {
|
|
5938
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n Not every pipeline section is h2\n\n ".concat(block(
|
|
5960
|
+
throw new UnexpectedError(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 "); }));
|
|
5939
5961
|
}
|
|
5940
5962
|
// =============================================================
|
|
5941
5963
|
///Note: 2️⃣ Function for defining parameters
|
|
5942
5964
|
var defineParam = function (parameterCommand) {
|
|
5943
5965
|
var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
|
|
5944
5966
|
if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
|
|
5945
|
-
throw new ParsingError(spaceTrim(function (block) { return "\n Parameter name {".concat(parameterName, "} is reserved and cannot be used as resulting parameter name\n\n ").concat(block(
|
|
5967
|
+
throw new ParsingError(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: [🚞] */);
|
|
5946
5968
|
}
|
|
5947
5969
|
var existingParameter = pipelineJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
|
|
5948
5970
|
if (existingParameter &&
|
|
5949
5971
|
existingParameter.description &&
|
|
5950
5972
|
existingParameter.description !== parameterDescription &&
|
|
5951
5973
|
parameterDescription) {
|
|
5952
|
-
throw new ParsingError(spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description:\n\n ").concat(block(
|
|
5974
|
+
throw new ParsingError(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 "); }));
|
|
5953
5975
|
}
|
|
5954
5976
|
if (existingParameter) {
|
|
5955
5977
|
if (parameterDescription) {
|
|
@@ -6012,10 +6034,10 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6012
6034
|
// <- Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
6013
6035
|
break;
|
|
6014
6036
|
case 'BOILERPLATE':
|
|
6015
|
-
throw new ParsingError(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(
|
|
6037
|
+
throw new ParsingError(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: [🚞]
|
|
6016
6038
|
// <- [💐]
|
|
6017
6039
|
default:
|
|
6018
|
-
throw new ParsingError(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(
|
|
6040
|
+
throw new ParsingError(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: [🚞]
|
|
6019
6041
|
}
|
|
6020
6042
|
};
|
|
6021
6043
|
try {
|
|
@@ -6048,7 +6070,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6048
6070
|
if (resultingParameterName !== null) {
|
|
6049
6071
|
return resultingParameterName;
|
|
6050
6072
|
}
|
|
6051
|
-
throw new ParsingError(spaceTrim(function (block) { return "\n Template section must end with -> {parameterName}\n\n ".concat(block(
|
|
6073
|
+
throw new ParsingError(spaceTrim(function (block) { return "\n Template section must end with -> {parameterName}\n\n ".concat(block(getPipelineIdentification()), "\n\n Invalid section:\n ").concat(block(
|
|
6052
6074
|
// TODO: Show code of invalid sections each time + DRY
|
|
6053
6075
|
section.content
|
|
6054
6076
|
.split('\n')
|
|
@@ -6091,13 +6113,13 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6091
6113
|
// TODO: [🍧] Use here applyToPipelineJson and remove switch statement
|
|
6092
6114
|
case 'BLOCK':
|
|
6093
6115
|
if (isBlockTypeSet) {
|
|
6094
|
-
throw new ParsingError(spaceTrim(function (block) { return "\n Block type is already defined in the prompt template. It can be defined only once.\n\n ".concat(block(
|
|
6116
|
+
throw new ParsingError(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 "); }));
|
|
6095
6117
|
}
|
|
6096
6118
|
if (command.blockType === 'SAMPLE') {
|
|
6097
6119
|
expectResultingParameterName();
|
|
6098
6120
|
var parameter = pipelineJson.parameters.find(function (param) { return param.name === resultingParameterName; });
|
|
6099
6121
|
if (parameter === undefined) {
|
|
6100
|
-
throw new ParsingError(spaceTrim(function (block) { return "\n Can not find parameter {".concat(resultingParameterName, "} to assign sample value\n\n ").concat(block(
|
|
6122
|
+
throw new ParsingError(spaceTrim(function (block) { return "\n Can not find parameter {".concat(resultingParameterName, "} to assign sample value\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
6101
6123
|
}
|
|
6102
6124
|
parameter.sampleValues = parameter.sampleValues || [];
|
|
6103
6125
|
parameter.sampleValues.push(content);
|
|
@@ -6132,20 +6154,20 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6132
6154
|
templateJson.expectations[unit_1] = templateJson.expectations[unit_1] || {};
|
|
6133
6155
|
if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
|
|
6134
6156
|
if (templateJson.expectations[unit_1].min !== undefined) {
|
|
6135
|
-
throw new ParsingError(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(
|
|
6157
|
+
throw new ParsingError(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 "); }));
|
|
6136
6158
|
}
|
|
6137
6159
|
templateJson.expectations[unit_1].min = command.amount;
|
|
6138
6160
|
} /* not else */
|
|
6139
6161
|
if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
|
|
6140
6162
|
if (templateJson.expectations[unit_1].max !== undefined) {
|
|
6141
|
-
throw new ParsingError(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(
|
|
6163
|
+
throw new ParsingError(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 "); }));
|
|
6142
6164
|
}
|
|
6143
6165
|
templateJson.expectations[unit_1].max = command.amount;
|
|
6144
6166
|
}
|
|
6145
6167
|
break;
|
|
6146
6168
|
case 'EXPECT_FORMAT':
|
|
6147
6169
|
if (templateJson.expectFormat !== undefined && command.format !== templateJson.expectFormat) {
|
|
6148
|
-
throw new ParsingError(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(
|
|
6170
|
+
throw new ParsingError(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 "); }));
|
|
6149
6171
|
}
|
|
6150
6172
|
templateJson.expectFormat = command.format;
|
|
6151
6173
|
break;
|
|
@@ -6181,11 +6203,11 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6181
6203
|
// <- Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
6182
6204
|
break;
|
|
6183
6205
|
case 'BOILERPLATE':
|
|
6184
|
-
console.error(new ParsingError(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(
|
|
6206
|
+
console.error(new ParsingError(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 "); })));
|
|
6185
6207
|
break;
|
|
6186
6208
|
// <- [💐]
|
|
6187
6209
|
default:
|
|
6188
|
-
throw new ParsingError(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(
|
|
6210
|
+
throw new ParsingError(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 "); }));
|
|
6189
6211
|
}
|
|
6190
6212
|
};
|
|
6191
6213
|
try {
|
|
@@ -6207,7 +6229,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6207
6229
|
// TODO: [🍧] Should be done in BLOCK command
|
|
6208
6230
|
if (templateJson.blockType === 'SCRIPT') {
|
|
6209
6231
|
if (!language) {
|
|
6210
|
-
throw new ParsingError(spaceTrim(function (block) { return "\n You must specify the language of the script in the prompt template\n\n ".concat(block(
|
|
6232
|
+
throw new ParsingError(spaceTrim(function (block) { return "\n You must specify the language of the script in the prompt template\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
|
|
6211
6233
|
}
|
|
6212
6234
|
if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
|
|
6213
6235
|
throw new ParsingError(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 "); }));
|