@promptbook/node 0.75.0-2 → 0.75.0-4
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 +27 -17
- package/esm/index.es.js +178 -104
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +10 -4
- package/esm/typings/src/_packages/types.index.d.ts +8 -6
- package/esm/typings/src/commands/EXPECT/ExpectCommand.d.ts +1 -1
- package/esm/typings/src/commands/SECTION/SectionCommand.d.ts +1 -1
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +0 -2
- package/esm/typings/src/config.d.ts +9 -2
- package/esm/typings/src/conversion/pipelineJsonToString.d.ts +1 -1
- package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +2 -2
- package/esm/typings/src/conversion/utils/extractParameterNamesFromTask.d.ts +3 -3
- package/esm/typings/src/conversion/utils/renameParameter.d.ts +2 -2
- package/esm/typings/src/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +1 -1
- package/esm/typings/src/execution/ScriptExecutionTools.d.ts +1 -1
- package/esm/typings/src/formfactors/_boilerplate/BoilerplateFormfactorDefinition.d.ts +2 -2
- package/esm/typings/src/formfactors/_common/AbstractFormfactorDefinition.d.ts +3 -0
- package/esm/typings/src/formfactors/chatbot/ChatbotFormfactorDefinition.d.ts +32 -2
- package/esm/typings/src/formfactors/generator/GeneratorFormfactorDefinition.d.ts +14 -0
- package/esm/typings/src/formfactors/generic/GenericFormfactorDefinition.d.ts +2 -2
- package/esm/typings/src/formfactors/index.d.ts +72 -10
- package/esm/typings/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +2 -2
- package/esm/typings/src/formfactors/sheets/SheetsFormfactorDefinition.d.ts +12 -2
- package/esm/typings/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +12 -2
- package/esm/typings/src/pipeline/PipelineInterface/PipelineInterface.d.ts +5 -4
- package/esm/typings/src/pipeline/PipelineInterface/constants.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineJson/{TaskJsonCommon.d.ts → CommonTaskJson.d.ts} +13 -13
- package/esm/typings/src/pipeline/PipelineJson/DialogTaskJson.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineJson/ParameterJson.d.ts +2 -0
- package/esm/typings/src/pipeline/PipelineJson/PersonaJson.d.ts +1 -1
- package/esm/typings/src/pipeline/PipelineJson/PipelineJson.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineJson/PromptTaskJson.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineJson/ScriptTaskJson.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineJson/SimpleTaskJson.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineJson/TaskJson.d.ts +1 -1
- package/esm/typings/src/pipeline/PipelineString.d.ts +1 -1
- package/esm/typings/src/prepare/isPipelinePrepared.d.ts +1 -1
- package/esm/typings/src/prepare/prepareTasks.d.ts +5 -5
- package/esm/typings/src/types/Prompt.d.ts +3 -3
- package/esm/typings/src/types/SectionType.d.ts +21 -0
- package/esm/typings/src/types/TaskProgress.d.ts +1 -1
- package/esm/typings/src/types/TaskType.d.ts +15 -0
- package/esm/typings/src/types/typeAliases.d.ts +1 -1
- package/esm/typings/src/utils/organization/TODO_remove_as.d.ts +6 -0
- package/esm/typings/src/utils/parameters/extractParameterNames.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +178 -104
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/commands/SECTION/SectionType.d.ts +0 -13
- /package/esm/typings/{promptbook-collection → books}/index.d.ts +0 -0
package/esm/index.es.js
CHANGED
|
@@ -26,7 +26,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
26
26
|
*
|
|
27
27
|
* @see https://github.com/webgptorg/promptbook
|
|
28
28
|
*/
|
|
29
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.75.0-
|
|
29
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.75.0-3';
|
|
30
30
|
/**
|
|
31
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
32
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -549,7 +549,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
549
549
|
return isInput;
|
|
550
550
|
})), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
551
551
|
var parameter = _h.value;
|
|
552
|
-
commands.push("INPUT PARAMETER ".concat(
|
|
552
|
+
commands.push("INPUT PARAMETER ".concat(taskParameterJsonToString(parameter)));
|
|
553
553
|
}
|
|
554
554
|
}
|
|
555
555
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
@@ -565,7 +565,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
565
565
|
return isOutput;
|
|
566
566
|
})), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
567
567
|
var parameter = _k.value;
|
|
568
|
-
commands.push("OUTPUT PARAMETER ".concat(
|
|
568
|
+
commands.push("OUTPUT PARAMETER ".concat(taskParameterJsonToString(parameter)));
|
|
569
569
|
}
|
|
570
570
|
}
|
|
571
571
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
@@ -579,12 +579,12 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
579
579
|
pipelineString += commands.map(function (command) { return "- ".concat(command); }).join('\n');
|
|
580
580
|
try {
|
|
581
581
|
for (var tasks_1 = __values(tasks), tasks_1_1 = tasks_1.next(); !tasks_1_1.done; tasks_1_1 = tasks_1.next()) {
|
|
582
|
-
var
|
|
582
|
+
var task = tasks_1_1.value;
|
|
583
583
|
var
|
|
584
584
|
/* Note: Not using:> name, */
|
|
585
|
-
title_1 =
|
|
585
|
+
title_1 = task.title, description_1 = task.description,
|
|
586
586
|
/* Note: dependentParameterNames, */
|
|
587
|
-
jokers =
|
|
587
|
+
jokers = task.jokerParameterNames, taskType = task.taskType, content = task.content, postprocessing = task.postprocessingFunctionNames, expectations = task.expectations, format = task.format, resultingParameterName = task.resultingParameterName;
|
|
588
588
|
pipelineString += '\n\n';
|
|
589
589
|
pipelineString += "## ".concat(title_1);
|
|
590
590
|
if (description_1) {
|
|
@@ -594,9 +594,10 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
594
594
|
var commands_1 = [];
|
|
595
595
|
var contentLanguage = 'text';
|
|
596
596
|
if (taskType === 'PROMPT_TASK') {
|
|
597
|
-
var modelRequirements =
|
|
597
|
+
var modelRequirements = task.modelRequirements;
|
|
598
598
|
var _l = modelRequirements || {}, modelName = _l.modelName, modelVariant = _l.modelVariant;
|
|
599
|
-
|
|
599
|
+
// Note: Do nothing, it is default
|
|
600
|
+
// commands.push(`PROMPT`);
|
|
600
601
|
if (modelVariant) {
|
|
601
602
|
commands_1.push("MODEL VARIANT ".concat(capitalize(modelVariant)));
|
|
602
603
|
}
|
|
@@ -609,16 +610,16 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
609
610
|
// Note: Nothing special here
|
|
610
611
|
}
|
|
611
612
|
else if (taskType === 'SCRIPT_TASK') {
|
|
612
|
-
commands_1.push("SCRIPT
|
|
613
|
-
if (
|
|
614
|
-
contentLanguage =
|
|
613
|
+
commands_1.push("SCRIPT");
|
|
614
|
+
if (task.contentLanguage) {
|
|
615
|
+
contentLanguage = task.contentLanguage;
|
|
615
616
|
}
|
|
616
617
|
else {
|
|
617
618
|
contentLanguage = '';
|
|
618
619
|
}
|
|
619
620
|
}
|
|
620
621
|
else if (taskType === 'DIALOG_TASK') {
|
|
621
|
-
commands_1.push("DIALOG
|
|
622
|
+
commands_1.push("DIALOG");
|
|
622
623
|
// Note: Nothing special here
|
|
623
624
|
} // <- }else if([🅱]
|
|
624
625
|
if (jokers) {
|
|
@@ -693,7 +694,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
693
694
|
pipelineString += '\n';
|
|
694
695
|
pipelineString += '```';
|
|
695
696
|
pipelineString += '\n\n';
|
|
696
|
-
pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!! If the parameter here has description, add it and use
|
|
697
|
+
pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!! If the parameter here has description, add it and use taskParameterJsonToString
|
|
697
698
|
}
|
|
698
699
|
}
|
|
699
700
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
@@ -708,8 +709,8 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
708
709
|
/**
|
|
709
710
|
* @private internal utility of `pipelineJsonToString`
|
|
710
711
|
*/
|
|
711
|
-
function
|
|
712
|
-
var name =
|
|
712
|
+
function taskParameterJsonToString(taskParameterJson) {
|
|
713
|
+
var name = taskParameterJson.name, description = taskParameterJson.description;
|
|
713
714
|
var parameterString = "{".concat(name, "}");
|
|
714
715
|
if (description) {
|
|
715
716
|
parameterString = "".concat(parameterString, " ").concat(description);
|
|
@@ -717,7 +718,7 @@ function templateParameterJsonToString(templateParameterJson) {
|
|
|
717
718
|
return parameterString;
|
|
718
719
|
}
|
|
719
720
|
/**
|
|
720
|
-
* TODO: [🛋] Implement new features and commands into `pipelineJsonToString` + `
|
|
721
|
+
* TODO: [🛋] Implement new features and commands into `pipelineJsonToString` + `taskParameterJsonToString` , use `stringifyCommand`
|
|
721
722
|
* TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
|
|
722
723
|
* TODO: [🏛] Maybe make some markdown builder
|
|
723
724
|
* TODO: [🏛] Escape all
|
|
@@ -1362,7 +1363,7 @@ function joinLlmExecutionTools() {
|
|
|
1362
1363
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
1363
1364
|
*/
|
|
1364
1365
|
|
|
1365
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",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}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./
|
|
1366
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",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}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-knowledge-from-markdown.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",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}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-knowledge-keywords.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",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}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-knowledge-title.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.md",formfactorName:"GENERIC",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}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\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}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-persona.book.md"}];
|
|
1366
1367
|
|
|
1367
1368
|
/**
|
|
1368
1369
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -1755,20 +1756,20 @@ function validatePipelineCore(pipeline) {
|
|
|
1755
1756
|
}
|
|
1756
1757
|
finally { if (e_3) throw e_3.error; }
|
|
1757
1758
|
}
|
|
1758
|
-
var
|
|
1759
|
+
var unresovedTasks = __spreadArray([], __read(pipeline.tasks), false);
|
|
1759
1760
|
var loopLimit = LOOP_LIMIT;
|
|
1760
1761
|
var _loop_3 = function () {
|
|
1761
1762
|
if (loopLimit-- < 0) {
|
|
1762
1763
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
1763
1764
|
throw new UnexpectedError(spaceTrim(function (block) { return "\n Loop limit reached during detection of circular dependencies in `validatePipeline`\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
1764
1765
|
}
|
|
1765
|
-
var
|
|
1766
|
+
var currentlyResovedTasks = unresovedTasks.filter(function (task) {
|
|
1766
1767
|
return task.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
|
|
1767
1768
|
});
|
|
1768
|
-
if (
|
|
1769
|
+
if (currentlyResovedTasks.length === 0) {
|
|
1769
1770
|
throw new PipelineLogicError(
|
|
1770
1771
|
// TODO: [🐎] DRY
|
|
1771
|
-
spaceTrim(function (block) { return "\n\n Can not resolve some parameters:\n Either you are using a parameter that is not defined, or there are some circular dependencies.\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(
|
|
1772
|
+
spaceTrim(function (block) { return "\n\n Can not resolve some parameters:\n Either you are using a parameter that is not defined, or there are some circular dependencies.\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTasks
|
|
1772
1773
|
.map(function (_a) {
|
|
1773
1774
|
var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
|
|
1774
1775
|
return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
|
|
@@ -1787,13 +1788,13 @@ function validatePipelineCore(pipeline) {
|
|
|
1787
1788
|
.map(function (name) { return "- Parameter `{".concat(name, "}`"); })
|
|
1788
1789
|
.join('\n')), "\n\n\n "); }));
|
|
1789
1790
|
}
|
|
1790
|
-
resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(
|
|
1791
|
+
resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTasks.map(function (_a) {
|
|
1791
1792
|
var resultingParameterName = _a.resultingParameterName;
|
|
1792
1793
|
return resultingParameterName;
|
|
1793
1794
|
})), false);
|
|
1794
|
-
|
|
1795
|
+
unresovedTasks = unresovedTasks.filter(function (task) { return !currentlyResovedTasks.includes(task); });
|
|
1795
1796
|
};
|
|
1796
|
-
while (
|
|
1797
|
+
while (unresovedTasks.length > 0) {
|
|
1797
1798
|
_loop_3();
|
|
1798
1799
|
}
|
|
1799
1800
|
// TODO: !!!!!! Test that pipeline interface implements declared formfactor interface
|
|
@@ -1855,7 +1856,7 @@ var PipelineUrlError = /** @class */ (function (_super) {
|
|
|
1855
1856
|
/**
|
|
1856
1857
|
* Parses the task and returns the list of all parameter names
|
|
1857
1858
|
*
|
|
1858
|
-
* @param template the
|
|
1859
|
+
* @param template the string template with parameters in {curly} braces
|
|
1859
1860
|
* @returns the list of parameter names
|
|
1860
1861
|
* @public exported from `@promptbook/utils`
|
|
1861
1862
|
*/
|
|
@@ -1889,13 +1890,13 @@ function unpreparePipeline(pipeline) {
|
|
|
1889
1890
|
var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, tasks = pipeline.tasks;
|
|
1890
1891
|
personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
|
|
1891
1892
|
knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
|
|
1892
|
-
tasks = tasks.map(function (
|
|
1893
|
-
var dependentParameterNames =
|
|
1894
|
-
var parameterNames = extractParameterNames(
|
|
1893
|
+
tasks = tasks.map(function (task) {
|
|
1894
|
+
var dependentParameterNames = task.dependentParameterNames;
|
|
1895
|
+
var parameterNames = extractParameterNames(task.preparedContent || '');
|
|
1895
1896
|
dependentParameterNames = dependentParameterNames.filter(function (dependentParameterName) { return !parameterNames.has(dependentParameterName); });
|
|
1896
|
-
var
|
|
1897
|
-
delete
|
|
1898
|
-
return
|
|
1897
|
+
var taskUnprepared = __assign(__assign({}, task), { dependentParameterNames: dependentParameterNames });
|
|
1898
|
+
delete taskUnprepared.preparedContent;
|
|
1899
|
+
return taskUnprepared;
|
|
1899
1900
|
});
|
|
1900
1901
|
return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), { tasks: tasks, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }));
|
|
1901
1902
|
}
|
|
@@ -2188,7 +2189,7 @@ function isPipelinePrepared(pipeline) {
|
|
|
2188
2189
|
* TODO: [🐠] Maybe base this on `makeValidator`
|
|
2189
2190
|
* TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
|
|
2190
2191
|
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
2191
|
-
* - [🏍] ? Is context in each
|
|
2192
|
+
* - [🏍] ? Is context in each task
|
|
2192
2193
|
* - [♨] Are examples prepared
|
|
2193
2194
|
* - [♨] Are tasks prepared
|
|
2194
2195
|
*/
|
|
@@ -2260,16 +2261,16 @@ function extractVariables(script) {
|
|
|
2260
2261
|
*/
|
|
2261
2262
|
|
|
2262
2263
|
/**
|
|
2263
|
-
* Parses the
|
|
2264
|
+
* Parses the task and returns the set of all used parameters
|
|
2264
2265
|
*
|
|
2265
|
-
* @param
|
|
2266
|
+
* @param task the task with used parameters
|
|
2266
2267
|
* @returns the set of parameter names
|
|
2267
2268
|
* @throws {ParseError} if the script is invalid
|
|
2268
2269
|
* @public exported from `@promptbook/utils`
|
|
2269
2270
|
*/
|
|
2270
|
-
function extractParameterNamesFromTask(
|
|
2271
|
+
function extractParameterNamesFromTask(task) {
|
|
2271
2272
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
2272
|
-
var title =
|
|
2273
|
+
var title = task.title, description = task.description, taskType = task.taskType, content = task.content, preparedContent = task.preparedContent, jokerParameterNames = task.jokerParameterNames, foreach = task.foreach;
|
|
2273
2274
|
var parameterNames = new Set();
|
|
2274
2275
|
try {
|
|
2275
2276
|
for (var _e = __values(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(extractParameterNames(title)), false), __read(extractParameterNames(description || '')), false), __read(extractParameterNames(content)), false), __read(extractParameterNames(preparedContent || '')), false)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
@@ -5314,10 +5315,10 @@ function prepareTasks(pipeline, tools, options) {
|
|
|
5314
5315
|
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
|
|
5315
5316
|
tasks = pipeline.tasks, pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
|
|
5316
5317
|
tasksPrepared = new Array(tasks.length);
|
|
5317
|
-
return [4 /*yield*/, forEachAsync(tasks, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (
|
|
5318
|
-
var dependentParameterNames, preparedContent,
|
|
5318
|
+
return [4 /*yield*/, forEachAsync(tasks, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (task, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
5319
|
+
var dependentParameterNames, preparedContent, preparedTask;
|
|
5319
5320
|
return __generator(this, function (_a) {
|
|
5320
|
-
dependentParameterNames =
|
|
5321
|
+
dependentParameterNames = task.dependentParameterNames;
|
|
5321
5322
|
preparedContent = undefined;
|
|
5322
5323
|
if (knowledgePiecesCount > 0 && !dependentParameterNames.includes('knowledge')) {
|
|
5323
5324
|
preparedContent = spaceTrim("\n {content}\n\n ## Knowledge\n\n {knowledge}\n ");
|
|
@@ -5326,8 +5327,8 @@ function prepareTasks(pipeline, tools, options) {
|
|
|
5326
5327
|
'knowledge',
|
|
5327
5328
|
], false);
|
|
5328
5329
|
}
|
|
5329
|
-
|
|
5330
|
-
tasksPrepared[index] =
|
|
5330
|
+
preparedTask = __assign(__assign({}, task), { dependentParameterNames: dependentParameterNames, preparedContent: preparedContent });
|
|
5331
|
+
tasksPrepared[index] = preparedTask;
|
|
5331
5332
|
return [2 /*return*/];
|
|
5332
5333
|
});
|
|
5333
5334
|
}); })];
|
|
@@ -5339,8 +5340,8 @@ function prepareTasks(pipeline, tools, options) {
|
|
|
5339
5340
|
});
|
|
5340
5341
|
}
|
|
5341
5342
|
/**
|
|
5342
|
-
* TODO: [🧠] Add context to each
|
|
5343
|
-
* TODO: [🧠] What is better name `
|
|
5343
|
+
* TODO: [🧠] Add context to each task (if missing)
|
|
5344
|
+
* TODO: [🧠] What is better name `prepareTask` or `prepareTaskAndParameters`
|
|
5344
5345
|
* TODO: [♨][main] !!! Prepare index the examples and maybe tasks
|
|
5345
5346
|
* TODO: Write tests for `preparePipeline`
|
|
5346
5347
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
@@ -5426,7 +5427,7 @@ function preparePipeline(pipeline, tools, options) {
|
|
|
5426
5427
|
})];
|
|
5427
5428
|
case 3:
|
|
5428
5429
|
tasksPrepared = (_c.sent()).tasksPrepared;
|
|
5429
|
-
// ----- /
|
|
5430
|
+
// ----- /Tasks preparation -----
|
|
5430
5431
|
// Note: Count total usage
|
|
5431
5432
|
currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
|
|
5432
5433
|
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { tasks: __spreadArray([], __read(tasksPrepared), false),
|
|
@@ -5445,6 +5446,40 @@ function preparePipeline(pipeline, tools, options) {
|
|
|
5445
5446
|
* @see https://docs.anthropic.com/en/docs/test-and-evaluate/strengthen-guardrails/increase-consistency#specify-the-desired-output-format
|
|
5446
5447
|
*/
|
|
5447
5448
|
|
|
5449
|
+
/**
|
|
5450
|
+
* All available task types
|
|
5451
|
+
*
|
|
5452
|
+
* There is is distinction between task types and section types
|
|
5453
|
+
* - Every section in markdown has its SectionType
|
|
5454
|
+
* - Some sections are tasks but other can be non-task sections
|
|
5455
|
+
*
|
|
5456
|
+
* @public exported from `@promptbook/core`
|
|
5457
|
+
*/
|
|
5458
|
+
var TaskTypes = [
|
|
5459
|
+
'PROMPT',
|
|
5460
|
+
'SIMPLE',
|
|
5461
|
+
'SCRIPT',
|
|
5462
|
+
'DIALOG',
|
|
5463
|
+
// <- [🅱]
|
|
5464
|
+
];
|
|
5465
|
+
|
|
5466
|
+
/**
|
|
5467
|
+
* All available sections which are not tasks
|
|
5468
|
+
*
|
|
5469
|
+
* @public exported from `@promptbook/core`
|
|
5470
|
+
*/
|
|
5471
|
+
var NonTaskSectionTypes = ['EXAMPLE', 'KNOWLEDGE', 'INSTRUMENT', 'ACTION'];
|
|
5472
|
+
/**
|
|
5473
|
+
* All available section types
|
|
5474
|
+
*
|
|
5475
|
+
* There is is distinction between task types and section types
|
|
5476
|
+
* - Every section in markdown has its SectionType
|
|
5477
|
+
* - Some sections are tasks but other can be non-task sections
|
|
5478
|
+
*
|
|
5479
|
+
* @public exported from `@promptbook/core`
|
|
5480
|
+
*/
|
|
5481
|
+
var SectionTypes = __spreadArray(__spreadArray([], __read(TaskTypes.map(function (TaskType) { return "".concat(TaskType, "_TASK"); })), false), __read(NonTaskSectionTypes), false);
|
|
5482
|
+
|
|
5448
5483
|
/**
|
|
5449
5484
|
* Parses the knowledge command
|
|
5450
5485
|
*
|
|
@@ -5537,24 +5572,6 @@ var knowledgeCommandParser = {
|
|
|
5537
5572
|
* Note: [⛱] There are two types of KNOWLEDGE commands *...(read more in [⛱])*
|
|
5538
5573
|
*/
|
|
5539
5574
|
|
|
5540
|
-
/**
|
|
5541
|
-
* Section type describes the way how the section is sectiond
|
|
5542
|
-
*
|
|
5543
|
-
* @public exported from `@promptbook/core`
|
|
5544
|
-
*/
|
|
5545
|
-
var SectionTypes = [
|
|
5546
|
-
'PROMPT_TASK',
|
|
5547
|
-
'SIMPLE_TASK',
|
|
5548
|
-
'SCRIPT_TASK',
|
|
5549
|
-
'DIALOG_TASK',
|
|
5550
|
-
'EXAMPLE',
|
|
5551
|
-
'KNOWLEDGE',
|
|
5552
|
-
'INSTRUMENT',
|
|
5553
|
-
'ACTION',
|
|
5554
|
-
// <- [🅱]
|
|
5555
|
-
];
|
|
5556
|
-
// <- TODO: !!!!!! Make alongside `SectionType` the `TaskType`, `TaskType` + [⛱] and ACRY
|
|
5557
|
-
|
|
5558
5575
|
/**
|
|
5559
5576
|
* Parses the section command
|
|
5560
5577
|
*
|
|
@@ -5642,7 +5659,10 @@ var sectionCommandParser = {
|
|
|
5642
5659
|
var normalized = input.normalized;
|
|
5643
5660
|
normalized = normalized.split('SAMPLE').join('EXAMPLE');
|
|
5644
5661
|
normalized = normalized.split('EXECUTE_').join('');
|
|
5645
|
-
|
|
5662
|
+
normalized = normalized.split('DIALOGUE').join('DIALOG');
|
|
5663
|
+
var taskTypes = SectionTypes.filter(function (sectionType) {
|
|
5664
|
+
return normalized.includes(sectionType.split('_TASK').join(''));
|
|
5665
|
+
});
|
|
5646
5666
|
if (taskTypes.length !== 1) {
|
|
5647
5667
|
throw new ParseError(spaceTrim$1(function (block) { return "\n Unknown section type \"".concat(normalized, "\"\n\n Supported section types are:\n ").concat(block(SectionTypes.join(', ')), "\n "); }));
|
|
5648
5668
|
}
|
|
@@ -6001,7 +6021,7 @@ var expectCommandParser = {
|
|
|
6001
6021
|
/**
|
|
6002
6022
|
* Description of the FORMAT command
|
|
6003
6023
|
*/
|
|
6004
|
-
description: spaceTrim$1("\n Expect command describes the desired output of the
|
|
6024
|
+
description: spaceTrim$1("\n Expect command describes the desired output of the task *(after post-processing)*\n It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.\n "),
|
|
6005
6025
|
/**
|
|
6006
6026
|
* Link to documentation
|
|
6007
6027
|
*/
|
|
@@ -6487,7 +6507,7 @@ var formatCommandParser = {
|
|
|
6487
6507
|
/**
|
|
6488
6508
|
* Description of the FORMAT command
|
|
6489
6509
|
*/
|
|
6490
|
-
description: spaceTrim$1("\n Format command describes the desired output of the
|
|
6510
|
+
description: spaceTrim$1("\n Format command describes the desired output of the task (after post-processing)\n It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.\n "),
|
|
6491
6511
|
/**
|
|
6492
6512
|
* Link to documentation
|
|
6493
6513
|
*/
|
|
@@ -6551,19 +6571,45 @@ var ChatbotFormfactorDefinition = {
|
|
|
6551
6571
|
description: "@@@",
|
|
6552
6572
|
documentationUrl: "https://github.com/webgptorg/promptbook/discussions/174",
|
|
6553
6573
|
pipelineInterface: {
|
|
6554
|
-
|
|
6555
|
-
|
|
6556
|
-
|
|
6557
|
-
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6574
|
+
inputParameters: [
|
|
6575
|
+
{
|
|
6576
|
+
name: 'previousTitle',
|
|
6577
|
+
description: "Previous title of the conversation",
|
|
6578
|
+
isInput: true,
|
|
6579
|
+
isOutput: false,
|
|
6580
|
+
},
|
|
6581
|
+
{
|
|
6582
|
+
name: 'previousConversationSummary',
|
|
6583
|
+
description: "Previous conversation summary",
|
|
6584
|
+
isInput: true,
|
|
6585
|
+
isOutput: false,
|
|
6586
|
+
},
|
|
6587
|
+
{ name: 'userMessage', description: "User message", isInput: true, isOutput: false },
|
|
6588
|
+
],
|
|
6589
|
+
outputParameters: [
|
|
6590
|
+
{ name: 'title', description: "Title of the conversation", isInput: false, isOutput: true },
|
|
6591
|
+
{ name: 'conversationSummary', description: "Summary of the conversation", isInput: false, isOutput: true },
|
|
6592
|
+
{ name: 'chatbotResponse', description: "Chatbot response", isInput: false, isOutput: true },
|
|
6593
|
+
],
|
|
6594
|
+
},
|
|
6595
|
+
};
|
|
6565
6596
|
|
|
6566
|
-
|
|
6597
|
+
/**
|
|
6598
|
+
* Generator is form of app that @@@
|
|
6599
|
+
*
|
|
6600
|
+
* @public exported from `@promptbook/core`
|
|
6601
|
+
*/
|
|
6602
|
+
var GeneratorFormfactorDefinition = {
|
|
6603
|
+
name: 'GENERATOR',
|
|
6604
|
+
description: "@@@",
|
|
6605
|
+
documentationUrl: "https://github.com/webgptorg/promptbook/discussions/184",
|
|
6606
|
+
pipelineInterface: {
|
|
6607
|
+
inputParameters: [
|
|
6608
|
+
/* @@@ */
|
|
6609
|
+
],
|
|
6610
|
+
outputParameters: [
|
|
6611
|
+
/* @@@ */
|
|
6612
|
+
],
|
|
6567
6613
|
},
|
|
6568
6614
|
};
|
|
6569
6615
|
|
|
@@ -6575,8 +6621,8 @@ var ChatbotFormfactorDefinition = {
|
|
|
6575
6621
|
* @public exported from `@promptbook/core`
|
|
6576
6622
|
*/
|
|
6577
6623
|
var GENERIC_PIPELINE_INTERFACE = {
|
|
6578
|
-
|
|
6579
|
-
|
|
6624
|
+
inputParameters: [],
|
|
6625
|
+
outputParameters: [],
|
|
6580
6626
|
};
|
|
6581
6627
|
/**
|
|
6582
6628
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -6604,10 +6650,10 @@ var MatcherFormfactorDefinition = {
|
|
|
6604
6650
|
description: "@@@",
|
|
6605
6651
|
documentationUrl: "https://github.com/webgptorg/promptbook/discussions/177",
|
|
6606
6652
|
pipelineInterface: {
|
|
6607
|
-
|
|
6653
|
+
inputParameters: [
|
|
6608
6654
|
/* @@@ */
|
|
6609
6655
|
],
|
|
6610
|
-
|
|
6656
|
+
outputParameters: [
|
|
6611
6657
|
/* @@@ */
|
|
6612
6658
|
],
|
|
6613
6659
|
},
|
|
@@ -6623,8 +6669,22 @@ var SheetsFormfactorDefinition = {
|
|
|
6623
6669
|
description: "@@@",
|
|
6624
6670
|
documentationUrl: "https://github.com/webgptorg/promptbook/discussions/176",
|
|
6625
6671
|
pipelineInterface: {
|
|
6626
|
-
|
|
6627
|
-
|
|
6672
|
+
inputParameters: [
|
|
6673
|
+
{
|
|
6674
|
+
name: 'inputSheet',
|
|
6675
|
+
description: "Input sheet to be processed as csv",
|
|
6676
|
+
isInput: true,
|
|
6677
|
+
isOutput: false,
|
|
6678
|
+
},
|
|
6679
|
+
],
|
|
6680
|
+
outputParameters: [
|
|
6681
|
+
{
|
|
6682
|
+
name: 'outputSheet',
|
|
6683
|
+
description: "Output sheet as csv",
|
|
6684
|
+
isInput: false,
|
|
6685
|
+
isOutput: true,
|
|
6686
|
+
},
|
|
6687
|
+
],
|
|
6628
6688
|
},
|
|
6629
6689
|
};
|
|
6630
6690
|
|
|
@@ -6638,9 +6698,23 @@ var TranslatorFormfactorDefinition = {
|
|
|
6638
6698
|
description: "@@@",
|
|
6639
6699
|
documentationUrl: "https://github.com/webgptorg/promptbook/discussions/175",
|
|
6640
6700
|
pipelineInterface: {
|
|
6641
|
-
|
|
6642
|
-
|
|
6643
|
-
|
|
6701
|
+
inputParameters: [
|
|
6702
|
+
{
|
|
6703
|
+
name: 'inputMessage',
|
|
6704
|
+
description: "Input message to be translated",
|
|
6705
|
+
isInput: true,
|
|
6706
|
+
isOutput: false,
|
|
6707
|
+
},
|
|
6708
|
+
],
|
|
6709
|
+
outputParameters: [
|
|
6710
|
+
{
|
|
6711
|
+
name: 'outputMessage',
|
|
6712
|
+
description: "Translated output message",
|
|
6713
|
+
isInput: false,
|
|
6714
|
+
isOutput: true,
|
|
6715
|
+
},
|
|
6716
|
+
],
|
|
6717
|
+
// <- TODO: [🤓] Maybe add {summary}
|
|
6644
6718
|
// <- TODO: [🧠] maybe change to {inputText}, {inputText} / or make system for any name of first input and first outpur parameter
|
|
6645
6719
|
},
|
|
6646
6720
|
};
|
|
@@ -6656,6 +6730,7 @@ var FORMFACTOR_DEFINITIONS = [
|
|
|
6656
6730
|
TranslatorFormfactorDefinition,
|
|
6657
6731
|
SheetsFormfactorDefinition,
|
|
6658
6732
|
MatcherFormfactorDefinition,
|
|
6733
|
+
GeneratorFormfactorDefinition,
|
|
6659
6734
|
];
|
|
6660
6735
|
/**
|
|
6661
6736
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -6768,7 +6843,7 @@ var jokerCommandParser = {
|
|
|
6768
6843
|
/**
|
|
6769
6844
|
* Description of the JOKER command
|
|
6770
6845
|
*/
|
|
6771
|
-
description: "Joker parameter is used instead of executing the
|
|
6846
|
+
description: "Joker parameter is used instead of executing the task result if jokers value meets the expectations requirements",
|
|
6772
6847
|
/**
|
|
6773
6848
|
* Link to documentation
|
|
6774
6849
|
*/
|
|
@@ -6996,7 +7071,7 @@ var parameterCommandParser = {
|
|
|
6996
7071
|
/**
|
|
6997
7072
|
* Description of the PARAMETER command
|
|
6998
7073
|
*/
|
|
6999
|
-
description: "Describes one parameter of the
|
|
7074
|
+
description: "Describes one parameter of the task",
|
|
7000
7075
|
/**
|
|
7001
7076
|
* Link to documentation
|
|
7002
7077
|
*/
|
|
@@ -7352,7 +7427,7 @@ var urlCommandParser = {
|
|
|
7352
7427
|
spaceTrim(
|
|
7353
7428
|
`
|
|
7354
7429
|
URL must not contain hash
|
|
7355
|
-
Hash is used for identification of the
|
|
7430
|
+
Hash is used for identification of the section of the pipeline
|
|
7356
7431
|
`,
|
|
7357
7432
|
),
|
|
7358
7433
|
);
|
|
@@ -7408,7 +7483,7 @@ var actionCommandParser = {
|
|
|
7408
7483
|
/**
|
|
7409
7484
|
* Description of the ACTION command
|
|
7410
7485
|
*/
|
|
7411
|
-
description: "Actions influences from the pipeline or
|
|
7486
|
+
description: "Actions influences from the pipeline or task into external world. Like turning on a light, sending an email, etc.",
|
|
7412
7487
|
/**
|
|
7413
7488
|
* Link to documentation
|
|
7414
7489
|
*/
|
|
@@ -7474,7 +7549,7 @@ var instrumentCommandParser = {
|
|
|
7474
7549
|
/**
|
|
7475
7550
|
* Description of the INSTRUMENT command
|
|
7476
7551
|
*/
|
|
7477
|
-
description: "Instrument command is used to specify the instrument to be used in the pipeline or
|
|
7552
|
+
description: "Instrument command is used to specify the instrument to be used in the pipeline or task like search, calculate, etc.",
|
|
7478
7553
|
/**
|
|
7479
7554
|
* Link to documentation
|
|
7480
7555
|
*/
|
|
@@ -7608,7 +7683,6 @@ function parseCommand(raw, usagePlace) {
|
|
|
7608
7683
|
normalized = normalized.split('(').join('');
|
|
7609
7684
|
normalized = normalized.split(')').join('');
|
|
7610
7685
|
normalized = normalizeTo_SCREAMING_CASE(normalized);
|
|
7611
|
-
normalized = normalized.split('DIALOGUE').join('DIALOG'); // <- TODO: !!!!!! Move to sectionCommandParser
|
|
7612
7686
|
var items = raw
|
|
7613
7687
|
.trim()
|
|
7614
7688
|
// Note: [🐡]
|
|
@@ -7796,7 +7870,7 @@ function extractAllListItemsFromMarkdown(markdown) {
|
|
|
7796
7870
|
function extractOneBlockFromMarkdown(markdown) {
|
|
7797
7871
|
var codeBlocks = extractAllBlocksFromMarkdown(markdown);
|
|
7798
7872
|
if (codeBlocks.length !== 1) {
|
|
7799
|
-
throw new ParseError(spaceTrim$1(function (block) { return "\n There should be exactly 1 code block in
|
|
7873
|
+
throw new ParseError(spaceTrim$1(function (block) { return "\n There should be exactly 1 code block in task section, found ".concat(codeBlocks.length, " code blocks\n\n ").concat(block(codeBlocks.map(function (block, i) { return "Block ".concat(i + 1, ":\n").concat(block.content); }).join('\n\n\n')), "\n "); }));
|
|
7800
7874
|
}
|
|
7801
7875
|
return codeBlocks[0];
|
|
7802
7876
|
}
|
|
@@ -8103,7 +8177,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8103
8177
|
var command = parseCommand(listItem, 'PIPELINE_HEAD');
|
|
8104
8178
|
var commandParser = getParserForCommand(command);
|
|
8105
8179
|
if (commandParser.isUsedInPipelineHead !== true /* <- Note: [🦦][4] */) {
|
|
8106
|
-
throw new ParseError(spaceTrim(function (block) { return "\n Command ".concat(command.type, " is not allowed in the head of the
|
|
8180
|
+
throw new ParseError(spaceTrim(function (block) { return "\n Command `".concat(command.type, "` is not allowed in the head of the pipeline ONLY at the pipeline task\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
|
|
8107
8181
|
}
|
|
8108
8182
|
try {
|
|
8109
8183
|
commandParser.$applyToPipelineJson(command, $pipelineJson);
|
|
@@ -8135,7 +8209,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8135
8209
|
}
|
|
8136
8210
|
var _loop_2 = function (section) {
|
|
8137
8211
|
var e_5, _l, e_6, _m;
|
|
8138
|
-
// TODO: Parse
|
|
8212
|
+
// TODO: Parse section's description (the content out of the codeblock and lists)
|
|
8139
8213
|
var listItems_2 = extractAllListItemsFromMarkdown(section.content);
|
|
8140
8214
|
var _o = extractOneBlockFromMarkdown(section.content), language = _o.language, content = _o.content;
|
|
8141
8215
|
// TODO: [🎾][1] DRY description
|
|
@@ -8166,7 +8240,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8166
8240
|
resultingParameterNameMatch.groups.resultingParamName !== undefined) {
|
|
8167
8241
|
$taskJson.resultingParameterName = resultingParameterNameMatch.groups.resultingParamName;
|
|
8168
8242
|
}
|
|
8169
|
-
// TODO: [🥥] Maybe move this logic to `$
|
|
8243
|
+
// TODO: [🥥] Maybe move this logic to `$parseAndApplyPipelineTaskCommands`
|
|
8170
8244
|
var commands = listItems_2.map(function (listItem) { return ({
|
|
8171
8245
|
listItem: listItem,
|
|
8172
8246
|
command: parseCommand(listItem, 'PIPELINE_TASK'),
|
|
@@ -8181,7 +8255,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8181
8255
|
var _loop_4 = function (listItem, command) {
|
|
8182
8256
|
var commandParser = getParserForCommand(command);
|
|
8183
8257
|
if (commandParser.isUsedInPipelineTask !== true /* <- Note: [🦦][4] */) {
|
|
8184
|
-
throw new ParseError(spaceTrim(function (block) { return "\n Command ".concat(command.type, " is not allowed in the
|
|
8258
|
+
throw new ParseError(spaceTrim(function (block) { return "\n Command `".concat(command.type, "` is not allowed in the task of the promptbook ONLY at the pipeline head\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
|
|
8185
8259
|
}
|
|
8186
8260
|
try {
|
|
8187
8261
|
commandParser.$applyToTaskJson(
|
|
@@ -8192,7 +8266,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8192
8266
|
if (!(error instanceof ParseError)) {
|
|
8193
8267
|
throw error;
|
|
8194
8268
|
}
|
|
8195
|
-
throw new ParseError(spaceTrim(function (block) { return "\n Command ".concat(command.type, " failed to apply to the
|
|
8269
|
+
throw new ParseError(spaceTrim(function (block) { return "\n Command `".concat(command.type, "` failed to apply to the task\n\n The error:\n ").concat(block(error.message), "\n\n Current state of the task:\n ").concat(block(JSON.stringify($taskJson, null, 4)), "\n *<- Maybe wrong order of commands?*\n\n Raw command:\n - ").concat(listItem, "\n\n Usage of ").concat(command.type, ":\n ").concat(block(commandParser.examples.map(function (example) { return "- ".concat(example); }).join('\n')), "\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
|
|
8196
8270
|
}
|
|
8197
8271
|
if (command.type === 'PARAMETER') {
|
|
8198
8272
|
defineParam(command);
|
|
@@ -8213,10 +8287,10 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8213
8287
|
}
|
|
8214
8288
|
finally { if (e_5) throw e_5.error; }
|
|
8215
8289
|
}
|
|
8216
|
-
// TODO: [🍧] Should be done in
|
|
8290
|
+
// TODO: [🍧] Should be done in SECTION command
|
|
8217
8291
|
if ($taskJson.taskType === 'SCRIPT_TASK') {
|
|
8218
8292
|
if (!language) {
|
|
8219
|
-
throw new ParseError(spaceTrim(function (block) { return "\n You must specify the language of the script in the SCRIPT
|
|
8293
|
+
throw new ParseError(spaceTrim(function (block) { return "\n You must specify the language of the script in the `SCRIPT` task\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
|
|
8220
8294
|
}
|
|
8221
8295
|
if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
|
|
8222
8296
|
throw new ParseError(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 "); }));
|
|
@@ -8227,7 +8301,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8227
8301
|
try {
|
|
8228
8302
|
for (var _q = (e_6 = void 0, __values($taskJson.dependentParameterNames)), _r = _q.next(); !_r.done; _r = _q.next()) {
|
|
8229
8303
|
var parameterName = _r.value;
|
|
8230
|
-
// TODO: [🧠] This definition should be made first in the
|
|
8304
|
+
// TODO: [🧠] This definition should be made first in the task
|
|
8231
8305
|
defineParam({
|
|
8232
8306
|
parameterName: parameterName,
|
|
8233
8307
|
parameterDescription: null,
|
|
@@ -8252,7 +8326,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8252
8326
|
(block) => `
|
|
8253
8327
|
Model requirements are defined for the block type ${
|
|
8254
8328
|
$taskJson.taskType
|
|
8255
|
-
} which is not a PROMPT
|
|
8329
|
+
} which is not a \`PROMPT\` task
|
|
8256
8330
|
|
|
8257
8331
|
This should be avoided by the \`modelCommandParser\`
|
|
8258
8332
|
|
|
@@ -8271,7 +8345,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8271
8345
|
};
|
|
8272
8346
|
try {
|
|
8273
8347
|
// =============================================================
|
|
8274
|
-
// Note: 4️⃣ Process each
|
|
8348
|
+
// Note: 4️⃣ Process each section of the pipeline
|
|
8275
8349
|
for (var pipelineSections_1 = __values(pipelineSections), pipelineSections_1_1 = pipelineSections_1.next(); !pipelineSections_1_1.done; pipelineSections_1_1 = pipelineSections_1.next()) {
|
|
8276
8350
|
var section = pipelineSections_1_1.value;
|
|
8277
8351
|
_loop_2(section);
|
|
@@ -8288,7 +8362,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
8288
8362
|
// Note: 5️⃣ Mark parameters as INPUT if not explicitly set
|
|
8289
8363
|
if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isInput; })) {
|
|
8290
8364
|
var _loop_3 = function (parameter) {
|
|
8291
|
-
var isThisParameterResulting = $pipelineJson.tasks.some(function (
|
|
8365
|
+
var isThisParameterResulting = $pipelineJson.tasks.some(function (task) { return task.resultingParameterName === parameter.name; });
|
|
8292
8366
|
if (!isThisParameterResulting) {
|
|
8293
8367
|
parameter.isInput = true;
|
|
8294
8368
|
}
|