@promptbook/node 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/node",
|
|
3
|
-
"version": "0.67.
|
|
3
|
+
"version": "0.67.8",
|
|
4
4
|
"description": "Supercharge your use of large language models",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"module": "./esm/index.es.js",
|
|
48
48
|
"typings": "./esm/typings/src/_packages/node.index.d.ts",
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@promptbook/core": "0.67.
|
|
50
|
+
"@promptbook/core": "0.67.8"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
/**
|
|
36
36
|
* The version of the Promptbook library
|
|
37
37
|
*/
|
|
38
|
-
var PROMPTBOOK_VERSION = '0.67.
|
|
38
|
+
var PROMPTBOOK_VERSION = '0.67.7';
|
|
39
39
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
40
40
|
|
|
41
41
|
/*! *****************************************************************************
|
|
@@ -889,7 +889,7 @@
|
|
|
889
889
|
});
|
|
890
890
|
}
|
|
891
891
|
|
|
892
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.67.
|
|
892
|
+
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"}];
|
|
893
893
|
|
|
894
894
|
/**
|
|
895
895
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -3074,7 +3074,7 @@
|
|
|
3074
3074
|
}
|
|
3075
3075
|
function executeSingleTemplate(currentTemplate) {
|
|
3076
3076
|
return __awaiter(this, void 0, void 0, function () {
|
|
3077
|
-
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;
|
|
3077
|
+
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;
|
|
3078
3078
|
var e_4, _f, _g;
|
|
3079
3079
|
return __generator(this, function (_h) {
|
|
3080
3080
|
switch (_h.label) {
|
|
@@ -3083,16 +3083,23 @@
|
|
|
3083
3083
|
title = currentTemplate.title;
|
|
3084
3084
|
priority = preparedPipeline.promptTemplates.length - preparedPipeline.promptTemplates.indexOf(currentTemplate);
|
|
3085
3085
|
if (!onProgress /* <- [3] */) return [3 /*break*/, 2]; /* <- [3] */
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3086
|
+
progress_1 = {
|
|
3087
|
+
name: name,
|
|
3088
|
+
title: title,
|
|
3089
|
+
isStarted: false,
|
|
3090
|
+
isDone: false,
|
|
3091
|
+
blockType: currentTemplate.blockType,
|
|
3092
|
+
parameterName: currentTemplate.resultingParameterName,
|
|
3093
|
+
parameterValue: null,
|
|
3094
|
+
// <- [3]
|
|
3095
|
+
};
|
|
3096
|
+
if (isReturned) {
|
|
3097
|
+
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)
|
|
3098
|
+
.split('\n')
|
|
3099
|
+
.map(function (line) { return "> ".concat(line); })
|
|
3100
|
+
.join('\n')), "\n "); }));
|
|
3101
|
+
}
|
|
3102
|
+
return [4 /*yield*/, onProgress(progress_1)];
|
|
3096
3103
|
case 1:
|
|
3097
3104
|
_h.sent();
|
|
3098
3105
|
_h.label = 2;
|
|
@@ -3478,18 +3485,28 @@
|
|
|
3478
3485
|
if (resultString === null) {
|
|
3479
3486
|
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
3480
3487
|
}
|
|
3481
|
-
if (onProgress /* <- [3] */)
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3488
|
+
if (!onProgress /* <- [3] */) return [3 /*break*/, 9]; /* <- [3] */
|
|
3489
|
+
progress_2 = {
|
|
3490
|
+
name: name,
|
|
3491
|
+
title: title,
|
|
3492
|
+
isStarted: true,
|
|
3493
|
+
isDone: true,
|
|
3494
|
+
blockType: currentTemplate.blockType,
|
|
3495
|
+
parameterName: currentTemplate.resultingParameterName,
|
|
3496
|
+
parameterValue: resultString,
|
|
3497
|
+
// <- [3]
|
|
3498
|
+
};
|
|
3499
|
+
if (isReturned) {
|
|
3500
|
+
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)
|
|
3501
|
+
.split('\n')
|
|
3502
|
+
.map(function (line) { return "> ".concat(line); })
|
|
3503
|
+
.join('\n')), "\n\n "); }));
|
|
3492
3504
|
}
|
|
3505
|
+
return [4 /*yield*/, onProgress(progress_2)];
|
|
3506
|
+
case 8:
|
|
3507
|
+
_h.sent();
|
|
3508
|
+
_h.label = 9;
|
|
3509
|
+
case 9:
|
|
3493
3510
|
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)));
|
|
3494
3511
|
return [2 /*return*/];
|
|
3495
3512
|
}
|
|
@@ -3526,7 +3543,7 @@
|
|
|
3526
3543
|
}
|
|
3527
3544
|
return outputParameters;
|
|
3528
3545
|
}
|
|
3529
|
-
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;
|
|
3546
|
+
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;
|
|
3530
3547
|
var e_1, _e, e_2, _f;
|
|
3531
3548
|
return __generator(this, function (_g) {
|
|
3532
3549
|
switch (_g.label) {
|
|
@@ -3551,6 +3568,7 @@
|
|
|
3551
3568
|
description: preparedPipeline.description,
|
|
3552
3569
|
promptExecutions: [],
|
|
3553
3570
|
};
|
|
3571
|
+
isReturned = false;
|
|
3554
3572
|
try {
|
|
3555
3573
|
// Note: Check that all input input parameters are defined
|
|
3556
3574
|
for (_a = __values(preparedPipeline.parameters.filter(function (_a) {
|
|
@@ -3559,6 +3577,7 @@
|
|
|
3559
3577
|
})), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
3560
3578
|
parameter = _b.value;
|
|
3561
3579
|
if (inputParameters[parameter.name] === undefined) {
|
|
3580
|
+
isReturned = true;
|
|
3562
3581
|
return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
|
|
3563
3582
|
isSuccessful: false,
|
|
3564
3583
|
errors: __spreadArray([
|
|
@@ -3589,6 +3608,7 @@
|
|
|
3589
3608
|
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 "); })));
|
|
3590
3609
|
}
|
|
3591
3610
|
else if (parameter.isInput === false) {
|
|
3611
|
+
isReturned = true;
|
|
3592
3612
|
return { value: $asDeeplyFrozenSerializableJson(spaceTrim.spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
|
|
3593
3613
|
isSuccessful: false,
|
|
3594
3614
|
errors: __spreadArray([
|
|
@@ -3701,6 +3721,7 @@
|
|
|
3701
3721
|
return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
|
|
3702
3722
|
})), false));
|
|
3703
3723
|
outputParameters_1 = filterJustOutputParameters();
|
|
3724
|
+
isReturned = true;
|
|
3704
3725
|
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult', {
|
|
3705
3726
|
isSuccessful: false,
|
|
3706
3727
|
errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
|
|
@@ -3716,6 +3737,7 @@
|
|
|
3716
3737
|
return (result === null || result === void 0 ? void 0 : result.usage) || ZERO_USAGE;
|
|
3717
3738
|
})), false));
|
|
3718
3739
|
outputParameters = filterJustOutputParameters();
|
|
3740
|
+
isReturned = true;
|
|
3719
3741
|
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Successful PipelineExecutorResult', {
|
|
3720
3742
|
isSuccessful: true,
|
|
3721
3743
|
errors: errors.map(serializeError),
|
|
@@ -5781,7 +5803,7 @@
|
|
|
5781
5803
|
personas: [],
|
|
5782
5804
|
preparations: [],
|
|
5783
5805
|
};
|
|
5784
|
-
|
|
5806
|
+
function getPipelineIdentification() {
|
|
5785
5807
|
// Note: This is a 😐 implementation of [🚞]
|
|
5786
5808
|
var _ = [];
|
|
5787
5809
|
if (pipelineJson.sourceFile !== undefined) {
|
|
@@ -5791,7 +5813,7 @@
|
|
|
5791
5813
|
_.push("Url: ".concat(pipelineJson.pipelineUrl));
|
|
5792
5814
|
}
|
|
5793
5815
|
return _.join('\n');
|
|
5794
|
-
}
|
|
5816
|
+
}
|
|
5795
5817
|
// =============================================================
|
|
5796
5818
|
// Note: 1️⃣ Parsing of the markdown into object
|
|
5797
5819
|
pipelineString = removeContentComments(pipelineString);
|
|
@@ -5800,27 +5822,27 @@
|
|
|
5800
5822
|
pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
5801
5823
|
var _c = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _c[0], pipelineSections = _c.slice(1); /* <- Note: [🥞] */
|
|
5802
5824
|
if (pipelineHead === undefined) {
|
|
5803
|
-
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(
|
|
5825
|
+
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 "); }));
|
|
5804
5826
|
}
|
|
5805
5827
|
if (pipelineHead.level !== 1) {
|
|
5806
|
-
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Pipeline head is not h1\n\n ".concat(block(
|
|
5828
|
+
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 "); }));
|
|
5807
5829
|
}
|
|
5808
5830
|
if (!pipelineSections.every(function (section) { return section.level === 2; })) {
|
|
5809
|
-
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Not every pipeline section is h2\n\n ".concat(block(
|
|
5831
|
+
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 "); }));
|
|
5810
5832
|
}
|
|
5811
5833
|
// =============================================================
|
|
5812
5834
|
///Note: 2️⃣ Function for defining parameters
|
|
5813
5835
|
var defineParam = function (parameterCommand) {
|
|
5814
5836
|
var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
|
|
5815
5837
|
if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
|
|
5816
|
-
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(
|
|
5838
|
+
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: [🚞] */);
|
|
5817
5839
|
}
|
|
5818
5840
|
var existingParameter = pipelineJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
|
|
5819
5841
|
if (existingParameter &&
|
|
5820
5842
|
existingParameter.description &&
|
|
5821
5843
|
existingParameter.description !== parameterDescription &&
|
|
5822
5844
|
parameterDescription) {
|
|
5823
|
-
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description:\n\n ").concat(block(
|
|
5845
|
+
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 "); }));
|
|
5824
5846
|
}
|
|
5825
5847
|
if (existingParameter) {
|
|
5826
5848
|
if (parameterDescription) {
|
|
@@ -5883,10 +5905,10 @@
|
|
|
5883
5905
|
// <- Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
5884
5906
|
break;
|
|
5885
5907
|
case 'BOILERPLATE':
|
|
5886
|
-
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(
|
|
5908
|
+
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: [🚞]
|
|
5887
5909
|
// <- [💐]
|
|
5888
5910
|
default:
|
|
5889
|
-
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(
|
|
5911
|
+
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: [🚞]
|
|
5890
5912
|
}
|
|
5891
5913
|
};
|
|
5892
5914
|
try {
|
|
@@ -5919,7 +5941,7 @@
|
|
|
5919
5941
|
if (resultingParameterName !== null) {
|
|
5920
5942
|
return resultingParameterName;
|
|
5921
5943
|
}
|
|
5922
|
-
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Template section must end with -> {parameterName}\n\n ".concat(block(
|
|
5944
|
+
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(
|
|
5923
5945
|
// TODO: Show code of invalid sections each time + DRY
|
|
5924
5946
|
section.content
|
|
5925
5947
|
.split('\n')
|
|
@@ -5962,13 +5984,13 @@
|
|
|
5962
5984
|
// TODO: [🍧] Use here applyToPipelineJson and remove switch statement
|
|
5963
5985
|
case 'BLOCK':
|
|
5964
5986
|
if (isBlockTypeSet) {
|
|
5965
|
-
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(
|
|
5987
|
+
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 "); }));
|
|
5966
5988
|
}
|
|
5967
5989
|
if (command.blockType === 'SAMPLE') {
|
|
5968
5990
|
expectResultingParameterName();
|
|
5969
5991
|
var parameter = pipelineJson.parameters.find(function (param) { return param.name === resultingParameterName; });
|
|
5970
5992
|
if (parameter === undefined) {
|
|
5971
|
-
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Can not find parameter {".concat(resultingParameterName, "} to assign sample value\n\n ").concat(block(
|
|
5993
|
+
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 "); }));
|
|
5972
5994
|
}
|
|
5973
5995
|
parameter.sampleValues = parameter.sampleValues || [];
|
|
5974
5996
|
parameter.sampleValues.push(content);
|
|
@@ -6003,20 +6025,20 @@
|
|
|
6003
6025
|
templateJson.expectations[unit_1] = templateJson.expectations[unit_1] || {};
|
|
6004
6026
|
if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
|
|
6005
6027
|
if (templateJson.expectations[unit_1].min !== undefined) {
|
|
6006
|
-
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(
|
|
6028
|
+
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 "); }));
|
|
6007
6029
|
}
|
|
6008
6030
|
templateJson.expectations[unit_1].min = command.amount;
|
|
6009
6031
|
} /* not else */
|
|
6010
6032
|
if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
|
|
6011
6033
|
if (templateJson.expectations[unit_1].max !== undefined) {
|
|
6012
|
-
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(
|
|
6034
|
+
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 "); }));
|
|
6013
6035
|
}
|
|
6014
6036
|
templateJson.expectations[unit_1].max = command.amount;
|
|
6015
6037
|
}
|
|
6016
6038
|
break;
|
|
6017
6039
|
case 'EXPECT_FORMAT':
|
|
6018
6040
|
if (templateJson.expectFormat !== undefined && command.format !== templateJson.expectFormat) {
|
|
6019
|
-
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(
|
|
6041
|
+
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 "); }));
|
|
6020
6042
|
}
|
|
6021
6043
|
templateJson.expectFormat = command.format;
|
|
6022
6044
|
break;
|
|
@@ -6052,11 +6074,11 @@
|
|
|
6052
6074
|
// <- Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
6053
6075
|
break;
|
|
6054
6076
|
case 'BOILERPLATE':
|
|
6055
|
-
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(
|
|
6077
|
+
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 "); })));
|
|
6056
6078
|
break;
|
|
6057
6079
|
// <- [💐]
|
|
6058
6080
|
default:
|
|
6059
|
-
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(
|
|
6081
|
+
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 "); }));
|
|
6060
6082
|
}
|
|
6061
6083
|
};
|
|
6062
6084
|
try {
|
|
@@ -6078,7 +6100,7 @@
|
|
|
6078
6100
|
// TODO: [🍧] Should be done in BLOCK command
|
|
6079
6101
|
if (templateJson.blockType === 'SCRIPT') {
|
|
6080
6102
|
if (!language) {
|
|
6081
|
-
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(
|
|
6103
|
+
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 "); }));
|
|
6082
6104
|
}
|
|
6083
6105
|
if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
|
|
6084
6106
|
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 "); }));
|