@promptbook/cli 0.61.0-24 → 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/README.md +3 -3
- package/esm/index.es.js +179 -135
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/utils.index.d.ts +4 -4
- package/esm/typings/src/config.d.ts +5 -1
- package/esm/typings/src/conversion/utils/{extractParametersFromPromptTemplate.d.ts → extractParameterNamesFromPromptTemplate.d.ts} +1 -1
- package/esm/typings/src/execution/createPipelineExecutor.d.ts +2 -0
- package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.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} +4 -1
- package/package.json +2 -2
- package/umd/index.umd.js +179 -135
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/src/_packages/utils.index.d.ts +4 -4
- package/umd/typings/src/config.d.ts +5 -1
- package/umd/typings/src/conversion/utils/{extractParametersFromPromptTemplate.d.ts → extractParameterNamesFromPromptTemplate.d.ts} +1 -1
- package/umd/typings/src/execution/createPipelineExecutor.d.ts +2 -0
- package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.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} +4 -1
- /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
|
/**
|
|
@@ -287,6 +287,7 @@ var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
|
|
|
287
287
|
* The names of the parameters that are reserved for special purposes
|
|
288
288
|
*/
|
|
289
289
|
var RESERVED_PARAMETER_NAMES = deepFreeze([
|
|
290
|
+
'content',
|
|
290
291
|
'context',
|
|
291
292
|
'knowledge',
|
|
292
293
|
'samples',
|
|
@@ -299,6 +300,10 @@ var RESERVED_PARAMETER_NAMES = deepFreeze([
|
|
|
299
300
|
* @@@
|
|
300
301
|
*/
|
|
301
302
|
var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
|
|
303
|
+
/**
|
|
304
|
+
* @@@
|
|
305
|
+
*/
|
|
306
|
+
var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
|
|
302
307
|
/*
|
|
303
308
|
TODO: !!! Just testing false-negative detection of [🟡][🟢][🔵][⚪] leak
|
|
304
309
|
*/
|
|
@@ -742,7 +747,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
742
747
|
});
|
|
743
748
|
}
|
|
744
749
|
|
|
745
|
-
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"}];
|
|
746
751
|
|
|
747
752
|
/**
|
|
748
753
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -945,52 +950,63 @@ function isValidPipelineUrl(url) {
|
|
|
945
950
|
*/
|
|
946
951
|
function validatePipeline(pipeline) {
|
|
947
952
|
// TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
|
|
948
|
-
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
|
+
})();
|
|
949
965
|
if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
|
|
950
966
|
// <- Note: [🚲]
|
|
951
|
-
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 "); }));
|
|
952
968
|
}
|
|
953
969
|
if (!isValidPromptbookVersion(pipeline.promptbookVersion)) {
|
|
954
970
|
// <- Note: [🚲]
|
|
955
|
-
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 "); }));
|
|
956
972
|
}
|
|
957
973
|
// TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
|
|
958
974
|
if (!Array.isArray(pipeline.parameters)) {
|
|
959
975
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
960
|
-
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 "); }));
|
|
961
977
|
}
|
|
962
978
|
// TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
|
|
963
979
|
if (!Array.isArray(pipeline.promptTemplates)) {
|
|
964
980
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
965
|
-
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 "); }));
|
|
966
982
|
}
|
|
967
983
|
var _loop_1 = function (parameter) {
|
|
968
984
|
if (parameter.isInput && parameter.isOutput) {
|
|
969
|
-
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 "); }));
|
|
970
986
|
}
|
|
971
987
|
// Note: Testing that parameter is either intermediate or output BUT not created and unused
|
|
972
988
|
if (!parameter.isInput &&
|
|
973
989
|
!parameter.isOutput &&
|
|
974
990
|
!pipeline.promptTemplates.some(function (template) { return template.dependentParameterNames.includes(parameter.name); })) {
|
|
975
|
-
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 "); }));
|
|
976
992
|
}
|
|
977
993
|
// Note: Testing that parameter is either input or result of some template
|
|
978
994
|
if (!parameter.isInput &&
|
|
979
995
|
!pipeline.promptTemplates.some(function (template) { return template.resultingParameterName === parameter.name; })) {
|
|
980
|
-
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 "); }));
|
|
981
997
|
}
|
|
982
998
|
};
|
|
983
999
|
try {
|
|
984
1000
|
// Note: Check each parameter individually
|
|
985
|
-
for (var
|
|
986
|
-
var parameter =
|
|
1001
|
+
for (var _d = __values(pipeline.parameters), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
1002
|
+
var parameter = _e.value;
|
|
987
1003
|
_loop_1(parameter);
|
|
988
1004
|
}
|
|
989
1005
|
}
|
|
990
1006
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
991
1007
|
finally {
|
|
992
1008
|
try {
|
|
993
|
-
if (
|
|
1009
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
994
1010
|
}
|
|
995
1011
|
finally { if (e_1) throw e_1.error; }
|
|
996
1012
|
}
|
|
@@ -1002,70 +1018,80 @@ function validatePipeline(pipeline) {
|
|
|
1002
1018
|
var name = _a.name;
|
|
1003
1019
|
return name;
|
|
1004
1020
|
}));
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
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 "); }));
|
|
1011
1037
|
}
|
|
1012
|
-
|
|
1013
|
-
|
|
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
|
+
}
|
|
1014
1048
|
}
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
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; }
|
|
1018
1055
|
}
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
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 "); }));
|
|
1023
1061
|
}
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
var joker = _l.value;
|
|
1027
|
-
if (!template.dependentParameterNames.includes(joker)) {
|
|
1028
|
-
throw new PipelineLogicError("Parameter {".concat(joker, "} is used for {").concat(template.resultingParameterName, "} as joker but not in dependentParameterNames"));
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
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 "); }));
|
|
1031
1064
|
}
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
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);
|
|
1038
1073
|
}
|
|
1039
1074
|
}
|
|
1040
|
-
|
|
1075
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
1076
|
+
finally {
|
|
1041
1077
|
try {
|
|
1042
|
-
|
|
1043
|
-
var _p = __read(_o.value, 2), unit = _p[0], _q = _p[1], min = _q.min, max = _q.max;
|
|
1044
|
-
if (min !== undefined && max !== undefined && min > max) {
|
|
1045
|
-
throw new PipelineLogicError("Min expectation (=".concat(min, ") of ").concat(unit, " is higher than max expectation (=").concat(max, ")"));
|
|
1046
|
-
}
|
|
1047
|
-
if (min !== undefined && min < 0) {
|
|
1048
|
-
throw new PipelineLogicError("Min expectation of ".concat(unit, " must be zero or positive"));
|
|
1049
|
-
}
|
|
1050
|
-
if (max !== undefined && max <= 0) {
|
|
1051
|
-
throw new PipelineLogicError("Max expectation of ".concat(unit, " must be positive"));
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
1056
|
-
finally {
|
|
1057
|
-
try {
|
|
1058
|
-
if (_o && !_o.done && (_d = _m.return)) _d.call(_m);
|
|
1059
|
-
}
|
|
1060
|
-
finally { if (e_4) throw e_4.error; }
|
|
1078
|
+
if (_o && !_o.done && (_j = _m.return)) _j.call(_m);
|
|
1061
1079
|
}
|
|
1080
|
+
finally { if (e_5) throw e_5.error; }
|
|
1062
1081
|
}
|
|
1063
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
|
+
}
|
|
1064
1090
|
}
|
|
1065
1091
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1066
1092
|
finally {
|
|
1067
1093
|
try {
|
|
1068
|
-
if (
|
|
1094
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
1069
1095
|
}
|
|
1070
1096
|
finally { if (e_2) throw e_2.error; }
|
|
1071
1097
|
}
|
|
@@ -1086,20 +1112,20 @@ function validatePipeline(pipeline) {
|
|
|
1086
1112
|
resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), [reservedParameterName], false);
|
|
1087
1113
|
}
|
|
1088
1114
|
}
|
|
1089
|
-
catch (
|
|
1115
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1090
1116
|
finally {
|
|
1091
1117
|
try {
|
|
1092
|
-
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);
|
|
1093
1119
|
}
|
|
1094
|
-
finally { if (
|
|
1120
|
+
finally { if (e_3) throw e_3.error; }
|
|
1095
1121
|
}
|
|
1096
1122
|
var unresovedTemplates = __spreadArray([], __read(pipeline.promptTemplates), false);
|
|
1097
1123
|
// <- TODO: [🧠][🥜]
|
|
1098
1124
|
var loopLimit = LOOP_LIMIT;
|
|
1099
|
-
var
|
|
1125
|
+
var _loop_3 = function () {
|
|
1100
1126
|
if (loopLimit-- < 0) {
|
|
1101
1127
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
1102
|
-
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 "); }));
|
|
1103
1129
|
}
|
|
1104
1130
|
var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
|
|
1105
1131
|
return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
|
|
@@ -1114,7 +1140,7 @@ function validatePipeline(pipeline) {
|
|
|
1114
1140
|
.map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
|
|
1115
1141
|
.join(' and '));
|
|
1116
1142
|
})
|
|
1117
|
-
.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 "); }));
|
|
1118
1144
|
}
|
|
1119
1145
|
resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTemplates.map(function (_a) {
|
|
1120
1146
|
var resultingParameterName = _a.resultingParameterName;
|
|
@@ -1123,7 +1149,7 @@ function validatePipeline(pipeline) {
|
|
|
1123
1149
|
unresovedTemplates = unresovedTemplates.filter(function (template) { return !currentlyResovedTemplates.includes(template); });
|
|
1124
1150
|
};
|
|
1125
1151
|
while (unresovedTemplates.length > 0) {
|
|
1126
|
-
|
|
1152
|
+
_loop_3();
|
|
1127
1153
|
}
|
|
1128
1154
|
return pipeline;
|
|
1129
1155
|
}
|
|
@@ -1176,6 +1202,36 @@ var ReferenceError$1 = /** @class */ (function (_super) {
|
|
|
1176
1202
|
return ReferenceError;
|
|
1177
1203
|
}(Error));
|
|
1178
1204
|
|
|
1205
|
+
/**
|
|
1206
|
+
* Parses the template and returns the list of all parameter names
|
|
1207
|
+
*
|
|
1208
|
+
* @param template the template with parameters in {curly} braces
|
|
1209
|
+
* @returns the list of parameter names
|
|
1210
|
+
*/
|
|
1211
|
+
function extractParameterNames(template) {
|
|
1212
|
+
var e_1, _a;
|
|
1213
|
+
var matches = template.matchAll(/{\w+}/g);
|
|
1214
|
+
var parameterNames = new Set();
|
|
1215
|
+
try {
|
|
1216
|
+
for (var matches_1 = __values(matches), matches_1_1 = matches_1.next(); !matches_1_1.done; matches_1_1 = matches_1.next()) {
|
|
1217
|
+
var match = matches_1_1.value;
|
|
1218
|
+
var parameterName = match[0].slice(1, -1);
|
|
1219
|
+
parameterNames.add(parameterName);
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1223
|
+
finally {
|
|
1224
|
+
try {
|
|
1225
|
+
if (matches_1_1 && !matches_1_1.done && (_a = matches_1.return)) _a.call(matches_1);
|
|
1226
|
+
}
|
|
1227
|
+
finally { if (e_1) throw e_1.error; }
|
|
1228
|
+
}
|
|
1229
|
+
return parameterNames;
|
|
1230
|
+
}
|
|
1231
|
+
/**
|
|
1232
|
+
* TODO: !!!!! Rename to extractParameterNames
|
|
1233
|
+
*/
|
|
1234
|
+
|
|
1179
1235
|
/**
|
|
1180
1236
|
* Unprepare just strips the preparation data of the pipeline
|
|
1181
1237
|
*/
|
|
@@ -1183,7 +1239,14 @@ function unpreparePipeline(pipeline) {
|
|
|
1183
1239
|
var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, promptTemplates = pipeline.promptTemplates;
|
|
1184
1240
|
personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
|
|
1185
1241
|
knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
|
|
1186
|
-
promptTemplates = promptTemplates.map(function (promptTemplate) {
|
|
1242
|
+
promptTemplates = promptTemplates.map(function (promptTemplate) {
|
|
1243
|
+
var dependentParameterNames = promptTemplate.dependentParameterNames;
|
|
1244
|
+
var parameterNames = extractParameterNames(promptTemplate.preparedContent || '');
|
|
1245
|
+
dependentParameterNames = dependentParameterNames.filter(function (dependentParameterName) { return !parameterNames.has(dependentParameterName); });
|
|
1246
|
+
var promptTemplateUnprepared = __assign(__assign({}, promptTemplate), { dependentParameterNames: dependentParameterNames });
|
|
1247
|
+
delete promptTemplateUnprepared.preparedContent;
|
|
1248
|
+
return promptTemplateUnprepared;
|
|
1249
|
+
});
|
|
1187
1250
|
return __assign(__assign({}, pipeline), { promptTemplates: promptTemplates, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] });
|
|
1188
1251
|
}
|
|
1189
1252
|
/**
|
|
@@ -1680,33 +1743,6 @@ function assertsExecutionSuccessful(executionResult) {
|
|
|
1680
1743
|
* TODO: [🧠] Can this return type be better typed than void
|
|
1681
1744
|
*/
|
|
1682
1745
|
|
|
1683
|
-
/**
|
|
1684
|
-
* Parses the template and returns the list of all parameter names
|
|
1685
|
-
*
|
|
1686
|
-
* @param template the template with parameters in {curly} braces
|
|
1687
|
-
* @returns the list of parameter names
|
|
1688
|
-
*/
|
|
1689
|
-
function extractParameters(template) {
|
|
1690
|
-
var e_1, _a;
|
|
1691
|
-
var matches = template.matchAll(/{\w+}/g);
|
|
1692
|
-
var parameterNames = new Set();
|
|
1693
|
-
try {
|
|
1694
|
-
for (var matches_1 = __values(matches), matches_1_1 = matches_1.next(); !matches_1_1.done; matches_1_1 = matches_1.next()) {
|
|
1695
|
-
var match = matches_1_1.value;
|
|
1696
|
-
var parameterName = match[0].slice(1, -1);
|
|
1697
|
-
parameterNames.add(parameterName);
|
|
1698
|
-
}
|
|
1699
|
-
}
|
|
1700
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1701
|
-
finally {
|
|
1702
|
-
try {
|
|
1703
|
-
if (matches_1_1 && !matches_1_1.done && (_a = matches_1.return)) _a.call(matches_1);
|
|
1704
|
-
}
|
|
1705
|
-
finally { if (e_1) throw e_1.error; }
|
|
1706
|
-
}
|
|
1707
|
-
return parameterNames;
|
|
1708
|
-
}
|
|
1709
|
-
|
|
1710
1746
|
/**
|
|
1711
1747
|
* Parses the given script and returns the list of all used variables that are not defined in the script
|
|
1712
1748
|
*
|
|
@@ -1762,12 +1798,12 @@ function extractVariables(script) {
|
|
|
1762
1798
|
* @returns the set of parameter names
|
|
1763
1799
|
* @throws {ParsingError} if the script is invalid
|
|
1764
1800
|
*/
|
|
1765
|
-
function
|
|
1801
|
+
function extractParameterNamesFromPromptTemplate(promptTemplate) {
|
|
1766
1802
|
var e_1, _a, e_2, _b, e_3, _c;
|
|
1767
|
-
var title = promptTemplate.title, description = promptTemplate.description, blockType = promptTemplate.blockType, content = promptTemplate.content, jokerParameterNames = promptTemplate.jokerParameterNames;
|
|
1803
|
+
var title = promptTemplate.title, description = promptTemplate.description, blockType = promptTemplate.blockType, content = promptTemplate.content, preparedContent = promptTemplate.preparedContent, jokerParameterNames = promptTemplate.jokerParameterNames;
|
|
1768
1804
|
var parameterNames = new Set();
|
|
1769
1805
|
try {
|
|
1770
|
-
for (var _d = __values(__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()) {
|
|
1771
1807
|
var parameterName = _e.value;
|
|
1772
1808
|
parameterNames.add(parameterName);
|
|
1773
1809
|
}
|
|
@@ -1807,6 +1843,8 @@ function extractParametersFromPromptTemplate(promptTemplate) {
|
|
|
1807
1843
|
}
|
|
1808
1844
|
finally { if (e_3) throw e_3.error; }
|
|
1809
1845
|
}
|
|
1846
|
+
parameterNames.delete('content');
|
|
1847
|
+
// <- Note {websiteContent} is used in `preparedContent`
|
|
1810
1848
|
return parameterNames;
|
|
1811
1849
|
}
|
|
1812
1850
|
/**
|
|
@@ -1976,7 +2014,14 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
|
|
|
1976
2014
|
throw errors[0];
|
|
1977
2015
|
}
|
|
1978
2016
|
else if (errors.length > 1) {
|
|
1979
|
-
throw new PipelineExecutionError(
|
|
2017
|
+
throw new PipelineExecutionError(
|
|
2018
|
+
// TODO: Tell which execution tools failed like
|
|
2019
|
+
// 1) OpenAI throw PipelineExecutionError: Parameter {knowledge} is not defined
|
|
2020
|
+
// 2) AnthropicClaude throw PipelineExecutionError: Parameter {knowledge} is not defined
|
|
2021
|
+
// 3) ...
|
|
2022
|
+
spaceTrim(function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors
|
|
2023
|
+
.map(function (error, i) { return "".concat(i + 1, ") **").concat(error.name || 'Error', ":** ").concat(error.message); })
|
|
2024
|
+
.join('\n')), "\n\n "); }));
|
|
1980
2025
|
}
|
|
1981
2026
|
else {
|
|
1982
2027
|
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n You have not provided any `LlmExecutionTools` that support model variant \"".concat(prompt.modelRequirements.modelVariant, "\n\n Available `LlmExecutionTools`:\n ").concat(block(_this.llmExecutionTools
|
|
@@ -2181,6 +2226,10 @@ function replaceParameters(template, parameters) {
|
|
|
2181
2226
|
if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
|
|
2182
2227
|
throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
|
|
2183
2228
|
}
|
|
2229
|
+
else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
|
|
2230
|
+
// TODO: [🍵]
|
|
2231
|
+
throw new UnexpectedError("Parameter {".concat(parameterName, "} is restricted to use"));
|
|
2232
|
+
}
|
|
2184
2233
|
}
|
|
2185
2234
|
}
|
|
2186
2235
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
@@ -2443,7 +2492,7 @@ function createPipelineExecutor(options) {
|
|
|
2443
2492
|
console.warn(spaceTrim$1("\n Pipeline ".concat(rawPipeline.pipelineUrl || rawPipeline.sourceFile || rawPipeline.title, " is not prepared\n\n ").concat(rawPipeline.sourceFile, "\n\n It will be prepared ad-hoc before the first execution\n But it is recommended to prepare the pipeline during collection preparation\n\n @see more at https://ptbk.io/prepare-pipeline\n ")));
|
|
2444
2493
|
}
|
|
2445
2494
|
var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
2446
|
-
// TODO:
|
|
2495
|
+
// TODO: !!! Extract to separate functions and files - ALL FUNCTIONS BELOW
|
|
2447
2496
|
function getContextForTemplate(// <- TODO: [🧠][🥜]
|
|
2448
2497
|
template) {
|
|
2449
2498
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -2494,6 +2543,7 @@ function createPipelineExecutor(options) {
|
|
|
2494
2543
|
currentDate = new Date().toISOString();
|
|
2495
2544
|
modelName = RESERVED_PARAMETER_MISSING_VALUE;
|
|
2496
2545
|
reservedParameters = {
|
|
2546
|
+
content: RESERVED_PARAMETER_RESTRICTED,
|
|
2497
2547
|
context: context,
|
|
2498
2548
|
knowledge: knowledge,
|
|
2499
2549
|
samples: samples,
|
|
@@ -2547,7 +2597,7 @@ function createPipelineExecutor(options) {
|
|
|
2547
2597
|
_u.sent();
|
|
2548
2598
|
_u.label = 2;
|
|
2549
2599
|
case 2:
|
|
2550
|
-
usedParameterNames =
|
|
2600
|
+
usedParameterNames = extractParameterNamesFromPromptTemplate(currentTemplate);
|
|
2551
2601
|
dependentParameterNames = new Set(currentTemplate.dependentParameterNames);
|
|
2552
2602
|
if (union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)).size !== 0) {
|
|
2553
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 ")));
|
|
@@ -2933,14 +2983,7 @@ function createPipelineExecutor(options) {
|
|
|
2933
2983
|
) {
|
|
2934
2984
|
// TODO: [🧠] Maybe put other blockTypes into report
|
|
2935
2985
|
executionReport.promptExecutions.push({
|
|
2936
|
-
prompt: {
|
|
2937
|
-
title: currentTemplate.title /* <- Note: If title in pipeline contains emojis, pass it innto report */,
|
|
2938
|
-
content: prompt.content,
|
|
2939
|
-
modelRequirements: prompt.modelRequirements,
|
|
2940
|
-
expectations: prompt.expectations,
|
|
2941
|
-
expectFormat: prompt.expectFormat,
|
|
2942
|
-
// <- Note: Do want to pass ONLY wanted information to the report
|
|
2943
|
-
},
|
|
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 }),
|
|
2944
2987
|
result: result || undefined,
|
|
2945
2988
|
error: expectError || undefined,
|
|
2946
2989
|
});
|
|
@@ -3204,6 +3247,8 @@ function createPipelineExecutor(options) {
|
|
|
3204
3247
|
return pipelineExecutor;
|
|
3205
3248
|
}
|
|
3206
3249
|
/**
|
|
3250
|
+
* TODO: !!!! return `preparedPipeline` from execution
|
|
3251
|
+
* TODO: !!!! `isNotPreparedWarningSupressed`
|
|
3207
3252
|
* TODO: Use isVerbose here (not only pass to `preparePipeline`)
|
|
3208
3253
|
* TODO: [🪂] Use maxParallelCount here (not only pass to `preparePipeline`)
|
|
3209
3254
|
* TODO: [♈] Probbably move expectations from templates to parameters
|
|
@@ -3218,7 +3263,7 @@ function createPipelineExecutor(options) {
|
|
|
3218
3263
|
/**
|
|
3219
3264
|
* @@@
|
|
3220
3265
|
*/
|
|
3221
|
-
function prepareKnowledgeFromMarkdown(
|
|
3266
|
+
function prepareKnowledgeFromMarkdown(knowledgeContent /* <- TODO: [🖖] (?maybe not) Always the file */, options) {
|
|
3222
3267
|
return __awaiter(this, void 0, void 0, function () {
|
|
3223
3268
|
var llmTools, _a, maxParallelCount, _b, isVerbose, collection, prepareKnowledgeFromMarkdownExecutor, _c, prepareTitleExecutor, _d, prepareKeywordsExecutor, _e, result, outputParameters, knowledgePiecesRaw, knowledgeTextPieces, knowledge;
|
|
3224
3269
|
var _f, _g, _h;
|
|
@@ -3256,7 +3301,7 @@ function prepareKnowledgeFromMarkdown(content /* <- TODO: [🖖] (?maybe not) Al
|
|
|
3256
3301
|
llm: llmTools,
|
|
3257
3302
|
},
|
|
3258
3303
|
_h)]);
|
|
3259
|
-
return [4 /*yield*/, prepareKnowledgeFromMarkdownExecutor({
|
|
3304
|
+
return [4 /*yield*/, prepareKnowledgeFromMarkdownExecutor({ knowledgeContent: knowledgeContent })];
|
|
3260
3305
|
case 4:
|
|
3261
3306
|
result = _j.sent();
|
|
3262
3307
|
assertsExecutionSuccessful(result);
|
|
@@ -3269,25 +3314,25 @@ function prepareKnowledgeFromMarkdown(content /* <- TODO: [🖖] (?maybe not) Al
|
|
|
3269
3314
|
return [4 /*yield*/, Promise.all(
|
|
3270
3315
|
// TODO: [🪂] !! Do not send all at once but in chunks
|
|
3271
3316
|
knowledgeTextPieces.map(function (knowledgeTextPiece, i) { return __awaiter(_this, void 0, void 0, function () {
|
|
3272
|
-
var name, title,
|
|
3317
|
+
var name, title, knowledgePieceContent, keywords, index, titleResult, _a, titleRaw, keywordsResult, _b, keywordsRaw, embeddingResult, error_1;
|
|
3273
3318
|
return __generator(this, function (_c) {
|
|
3274
3319
|
switch (_c.label) {
|
|
3275
3320
|
case 0:
|
|
3276
3321
|
name = "piece-".concat(i);
|
|
3277
3322
|
title = spaceTrim(knowledgeTextPiece.substring(0, 100));
|
|
3278
|
-
|
|
3323
|
+
knowledgePieceContent = spaceTrim(knowledgeTextPiece);
|
|
3279
3324
|
keywords = [];
|
|
3280
3325
|
index = [];
|
|
3281
3326
|
_c.label = 1;
|
|
3282
3327
|
case 1:
|
|
3283
3328
|
_c.trys.push([1, 7, , 8]);
|
|
3284
|
-
return [4 /*yield*/, prepareTitleExecutor({
|
|
3329
|
+
return [4 /*yield*/, prepareTitleExecutor({ knowledgePieceContent: knowledgePieceContent })];
|
|
3285
3330
|
case 2:
|
|
3286
3331
|
titleResult = _c.sent();
|
|
3287
3332
|
_a = titleResult.outputParameters.title, titleRaw = _a === void 0 ? 'Untitled' : _a;
|
|
3288
3333
|
title = spaceTrim(titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
3289
3334
|
name = titleToName(title);
|
|
3290
|
-
return [4 /*yield*/, prepareKeywordsExecutor({
|
|
3335
|
+
return [4 /*yield*/, prepareKeywordsExecutor({ knowledgePieceContent: knowledgePieceContent })];
|
|
3291
3336
|
case 3:
|
|
3292
3337
|
keywordsResult = _c.sent();
|
|
3293
3338
|
_b = keywordsResult.outputParameters.keywords, keywordsRaw = _b === void 0 ? '' : _b;
|
|
@@ -3305,7 +3350,7 @@ function prepareKnowledgeFromMarkdown(content /* <- TODO: [🖖] (?maybe not) Al
|
|
|
3305
3350
|
case 4: return [4 /*yield*/, llmTools.callEmbeddingModel({
|
|
3306
3351
|
title: "Embedding for ".concat(title) /* <- Note: No impact on embedding result itself, just for logging */,
|
|
3307
3352
|
parameters: {},
|
|
3308
|
-
content:
|
|
3353
|
+
content: knowledgePieceContent,
|
|
3309
3354
|
modelRequirements: {
|
|
3310
3355
|
modelVariant: 'EMBEDDING',
|
|
3311
3356
|
},
|
|
@@ -3326,7 +3371,7 @@ function prepareKnowledgeFromMarkdown(content /* <- TODO: [🖖] (?maybe not) Al
|
|
|
3326
3371
|
case 8: return [2 /*return*/, {
|
|
3327
3372
|
name: name,
|
|
3328
3373
|
title: title,
|
|
3329
|
-
content:
|
|
3374
|
+
content: knowledgePieceContent,
|
|
3330
3375
|
keywords: keywords,
|
|
3331
3376
|
index: index,
|
|
3332
3377
|
// <- TODO: [☀] sources,
|
|
@@ -3492,14 +3537,18 @@ function prepareTemplates(pipeline, options) {
|
|
|
3492
3537
|
TODO_USE(parameters);
|
|
3493
3538
|
promptTemplatesPrepared = new Array(promptTemplates.length);
|
|
3494
3539
|
return [4 /*yield*/, forEachAsync(promptTemplates, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (template, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
3495
|
-
var preparedContent, preparedTemplate;
|
|
3540
|
+
var dependentParameterNames, preparedContent, preparedTemplate;
|
|
3496
3541
|
return __generator(this, function (_a) {
|
|
3542
|
+
dependentParameterNames = template.dependentParameterNames;
|
|
3497
3543
|
preparedContent = undefined;
|
|
3498
|
-
if (knowledgePiecesCount > 0) {
|
|
3544
|
+
if (knowledgePiecesCount > 0 && !dependentParameterNames.includes('knowledge')) {
|
|
3499
3545
|
preparedContent = spaceTrim$1("\n {content}\n\n ## Knowledge\n\n {knowledge}\n ");
|
|
3500
3546
|
// <- TODO: [🧠][🧻] Cutomize shape/language/formatting of the addition to the prompt
|
|
3547
|
+
dependentParameterNames = __spreadArray(__spreadArray([], __read(dependentParameterNames), false), [
|
|
3548
|
+
'knowledge',
|
|
3549
|
+
], false);
|
|
3501
3550
|
}
|
|
3502
|
-
preparedTemplate = __assign(__assign({}, template), { preparedContent: preparedContent });
|
|
3551
|
+
preparedTemplate = __assign(__assign({}, template), { dependentParameterNames: dependentParameterNames, preparedContent: preparedContent });
|
|
3503
3552
|
promptTemplatesPrepared[index] = preparedTemplate;
|
|
3504
3553
|
return [2 /*return*/];
|
|
3505
3554
|
});
|
|
@@ -4315,7 +4364,7 @@ var parameterCommandParser = {
|
|
|
4315
4364
|
/**
|
|
4316
4365
|
* Example usages of the PARAMETER command
|
|
4317
4366
|
*/
|
|
4318
|
-
examples: ['PARAMETER {title} Title of the book', 'OUTPUT PARAMETER {
|
|
4367
|
+
examples: ['PARAMETER {title} Title of the book', 'OUTPUT PARAMETER {websiteContent} Content of the book'],
|
|
4319
4368
|
/**
|
|
4320
4369
|
* Parses the PARAMETER command
|
|
4321
4370
|
*/
|
|
@@ -4414,11 +4463,8 @@ var promptbookVersionCommandParser = {
|
|
|
4414
4463
|
/**
|
|
4415
4464
|
* Name of the command
|
|
4416
4465
|
*/
|
|
4417
|
-
name: '
|
|
4418
|
-
|
|
4419
|
-
Note: [📇] No need to put here "PROMPTBOOK" alias here
|
|
4420
|
-
aliasNames: ['PROMPTBOOK_VERSION'],
|
|
4421
|
-
*/
|
|
4466
|
+
name: 'PROMPTBOOK_VERSION',
|
|
4467
|
+
aliasNames: ['PTBK_VERSION', 'PTBK_V', 'PTBKV'],
|
|
4422
4468
|
/**
|
|
4423
4469
|
* BOILERPLATE command can be used in:
|
|
4424
4470
|
*/
|
|
@@ -4434,7 +4480,7 @@ var promptbookVersionCommandParser = {
|
|
|
4434
4480
|
/**
|
|
4435
4481
|
* Example usages of the PROMPTBOOK_VERSION command
|
|
4436
4482
|
*/
|
|
4437
|
-
examples: ["PROMPTBOOK VERSION ".concat(PROMPTBOOK_VERSION), "
|
|
4483
|
+
examples: ["PROMPTBOOK VERSION ".concat(PROMPTBOOK_VERSION), "PTBKV ".concat(PROMPTBOOK_VERSION)],
|
|
4438
4484
|
/**
|
|
4439
4485
|
* Parses the PROMPTBOOK_VERSION command
|
|
4440
4486
|
*/
|
|
@@ -4468,8 +4514,9 @@ var urlCommandParser = {
|
|
|
4468
4514
|
* Name of the command
|
|
4469
4515
|
*/
|
|
4470
4516
|
name: 'URL',
|
|
4517
|
+
aliasNames: ['PIPELINE_URL'],
|
|
4471
4518
|
/*
|
|
4472
|
-
Note: [🛵] No need for alias name because it is already preprocessed
|
|
4519
|
+
Note: [🛵] No need for this alias name because it is already preprocessed
|
|
4473
4520
|
aliasNames: ['HTTPS'],
|
|
4474
4521
|
*/
|
|
4475
4522
|
/**
|
|
@@ -4488,6 +4535,7 @@ var urlCommandParser = {
|
|
|
4488
4535
|
* Example usages of the URL command
|
|
4489
4536
|
*/
|
|
4490
4537
|
examples: [
|
|
4538
|
+
'PIPELINE URL https://promptbook.studio/library/write-cv.ptbk.md',
|
|
4491
4539
|
'URL https://promptbook.studio/library/write-cv.ptbk.md',
|
|
4492
4540
|
'https://promptbook.studio/library/write-cv.ptbk.md',
|
|
4493
4541
|
],
|
|
@@ -4726,10 +4774,6 @@ function parseCommand(raw, usagePlace) {
|
|
|
4726
4774
|
.split(' ')
|
|
4727
4775
|
.map(function (part) { return part.trim(); })
|
|
4728
4776
|
.filter(function (item) { return item !== ''; })
|
|
4729
|
-
// Note: [📇]:
|
|
4730
|
-
.filter(function (item) { return !/^PTBK$/i.test(item); })
|
|
4731
|
-
.filter(function (item) { return !/^PIPELINE$/i.test(item); })
|
|
4732
|
-
.filter(function (item) { return !/^PROMPTBOOK$/i.test(item); })
|
|
4733
4777
|
.map(removeMarkdownFormatting)
|
|
4734
4778
|
.map(function (item) { return item.trim(); });
|
|
4735
4779
|
if (items.length === 0 || items[0] === '') {
|
|
@@ -5444,7 +5488,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
5444
5488
|
if (templateModelRequirements.modelVariant === undefined) {
|
|
5445
5489
|
templateModelRequirements.modelVariant = 'CHAT';
|
|
5446
5490
|
}
|
|
5447
|
-
templateJson.dependentParameterNames = Array.from(
|
|
5491
|
+
templateJson.dependentParameterNames = Array.from(extractParameterNamesFromPromptTemplate(templateJson));
|
|
5448
5492
|
// TODO: [🍧][❔] Remove this condition - modelRequirements should be put here via BLOCK command not removed when PROMPT_TEMPLATE
|
|
5449
5493
|
if (templateJson.blockType !== 'PROMPT_TEMPLATE') {
|
|
5450
5494
|
delete templateJson.modelRequirements;
|