@promptbook/cli 0.61.0-25 → 0.61.0-26
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 +103 -94
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/utils.index.d.ts +4 -4
- package/esm/typings/src/conversion/utils/{extractParametersFromPromptTemplate.d.ts → extractParameterNamesFromPromptTemplate.d.ts} +1 -1
- package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +1 -1
- package/esm/typings/src/utils/{extractParameters.d.ts → extractParameterNames.d.ts} +2 -2
- package/package.json +2 -2
- package/umd/index.umd.js +103 -94
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/src/_packages/utils.index.d.ts +4 -4
- package/umd/typings/src/conversion/utils/{extractParametersFromPromptTemplate.d.ts → extractParameterNamesFromPromptTemplate.d.ts} +1 -1
- package/umd/typings/src/types/PipelineJson/PipelineJson.d.ts +1 -1
- package/umd/typings/src/utils/{extractParameters.d.ts → extractParameterNames.d.ts} +2 -2
- /package/esm/typings/src/conversion/utils/{extractParametersFromPromptTemplate.test.d.ts → extractParameterNamesFromPromptTemplate.test.d.ts} +0 -0
- /package/esm/typings/src/utils/{extractParameters.test.d.ts → extractParameterNames.test.d.ts} +0 -0
- /package/umd/typings/src/conversion/utils/{extractParametersFromPromptTemplate.test.d.ts → extractParameterNamesFromPromptTemplate.test.d.ts} +0 -0
- /package/umd/typings/src/utils/{extractParameters.test.d.ts → extractParameterNames.test.d.ts} +0 -0
package/esm/index.es.js
CHANGED
|
@@ -150,7 +150,7 @@ new Function("\n try {\n if (typeof WorkerGlobalScope !== 'undefined'
|
|
|
150
150
|
/**
|
|
151
151
|
* The version of the Promptbook library
|
|
152
152
|
*/
|
|
153
|
-
var PROMPTBOOK_VERSION = '0.61.0-
|
|
153
|
+
var PROMPTBOOK_VERSION = '0.61.0-25';
|
|
154
154
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
155
155
|
|
|
156
156
|
/**
|
|
@@ -747,7 +747,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
747
747
|
});
|
|
748
748
|
}
|
|
749
749
|
|
|
750
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-
|
|
750
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-25",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",modelName:"claude-3-opus-20240229"},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:[{id:1,promptbookVersion:"0.61.0-25",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.61.0-25",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",modelName:"claude-3-opus-20240229"},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:[{id:1,promptbookVersion:"0.61.0-25",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.61.0-25",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",modelName:"claude-3-opus-20240229"},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:[{id:1,promptbookVersion:"0.61.0-25",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.61.0-25",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",modelName:"gpt-4-turbo"},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### Option `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Option `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### Option `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:[{id:1,promptbookVersion:"0.61.0-25",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
|
|
751
751
|
|
|
752
752
|
/**
|
|
753
753
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -950,52 +950,63 @@ function isValidPipelineUrl(url) {
|
|
|
950
950
|
*/
|
|
951
951
|
function validatePipeline(pipeline) {
|
|
952
952
|
// TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
|
|
953
|
-
var e_1, _a, e_2, _b, e_3, _c
|
|
953
|
+
var e_1, _a, e_2, _b, e_3, _c;
|
|
954
|
+
var pipelineIdentification = (function () {
|
|
955
|
+
// Note: This is a 😐 implementation of [🚞]
|
|
956
|
+
var _ = [];
|
|
957
|
+
if (pipeline.sourceFile !== undefined) {
|
|
958
|
+
_.push("File: ".concat(pipeline.sourceFile));
|
|
959
|
+
}
|
|
960
|
+
if (pipeline.pipelineUrl !== undefined) {
|
|
961
|
+
_.push("Url: ".concat(pipeline.pipelineUrl));
|
|
962
|
+
}
|
|
963
|
+
return _.join('\n');
|
|
964
|
+
})();
|
|
954
965
|
if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
|
|
955
966
|
// <- Note: [🚲]
|
|
956
|
-
throw new PipelineLogicError("Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\""));
|
|
967
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
957
968
|
}
|
|
958
969
|
if (!isValidPromptbookVersion(pipeline.promptbookVersion)) {
|
|
959
970
|
// <- Note: [🚲]
|
|
960
|
-
throw new PipelineLogicError("Invalid
|
|
971
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.promptbookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
961
972
|
}
|
|
962
973
|
// TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
|
|
963
974
|
if (!Array.isArray(pipeline.parameters)) {
|
|
964
975
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
965
|
-
throw new ParsingError(spaceTrim$1("\n
|
|
976
|
+
throw new ParsingError(spaceTrim$1(function (block) { return "\n Promptbook is valid JSON but with wrong structure\n\n `promptbook.parameters` expected to be an array, but got ".concat(typeof pipeline.parameters, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
966
977
|
}
|
|
967
978
|
// TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
|
|
968
979
|
if (!Array.isArray(pipeline.promptTemplates)) {
|
|
969
980
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
970
|
-
throw new ParsingError(spaceTrim$1("\n
|
|
981
|
+
throw new ParsingError(spaceTrim$1(function (block) { return "\n Promptbook is valid JSON but with wrong structure\n\n `promptbook.promptTemplates` expected to be an array, but got ".concat(typeof pipeline.promptTemplates, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
971
982
|
}
|
|
972
983
|
var _loop_1 = function (parameter) {
|
|
973
984
|
if (parameter.isInput && parameter.isOutput) {
|
|
974
|
-
throw new PipelineLogicError("Parameter {".concat(parameter.name, "} can not be both input and output"));
|
|
985
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n\n Parameter {".concat(parameter.name, "} can not be both input and output\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
975
986
|
}
|
|
976
987
|
// Note: Testing that parameter is either intermediate or output BUT not created and unused
|
|
977
988
|
if (!parameter.isInput &&
|
|
978
989
|
!parameter.isOutput &&
|
|
979
990
|
!pipeline.promptTemplates.some(function (template) { return template.dependentParameterNames.includes(parameter.name); })) {
|
|
980
|
-
throw new PipelineLogicError(spaceTrim$1("\n
|
|
991
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter {".concat(parameter.name, "} is created but not used\n\n You can declare {").concat(parameter.name, "} as output parameter by adding in the header:\n - OUTPUT PARAMETER `{").concat(parameter.name, "}` ").concat(parameter.description || '', "\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
|
|
981
992
|
}
|
|
982
993
|
// Note: Testing that parameter is either input or result of some template
|
|
983
994
|
if (!parameter.isInput &&
|
|
984
995
|
!pipeline.promptTemplates.some(function (template) { return template.resultingParameterName === parameter.name; })) {
|
|
985
|
-
throw new PipelineLogicError(spaceTrim$1("\n
|
|
996
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter {".concat(parameter.name, "} is declared but not defined\n\n You can do one of these:\n - Remove declaration of {").concat(parameter.name, "}\n - Add prompt template that results in -> {").concat(parameter.name, "}\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
986
997
|
}
|
|
987
998
|
};
|
|
988
999
|
try {
|
|
989
1000
|
// Note: Check each parameter individually
|
|
990
|
-
for (var
|
|
991
|
-
var parameter =
|
|
1001
|
+
for (var _d = __values(pipeline.parameters), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
1002
|
+
var parameter = _e.value;
|
|
992
1003
|
_loop_1(parameter);
|
|
993
1004
|
}
|
|
994
1005
|
}
|
|
995
1006
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
996
1007
|
finally {
|
|
997
1008
|
try {
|
|
998
|
-
if (
|
|
1009
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
999
1010
|
}
|
|
1000
1011
|
finally { if (e_1) throw e_1.error; }
|
|
1001
1012
|
}
|
|
@@ -1007,70 +1018,80 @@ function validatePipeline(pipeline) {
|
|
|
1007
1018
|
var name = _a.name;
|
|
1008
1019
|
return name;
|
|
1009
1020
|
}));
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1021
|
+
var _loop_2 = function (template) {
|
|
1022
|
+
var e_4, _h, e_5, _j;
|
|
1023
|
+
if (definedParameters.has(template.resultingParameterName)) {
|
|
1024
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter {".concat(template.resultingParameterName, "} is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1025
|
+
}
|
|
1026
|
+
if (RESERVED_PARAMETER_NAMES.includes(template.resultingParameterName)) {
|
|
1027
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter name {".concat(template.resultingParameterName, "} is reserved, please use different name\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1028
|
+
}
|
|
1029
|
+
definedParameters.add(template.resultingParameterName);
|
|
1030
|
+
if (template.blockType === 'PROMPT_TEMPLATE' && template.modelRequirements.modelVariant === undefined) {
|
|
1031
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n\n You must specify MODEL VARIANT in the prompt template \"".concat(template.title, "\"\n\n For example:\n - MODEL VARIANT Chat\n - MODEL NAME `gpt-4-1106-preview`").concat(/* <- TODO: Dynamic listing of command examples */ '', "\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1032
|
+
}
|
|
1033
|
+
if (template.jokerParameterNames && template.jokerParameterNames.length > 0) {
|
|
1034
|
+
if (!template.expectFormat &&
|
|
1035
|
+
!template.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
|
|
1036
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Joker parameters are used for {".concat(template.resultingParameterName, "} but no expectations are defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1016
1037
|
}
|
|
1017
|
-
|
|
1018
|
-
|
|
1038
|
+
var _loop_4 = function (joker) {
|
|
1039
|
+
if (!template.dependentParameterNames.includes(joker)) {
|
|
1040
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter {".concat(joker, "} is used for {").concat(template.resultingParameterName, "} as joker but not in `dependentParameterNames`\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1041
|
+
}
|
|
1042
|
+
};
|
|
1043
|
+
try {
|
|
1044
|
+
for (var _k = (e_4 = void 0, __values(template.jokerParameterNames)), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
1045
|
+
var joker = _l.value;
|
|
1046
|
+
_loop_4(joker);
|
|
1047
|
+
}
|
|
1019
1048
|
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1049
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
1050
|
+
finally {
|
|
1051
|
+
try {
|
|
1052
|
+
if (_l && !_l.done && (_h = _k.return)) _h.call(_k);
|
|
1053
|
+
}
|
|
1054
|
+
finally { if (e_4) throw e_4.error; }
|
|
1023
1055
|
}
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1056
|
+
}
|
|
1057
|
+
if (template.expectations) {
|
|
1058
|
+
var _loop_5 = function (unit, min, max) {
|
|
1059
|
+
if (min !== undefined && max !== undefined && min > max) {
|
|
1060
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Min expectation (=".concat(min, ") of ").concat(unit, " is higher than max expectation (=").concat(max, ")\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1028
1061
|
}
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
var joker = _l.value;
|
|
1032
|
-
if (!template.dependentParameterNames.includes(joker)) {
|
|
1033
|
-
throw new PipelineLogicError("Parameter {".concat(joker, "} is used for {").concat(template.resultingParameterName, "} as joker but not in dependentParameterNames"));
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1062
|
+
if (min !== undefined && min < 0) {
|
|
1063
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Min expectation of ".concat(unit, " must be zero or positive\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1036
1064
|
}
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1065
|
+
if (max !== undefined && max <= 0) {
|
|
1066
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Max expectation of ".concat(unit, " must be positive\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1067
|
+
}
|
|
1068
|
+
};
|
|
1069
|
+
try {
|
|
1070
|
+
for (var _m = (e_5 = void 0, __values(Object.entries(template.expectations))), _o = _m.next(); !_o.done; _o = _m.next()) {
|
|
1071
|
+
var _p = __read(_o.value, 2), unit = _p[0], _q = _p[1], min = _q.min, max = _q.max;
|
|
1072
|
+
_loop_5(unit, min, max);
|
|
1043
1073
|
}
|
|
1044
1074
|
}
|
|
1045
|
-
|
|
1075
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
1076
|
+
finally {
|
|
1046
1077
|
try {
|
|
1047
|
-
|
|
1048
|
-
var _p = __read(_o.value, 2), unit = _p[0], _q = _p[1], min = _q.min, max = _q.max;
|
|
1049
|
-
if (min !== undefined && max !== undefined && min > max) {
|
|
1050
|
-
throw new PipelineLogicError("Min expectation (=".concat(min, ") of ").concat(unit, " is higher than max expectation (=").concat(max, ")"));
|
|
1051
|
-
}
|
|
1052
|
-
if (min !== undefined && min < 0) {
|
|
1053
|
-
throw new PipelineLogicError("Min expectation of ".concat(unit, " must be zero or positive"));
|
|
1054
|
-
}
|
|
1055
|
-
if (max !== undefined && max <= 0) {
|
|
1056
|
-
throw new PipelineLogicError("Max expectation of ".concat(unit, " must be positive"));
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
1061
|
-
finally {
|
|
1062
|
-
try {
|
|
1063
|
-
if (_o && !_o.done && (_d = _m.return)) _d.call(_m);
|
|
1064
|
-
}
|
|
1065
|
-
finally { if (e_4) throw e_4.error; }
|
|
1078
|
+
if (_o && !_o.done && (_j = _m.return)) _j.call(_m);
|
|
1066
1079
|
}
|
|
1080
|
+
finally { if (e_5) throw e_5.error; }
|
|
1067
1081
|
}
|
|
1068
1082
|
}
|
|
1083
|
+
};
|
|
1084
|
+
try {
|
|
1085
|
+
// Note: Checking each template individually
|
|
1086
|
+
for (var _f = __values(pipeline.promptTemplates), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
1087
|
+
var template = _g.value;
|
|
1088
|
+
_loop_2(template);
|
|
1089
|
+
}
|
|
1069
1090
|
}
|
|
1070
1091
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1071
1092
|
finally {
|
|
1072
1093
|
try {
|
|
1073
|
-
if (
|
|
1094
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
1074
1095
|
}
|
|
1075
1096
|
finally { if (e_2) throw e_2.error; }
|
|
1076
1097
|
}
|
|
@@ -1091,20 +1112,20 @@ function validatePipeline(pipeline) {
|
|
|
1091
1112
|
resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), [reservedParameterName], false);
|
|
1092
1113
|
}
|
|
1093
1114
|
}
|
|
1094
|
-
catch (
|
|
1115
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1095
1116
|
finally {
|
|
1096
1117
|
try {
|
|
1097
|
-
if (RESERVED_PARAMETER_NAMES_1_1 && !RESERVED_PARAMETER_NAMES_1_1.done && (
|
|
1118
|
+
if (RESERVED_PARAMETER_NAMES_1_1 && !RESERVED_PARAMETER_NAMES_1_1.done && (_c = RESERVED_PARAMETER_NAMES_1.return)) _c.call(RESERVED_PARAMETER_NAMES_1);
|
|
1098
1119
|
}
|
|
1099
|
-
finally { if (
|
|
1120
|
+
finally { if (e_3) throw e_3.error; }
|
|
1100
1121
|
}
|
|
1101
1122
|
var unresovedTemplates = __spreadArray([], __read(pipeline.promptTemplates), false);
|
|
1102
1123
|
// <- TODO: [🧠][🥜]
|
|
1103
1124
|
var loopLimit = LOOP_LIMIT;
|
|
1104
|
-
var
|
|
1125
|
+
var _loop_3 = function () {
|
|
1105
1126
|
if (loopLimit-- < 0) {
|
|
1106
1127
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
1107
|
-
throw new UnexpectedError(
|
|
1128
|
+
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Loop limit reached during detection of circular dependencies in `validatePipeline`\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
1108
1129
|
}
|
|
1109
1130
|
var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
|
|
1110
1131
|
return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
|
|
@@ -1119,7 +1140,7 @@ function validatePipeline(pipeline) {
|
|
|
1119
1140
|
.map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
|
|
1120
1141
|
.join(' and '));
|
|
1121
1142
|
})
|
|
1122
|
-
.join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameters.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n "); }));
|
|
1143
|
+
.join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameters.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1123
1144
|
}
|
|
1124
1145
|
resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTemplates.map(function (_a) {
|
|
1125
1146
|
var resultingParameterName = _a.resultingParameterName;
|
|
@@ -1128,7 +1149,7 @@ function validatePipeline(pipeline) {
|
|
|
1128
1149
|
unresovedTemplates = unresovedTemplates.filter(function (template) { return !currentlyResovedTemplates.includes(template); });
|
|
1129
1150
|
};
|
|
1130
1151
|
while (unresovedTemplates.length > 0) {
|
|
1131
|
-
|
|
1152
|
+
_loop_3();
|
|
1132
1153
|
}
|
|
1133
1154
|
return pipeline;
|
|
1134
1155
|
}
|
|
@@ -1187,7 +1208,7 @@ var ReferenceError$1 = /** @class */ (function (_super) {
|
|
|
1187
1208
|
* @param template the template with parameters in {curly} braces
|
|
1188
1209
|
* @returns the list of parameter names
|
|
1189
1210
|
*/
|
|
1190
|
-
function
|
|
1211
|
+
function extractParameterNames(template) {
|
|
1191
1212
|
var e_1, _a;
|
|
1192
1213
|
var matches = template.matchAll(/{\w+}/g);
|
|
1193
1214
|
var parameterNames = new Set();
|
|
@@ -1220,7 +1241,7 @@ function unpreparePipeline(pipeline) {
|
|
|
1220
1241
|
knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
|
|
1221
1242
|
promptTemplates = promptTemplates.map(function (promptTemplate) {
|
|
1222
1243
|
var dependentParameterNames = promptTemplate.dependentParameterNames;
|
|
1223
|
-
var parameterNames =
|
|
1244
|
+
var parameterNames = extractParameterNames(promptTemplate.preparedContent || '');
|
|
1224
1245
|
dependentParameterNames = dependentParameterNames.filter(function (dependentParameterName) { return !parameterNames.has(dependentParameterName); });
|
|
1225
1246
|
var promptTemplateUnprepared = __assign(__assign({}, promptTemplate), { dependentParameterNames: dependentParameterNames });
|
|
1226
1247
|
delete promptTemplateUnprepared.preparedContent;
|
|
@@ -1777,12 +1798,12 @@ function extractVariables(script) {
|
|
|
1777
1798
|
* @returns the set of parameter names
|
|
1778
1799
|
* @throws {ParsingError} if the script is invalid
|
|
1779
1800
|
*/
|
|
1780
|
-
function
|
|
1801
|
+
function extractParameterNamesFromPromptTemplate(promptTemplate) {
|
|
1781
1802
|
var e_1, _a, e_2, _b, e_3, _c;
|
|
1782
1803
|
var title = promptTemplate.title, description = promptTemplate.description, blockType = promptTemplate.blockType, content = promptTemplate.content, preparedContent = promptTemplate.preparedContent, jokerParameterNames = promptTemplate.jokerParameterNames;
|
|
1783
1804
|
var parameterNames = new Set();
|
|
1784
1805
|
try {
|
|
1785
|
-
for (var _d = __values(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(
|
|
1806
|
+
for (var _d = __values(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(extractParameterNames(title)), false), __read(extractParameterNames(description || '')), false), __read(extractParameterNames(content)), false), __read(extractParameterNames(preparedContent || '')), false)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
1786
1807
|
var parameterName = _e.value;
|
|
1787
1808
|
parameterNames.add(parameterName);
|
|
1788
1809
|
}
|
|
@@ -2576,7 +2597,7 @@ function createPipelineExecutor(options) {
|
|
|
2576
2597
|
_u.sent();
|
|
2577
2598
|
_u.label = 2;
|
|
2578
2599
|
case 2:
|
|
2579
|
-
usedParameterNames =
|
|
2600
|
+
usedParameterNames = extractParameterNamesFromPromptTemplate(currentTemplate);
|
|
2580
2601
|
dependentParameterNames = new Set(currentTemplate.dependentParameterNames);
|
|
2581
2602
|
if (union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)).size !== 0) {
|
|
2582
2603
|
throw new UnexpectedError(spaceTrim$1("\n Dependent parameters are not consistent used parameters:\n\n Dependent parameters:\n ".concat(Array.from(dependentParameterNames).join(', '), "\n\n Used parameters:\n ").concat(Array.from(usedParameterNames).join(', '), "\n\n ")));
|
|
@@ -2962,14 +2983,7 @@ function createPipelineExecutor(options) {
|
|
|
2962
2983
|
) {
|
|
2963
2984
|
// TODO: [🧠] Maybe put other blockTypes into report
|
|
2964
2985
|
executionReport.promptExecutions.push({
|
|
2965
|
-
prompt: {
|
|
2966
|
-
title: currentTemplate.title /* <- Note: If title in pipeline contains emojis, pass it innto report */,
|
|
2967
|
-
content: prompt.content,
|
|
2968
|
-
modelRequirements: prompt.modelRequirements,
|
|
2969
|
-
expectations: prompt.expectations,
|
|
2970
|
-
expectFormat: prompt.expectFormat,
|
|
2971
|
-
// <- Note: Do want to pass ONLY wanted information to the report
|
|
2972
|
-
},
|
|
2986
|
+
prompt: __assign(__assign({ '!!! All information': null }, prompt), { '!!! Wanted information': null, title: currentTemplate.title /* <- Note: If title in pipeline contains emojis, pass it innto report */, content: prompt.content, modelRequirements: prompt.modelRequirements, expectations: prompt.expectations, expectFormat: prompt.expectFormat }),
|
|
2973
2987
|
result: result || undefined,
|
|
2974
2988
|
error: expectError || undefined,
|
|
2975
2989
|
});
|
|
@@ -4449,11 +4463,8 @@ var promptbookVersionCommandParser = {
|
|
|
4449
4463
|
/**
|
|
4450
4464
|
* Name of the command
|
|
4451
4465
|
*/
|
|
4452
|
-
name: '
|
|
4453
|
-
|
|
4454
|
-
Note: [📇] No need to put here "PROMPTBOOK" alias here
|
|
4455
|
-
aliasNames: ['PROMPTBOOK_VERSION'],
|
|
4456
|
-
*/
|
|
4466
|
+
name: 'PROMPTBOOK_VERSION',
|
|
4467
|
+
aliasNames: ['PTBK_VERSION', 'PTBK_V', 'PTBKV'],
|
|
4457
4468
|
/**
|
|
4458
4469
|
* BOILERPLATE command can be used in:
|
|
4459
4470
|
*/
|
|
@@ -4469,7 +4480,7 @@ var promptbookVersionCommandParser = {
|
|
|
4469
4480
|
/**
|
|
4470
4481
|
* Example usages of the PROMPTBOOK_VERSION command
|
|
4471
4482
|
*/
|
|
4472
|
-
examples: ["PROMPTBOOK VERSION ".concat(PROMPTBOOK_VERSION), "
|
|
4483
|
+
examples: ["PROMPTBOOK VERSION ".concat(PROMPTBOOK_VERSION), "PTBKV ".concat(PROMPTBOOK_VERSION)],
|
|
4473
4484
|
/**
|
|
4474
4485
|
* Parses the PROMPTBOOK_VERSION command
|
|
4475
4486
|
*/
|
|
@@ -4503,8 +4514,9 @@ var urlCommandParser = {
|
|
|
4503
4514
|
* Name of the command
|
|
4504
4515
|
*/
|
|
4505
4516
|
name: 'URL',
|
|
4517
|
+
aliasNames: ['PIPELINE_URL'],
|
|
4506
4518
|
/*
|
|
4507
|
-
Note: [🛵] No need for alias name because it is already preprocessed
|
|
4519
|
+
Note: [🛵] No need for this alias name because it is already preprocessed
|
|
4508
4520
|
aliasNames: ['HTTPS'],
|
|
4509
4521
|
*/
|
|
4510
4522
|
/**
|
|
@@ -4523,6 +4535,7 @@ var urlCommandParser = {
|
|
|
4523
4535
|
* Example usages of the URL command
|
|
4524
4536
|
*/
|
|
4525
4537
|
examples: [
|
|
4538
|
+
'PIPELINE URL https://promptbook.studio/library/write-cv.ptbk.md',
|
|
4526
4539
|
'URL https://promptbook.studio/library/write-cv.ptbk.md',
|
|
4527
4540
|
'https://promptbook.studio/library/write-cv.ptbk.md',
|
|
4528
4541
|
],
|
|
@@ -4761,10 +4774,6 @@ function parseCommand(raw, usagePlace) {
|
|
|
4761
4774
|
.split(' ')
|
|
4762
4775
|
.map(function (part) { return part.trim(); })
|
|
4763
4776
|
.filter(function (item) { return item !== ''; })
|
|
4764
|
-
// Note: [📇]:
|
|
4765
|
-
.filter(function (item) { return !/^PTBK$/i.test(item); })
|
|
4766
|
-
.filter(function (item) { return !/^PIPELINE$/i.test(item); })
|
|
4767
|
-
.filter(function (item) { return !/^PROMPTBOOK$/i.test(item); })
|
|
4768
4777
|
.map(removeMarkdownFormatting)
|
|
4769
4778
|
.map(function (item) { return item.trim(); });
|
|
4770
4779
|
if (items.length === 0 || items[0] === '') {
|
|
@@ -5479,7 +5488,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
5479
5488
|
if (templateModelRequirements.modelVariant === undefined) {
|
|
5480
5489
|
templateModelRequirements.modelVariant = 'CHAT';
|
|
5481
5490
|
}
|
|
5482
|
-
templateJson.dependentParameterNames = Array.from(
|
|
5491
|
+
templateJson.dependentParameterNames = Array.from(extractParameterNamesFromPromptTemplate(templateJson));
|
|
5483
5492
|
// TODO: [🍧][❔] Remove this condition - modelRequirements should be put here via BLOCK command not removed when PROMPT_TEMPLATE
|
|
5484
5493
|
if (templateJson.blockType !== 'PROMPT_TEMPLATE') {
|
|
5485
5494
|
delete templateJson.modelRequirements;
|