@promptbook/cli 0.75.0-2 → 0.75.1
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 +49 -33
- package/esm/index.es.js +207 -127
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +16 -4
- package/esm/typings/src/_packages/types.index.d.ts +8 -6
- package/esm/typings/src/_packages/utils.index.d.ts +2 -0
- 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 +34 -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/organization/spaceTrim.d.ts +11 -0
- package/esm/typings/src/utils/parameters/extractParameterNames.d.ts +1 -1
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +207 -127
- 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/umd/index.umd.js
CHANGED
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
*
|
|
50
50
|
* @see https://github.com/webgptorg/promptbook
|
|
51
51
|
*/
|
|
52
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.75.0
|
|
52
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.75.0';
|
|
53
53
|
/**
|
|
54
54
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
55
55
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -401,7 +401,6 @@
|
|
|
401
401
|
* @public exported from `@promptbook/core`
|
|
402
402
|
*/
|
|
403
403
|
var CLAIM = "It's time for a paradigm shift. The future of software in plain English, French or Latin";
|
|
404
|
-
// <- TODO: [🐊] Pick the best claim
|
|
405
404
|
/**
|
|
406
405
|
* When the title is not provided, the default title is used
|
|
407
406
|
*
|
|
@@ -427,7 +426,7 @@
|
|
|
427
426
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
428
427
|
*/
|
|
429
428
|
var CONNECTION_TIMEOUT_MS = 7 * 1000;
|
|
430
|
-
// <- TODO: [⏳]
|
|
429
|
+
// <- TODO: [⏳] Standardize timeouts, Make DEFAULT_TIMEOUT_MS as global constant
|
|
431
430
|
/**
|
|
432
431
|
* How many times to retry the connections
|
|
433
432
|
*
|
|
@@ -465,6 +464,13 @@
|
|
|
465
464
|
* @public exported from `@promptbook/core`
|
|
466
465
|
*/
|
|
467
466
|
var DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [🤹♂️]
|
|
467
|
+
/**
|
|
468
|
+
* Where to store your books
|
|
469
|
+
* This is kind of a "src" for your books
|
|
470
|
+
*
|
|
471
|
+
* @public exported from `@promptbook/core`
|
|
472
|
+
*/
|
|
473
|
+
var DEFAULT_BOOKS_DIRNAME = './books';
|
|
468
474
|
/**
|
|
469
475
|
* Where to store the cache of executions for promptbook CLI
|
|
470
476
|
*
|
|
@@ -472,7 +478,7 @@
|
|
|
472
478
|
*
|
|
473
479
|
* @public exported from `@promptbook/core`
|
|
474
480
|
*/
|
|
475
|
-
var DEFAULT_EXECUTIONS_CACHE_DIRNAME = '
|
|
481
|
+
var DEFAULT_EXECUTIONS_CACHE_DIRNAME = './.promptbook/executions-cache';
|
|
476
482
|
/**
|
|
477
483
|
* Where to store the scrape cache
|
|
478
484
|
*
|
|
@@ -480,7 +486,7 @@
|
|
|
480
486
|
*
|
|
481
487
|
* @public exported from `@promptbook/core`
|
|
482
488
|
*/
|
|
483
|
-
var DEFAULT_SCRAPE_CACHE_DIRNAME = '
|
|
489
|
+
var DEFAULT_SCRAPE_CACHE_DIRNAME = './.promptbook/scrape-cache';
|
|
484
490
|
/**
|
|
485
491
|
* The name of the builded pipeline collection made by CLI `ptbk make` and for lookup in `createCollectionFromDirectory`
|
|
486
492
|
*
|
|
@@ -760,7 +766,7 @@
|
|
|
760
766
|
return isInput;
|
|
761
767
|
})), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
762
768
|
var parameter = _h.value;
|
|
763
|
-
commands.push("INPUT PARAMETER ".concat(
|
|
769
|
+
commands.push("INPUT PARAMETER ".concat(taskParameterJsonToString(parameter)));
|
|
764
770
|
}
|
|
765
771
|
}
|
|
766
772
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
@@ -776,7 +782,7 @@
|
|
|
776
782
|
return isOutput;
|
|
777
783
|
})), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
778
784
|
var parameter = _k.value;
|
|
779
|
-
commands.push("OUTPUT PARAMETER ".concat(
|
|
785
|
+
commands.push("OUTPUT PARAMETER ".concat(taskParameterJsonToString(parameter)));
|
|
780
786
|
}
|
|
781
787
|
}
|
|
782
788
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
@@ -790,12 +796,12 @@
|
|
|
790
796
|
pipelineString += commands.map(function (command) { return "- ".concat(command); }).join('\n');
|
|
791
797
|
try {
|
|
792
798
|
for (var tasks_1 = __values(tasks), tasks_1_1 = tasks_1.next(); !tasks_1_1.done; tasks_1_1 = tasks_1.next()) {
|
|
793
|
-
var
|
|
799
|
+
var task = tasks_1_1.value;
|
|
794
800
|
var
|
|
795
801
|
/* Note: Not using:> name, */
|
|
796
|
-
title_1 =
|
|
802
|
+
title_1 = task.title, description_1 = task.description,
|
|
797
803
|
/* Note: dependentParameterNames, */
|
|
798
|
-
jokers =
|
|
804
|
+
jokers = task.jokerParameterNames, taskType = task.taskType, content = task.content, postprocessing = task.postprocessingFunctionNames, expectations = task.expectations, format = task.format, resultingParameterName = task.resultingParameterName;
|
|
799
805
|
pipelineString += '\n\n';
|
|
800
806
|
pipelineString += "## ".concat(title_1);
|
|
801
807
|
if (description_1) {
|
|
@@ -805,9 +811,10 @@
|
|
|
805
811
|
var commands_1 = [];
|
|
806
812
|
var contentLanguage = 'text';
|
|
807
813
|
if (taskType === 'PROMPT_TASK') {
|
|
808
|
-
var modelRequirements =
|
|
814
|
+
var modelRequirements = task.modelRequirements;
|
|
809
815
|
var _l = modelRequirements || {}, modelName = _l.modelName, modelVariant = _l.modelVariant;
|
|
810
|
-
|
|
816
|
+
// Note: Do nothing, it is default
|
|
817
|
+
// commands.push(`PROMPT`);
|
|
811
818
|
if (modelVariant) {
|
|
812
819
|
commands_1.push("MODEL VARIANT ".concat(capitalize(modelVariant)));
|
|
813
820
|
}
|
|
@@ -820,16 +827,16 @@
|
|
|
820
827
|
// Note: Nothing special here
|
|
821
828
|
}
|
|
822
829
|
else if (taskType === 'SCRIPT_TASK') {
|
|
823
|
-
commands_1.push("SCRIPT
|
|
824
|
-
if (
|
|
825
|
-
contentLanguage =
|
|
830
|
+
commands_1.push("SCRIPT");
|
|
831
|
+
if (task.contentLanguage) {
|
|
832
|
+
contentLanguage = task.contentLanguage;
|
|
826
833
|
}
|
|
827
834
|
else {
|
|
828
835
|
contentLanguage = '';
|
|
829
836
|
}
|
|
830
837
|
}
|
|
831
838
|
else if (taskType === 'DIALOG_TASK') {
|
|
832
|
-
commands_1.push("DIALOG
|
|
839
|
+
commands_1.push("DIALOG");
|
|
833
840
|
// Note: Nothing special here
|
|
834
841
|
} // <- }else if([🅱]
|
|
835
842
|
if (jokers) {
|
|
@@ -904,7 +911,7 @@
|
|
|
904
911
|
pipelineString += '\n';
|
|
905
912
|
pipelineString += '```';
|
|
906
913
|
pipelineString += '\n\n';
|
|
907
|
-
pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!! If the parameter here has description, add it and use
|
|
914
|
+
pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!! If the parameter here has description, add it and use taskParameterJsonToString
|
|
908
915
|
}
|
|
909
916
|
}
|
|
910
917
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
@@ -919,8 +926,8 @@
|
|
|
919
926
|
/**
|
|
920
927
|
* @private internal utility of `pipelineJsonToString`
|
|
921
928
|
*/
|
|
922
|
-
function
|
|
923
|
-
var name =
|
|
929
|
+
function taskParameterJsonToString(taskParameterJson) {
|
|
930
|
+
var name = taskParameterJson.name, description = taskParameterJson.description;
|
|
924
931
|
var parameterString = "{".concat(name, "}");
|
|
925
932
|
if (description) {
|
|
926
933
|
parameterString = "".concat(parameterString, " ").concat(description);
|
|
@@ -928,7 +935,7 @@
|
|
|
928
935
|
return parameterString;
|
|
929
936
|
}
|
|
930
937
|
/**
|
|
931
|
-
* TODO: [🛋] Implement new features and commands into `pipelineJsonToString` + `
|
|
938
|
+
* TODO: [🛋] Implement new features and commands into `pipelineJsonToString` + `taskParameterJsonToString` , use `stringifyCommand`
|
|
932
939
|
* TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
|
|
933
940
|
* TODO: [🏛] Maybe make some markdown builder
|
|
934
941
|
* TODO: [🏛] Escape all
|
|
@@ -1573,7 +1580,7 @@
|
|
|
1573
1580
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
1574
1581
|
*/
|
|
1575
1582
|
|
|
1576
|
-
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:"./
|
|
1583
|
+
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"}];
|
|
1577
1584
|
|
|
1578
1585
|
/**
|
|
1579
1586
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -1966,20 +1973,20 @@
|
|
|
1966
1973
|
}
|
|
1967
1974
|
finally { if (e_3) throw e_3.error; }
|
|
1968
1975
|
}
|
|
1969
|
-
var
|
|
1976
|
+
var unresovedTasks = __spreadArray([], __read(pipeline.tasks), false);
|
|
1970
1977
|
var loopLimit = LOOP_LIMIT;
|
|
1971
1978
|
var _loop_3 = function () {
|
|
1972
1979
|
if (loopLimit-- < 0) {
|
|
1973
1980
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
1974
1981
|
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Loop limit reached during detection of circular dependencies in `validatePipeline`\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
1975
1982
|
}
|
|
1976
|
-
var
|
|
1983
|
+
var currentlyResovedTasks = unresovedTasks.filter(function (task) {
|
|
1977
1984
|
return task.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
|
|
1978
1985
|
});
|
|
1979
|
-
if (
|
|
1986
|
+
if (currentlyResovedTasks.length === 0) {
|
|
1980
1987
|
throw new PipelineLogicError(
|
|
1981
1988
|
// TODO: [🐎] DRY
|
|
1982
|
-
spaceTrim.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(
|
|
1989
|
+
spaceTrim.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
|
|
1983
1990
|
.map(function (_a) {
|
|
1984
1991
|
var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
|
|
1985
1992
|
return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
|
|
@@ -1998,13 +2005,13 @@
|
|
|
1998
2005
|
.map(function (name) { return "- Parameter `{".concat(name, "}`"); })
|
|
1999
2006
|
.join('\n')), "\n\n\n "); }));
|
|
2000
2007
|
}
|
|
2001
|
-
resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(
|
|
2008
|
+
resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTasks.map(function (_a) {
|
|
2002
2009
|
var resultingParameterName = _a.resultingParameterName;
|
|
2003
2010
|
return resultingParameterName;
|
|
2004
2011
|
})), false);
|
|
2005
|
-
|
|
2012
|
+
unresovedTasks = unresovedTasks.filter(function (task) { return !currentlyResovedTasks.includes(task); });
|
|
2006
2013
|
};
|
|
2007
|
-
while (
|
|
2014
|
+
while (unresovedTasks.length > 0) {
|
|
2008
2015
|
_loop_3();
|
|
2009
2016
|
}
|
|
2010
2017
|
// TODO: !!!!!! Test that pipeline interface implements declared formfactor interface
|
|
@@ -2066,7 +2073,7 @@
|
|
|
2066
2073
|
/**
|
|
2067
2074
|
* Parses the task and returns the list of all parameter names
|
|
2068
2075
|
*
|
|
2069
|
-
* @param template the
|
|
2076
|
+
* @param template the string template with parameters in {curly} braces
|
|
2070
2077
|
* @returns the list of parameter names
|
|
2071
2078
|
* @public exported from `@promptbook/utils`
|
|
2072
2079
|
*/
|
|
@@ -2100,13 +2107,13 @@
|
|
|
2100
2107
|
var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, tasks = pipeline.tasks;
|
|
2101
2108
|
personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
|
|
2102
2109
|
knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
|
|
2103
|
-
tasks = tasks.map(function (
|
|
2104
|
-
var dependentParameterNames =
|
|
2105
|
-
var parameterNames = extractParameterNames(
|
|
2110
|
+
tasks = tasks.map(function (task) {
|
|
2111
|
+
var dependentParameterNames = task.dependentParameterNames;
|
|
2112
|
+
var parameterNames = extractParameterNames(task.preparedContent || '');
|
|
2106
2113
|
dependentParameterNames = dependentParameterNames.filter(function (dependentParameterName) { return !parameterNames.has(dependentParameterName); });
|
|
2107
|
-
var
|
|
2108
|
-
delete
|
|
2109
|
-
return
|
|
2114
|
+
var taskUnprepared = __assign(__assign({}, task), { dependentParameterNames: dependentParameterNames });
|
|
2115
|
+
delete taskUnprepared.preparedContent;
|
|
2116
|
+
return taskUnprepared;
|
|
2110
2117
|
});
|
|
2111
2118
|
return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), { tasks: tasks, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }));
|
|
2112
2119
|
}
|
|
@@ -2383,7 +2390,7 @@
|
|
|
2383
2390
|
* TODO: [🐠] Maybe base this on `makeValidator`
|
|
2384
2391
|
* TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
|
|
2385
2392
|
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
2386
|
-
* - [🏍] ? Is context in each
|
|
2393
|
+
* - [🏍] ? Is context in each task
|
|
2387
2394
|
* - [♨] Are examples prepared
|
|
2388
2395
|
* - [♨] Are tasks prepared
|
|
2389
2396
|
*/
|
|
@@ -2455,16 +2462,16 @@
|
|
|
2455
2462
|
*/
|
|
2456
2463
|
|
|
2457
2464
|
/**
|
|
2458
|
-
* Parses the
|
|
2465
|
+
* Parses the task and returns the set of all used parameters
|
|
2459
2466
|
*
|
|
2460
|
-
* @param
|
|
2467
|
+
* @param task the task with used parameters
|
|
2461
2468
|
* @returns the set of parameter names
|
|
2462
2469
|
* @throws {ParseError} if the script is invalid
|
|
2463
2470
|
* @public exported from `@promptbook/utils`
|
|
2464
2471
|
*/
|
|
2465
|
-
function extractParameterNamesFromTask(
|
|
2472
|
+
function extractParameterNamesFromTask(task) {
|
|
2466
2473
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
2467
|
-
var title =
|
|
2474
|
+
var title = task.title, description = task.description, taskType = task.taskType, content = task.content, preparedContent = task.preparedContent, jokerParameterNames = task.jokerParameterNames, foreach = task.foreach;
|
|
2468
2475
|
var parameterNames = new Set();
|
|
2469
2476
|
try {
|
|
2470
2477
|
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()) {
|
|
@@ -5522,10 +5529,10 @@
|
|
|
5522
5529
|
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
|
|
5523
5530
|
tasks = pipeline.tasks, pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
|
|
5524
5531
|
tasksPrepared = new Array(tasks.length);
|
|
5525
|
-
return [4 /*yield*/, forEachAsync(tasks, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (
|
|
5526
|
-
var dependentParameterNames, preparedContent,
|
|
5532
|
+
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 () {
|
|
5533
|
+
var dependentParameterNames, preparedContent, preparedTask;
|
|
5527
5534
|
return __generator(this, function (_a) {
|
|
5528
|
-
dependentParameterNames =
|
|
5535
|
+
dependentParameterNames = task.dependentParameterNames;
|
|
5529
5536
|
preparedContent = undefined;
|
|
5530
5537
|
if (knowledgePiecesCount > 0 && !dependentParameterNames.includes('knowledge')) {
|
|
5531
5538
|
preparedContent = spaceTrim.spaceTrim("\n {content}\n\n ## Knowledge\n\n {knowledge}\n ");
|
|
@@ -5534,8 +5541,8 @@
|
|
|
5534
5541
|
'knowledge',
|
|
5535
5542
|
], false);
|
|
5536
5543
|
}
|
|
5537
|
-
|
|
5538
|
-
tasksPrepared[index] =
|
|
5544
|
+
preparedTask = __assign(__assign({}, task), { dependentParameterNames: dependentParameterNames, preparedContent: preparedContent });
|
|
5545
|
+
tasksPrepared[index] = preparedTask;
|
|
5539
5546
|
return [2 /*return*/];
|
|
5540
5547
|
});
|
|
5541
5548
|
}); })];
|
|
@@ -5547,8 +5554,8 @@
|
|
|
5547
5554
|
});
|
|
5548
5555
|
}
|
|
5549
5556
|
/**
|
|
5550
|
-
* TODO: [🧠] Add context to each
|
|
5551
|
-
* TODO: [🧠] What is better name `
|
|
5557
|
+
* TODO: [🧠] Add context to each task (if missing)
|
|
5558
|
+
* TODO: [🧠] What is better name `prepareTask` or `prepareTaskAndParameters`
|
|
5552
5559
|
* TODO: [♨][main] !!! Prepare index the examples and maybe tasks
|
|
5553
5560
|
* TODO: Write tests for `preparePipeline`
|
|
5554
5561
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
@@ -5634,7 +5641,7 @@
|
|
|
5634
5641
|
})];
|
|
5635
5642
|
case 3:
|
|
5636
5643
|
tasksPrepared = (_c.sent()).tasksPrepared;
|
|
5637
|
-
// ----- /
|
|
5644
|
+
// ----- /Tasks preparation -----
|
|
5638
5645
|
// Note: Count total usage
|
|
5639
5646
|
currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
|
|
5640
5647
|
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { tasks: __spreadArray([], __read(tasksPrepared), false),
|
|
@@ -5653,6 +5660,40 @@
|
|
|
5653
5660
|
* @see https://docs.anthropic.com/en/docs/test-and-evaluate/strengthen-guardrails/increase-consistency#specify-the-desired-output-format
|
|
5654
5661
|
*/
|
|
5655
5662
|
|
|
5663
|
+
/**
|
|
5664
|
+
* All available task types
|
|
5665
|
+
*
|
|
5666
|
+
* There is is distinction between task types and section types
|
|
5667
|
+
* - Every section in markdown has its SectionType
|
|
5668
|
+
* - Some sections are tasks but other can be non-task sections
|
|
5669
|
+
*
|
|
5670
|
+
* @public exported from `@promptbook/core`
|
|
5671
|
+
*/
|
|
5672
|
+
var TaskTypes = [
|
|
5673
|
+
'PROMPT',
|
|
5674
|
+
'SIMPLE',
|
|
5675
|
+
'SCRIPT',
|
|
5676
|
+
'DIALOG',
|
|
5677
|
+
// <- [🅱]
|
|
5678
|
+
];
|
|
5679
|
+
|
|
5680
|
+
/**
|
|
5681
|
+
* All available sections which are not tasks
|
|
5682
|
+
*
|
|
5683
|
+
* @public exported from `@promptbook/core`
|
|
5684
|
+
*/
|
|
5685
|
+
var NonTaskSectionTypes = ['EXAMPLE', 'KNOWLEDGE', 'INSTRUMENT', 'ACTION'];
|
|
5686
|
+
/**
|
|
5687
|
+
* All available section types
|
|
5688
|
+
*
|
|
5689
|
+
* There is is distinction between task types and section types
|
|
5690
|
+
* - Every section in markdown has its SectionType
|
|
5691
|
+
* - Some sections are tasks but other can be non-task sections
|
|
5692
|
+
*
|
|
5693
|
+
* @public exported from `@promptbook/core`
|
|
5694
|
+
*/
|
|
5695
|
+
var SectionTypes = __spreadArray(__spreadArray([], __read(TaskTypes.map(function (TaskType) { return "".concat(TaskType, "_TASK"); })), false), __read(NonTaskSectionTypes), false);
|
|
5696
|
+
|
|
5656
5697
|
/**
|
|
5657
5698
|
* Parses the knowledge command
|
|
5658
5699
|
*
|
|
@@ -5745,24 +5786,6 @@
|
|
|
5745
5786
|
* Note: [⛱] There are two types of KNOWLEDGE commands *...(read more in [⛱])*
|
|
5746
5787
|
*/
|
|
5747
5788
|
|
|
5748
|
-
/**
|
|
5749
|
-
* Section type describes the way how the section is sectiond
|
|
5750
|
-
*
|
|
5751
|
-
* @public exported from `@promptbook/core`
|
|
5752
|
-
*/
|
|
5753
|
-
var SectionTypes = [
|
|
5754
|
-
'PROMPT_TASK',
|
|
5755
|
-
'SIMPLE_TASK',
|
|
5756
|
-
'SCRIPT_TASK',
|
|
5757
|
-
'DIALOG_TASK',
|
|
5758
|
-
'EXAMPLE',
|
|
5759
|
-
'KNOWLEDGE',
|
|
5760
|
-
'INSTRUMENT',
|
|
5761
|
-
'ACTION',
|
|
5762
|
-
// <- [🅱]
|
|
5763
|
-
];
|
|
5764
|
-
// <- TODO: !!!!!! Make alongside `SectionType` the `TaskType`, `TaskType` + [⛱] and ACRY
|
|
5765
|
-
|
|
5766
5789
|
/**
|
|
5767
5790
|
* Parses the section command
|
|
5768
5791
|
*
|
|
@@ -5850,7 +5873,10 @@
|
|
|
5850
5873
|
var normalized = input.normalized;
|
|
5851
5874
|
normalized = normalized.split('SAMPLE').join('EXAMPLE');
|
|
5852
5875
|
normalized = normalized.split('EXECUTE_').join('');
|
|
5853
|
-
|
|
5876
|
+
normalized = normalized.split('DIALOGUE').join('DIALOG');
|
|
5877
|
+
var taskTypes = SectionTypes.filter(function (sectionType) {
|
|
5878
|
+
return normalized.includes(sectionType.split('_TASK').join(''));
|
|
5879
|
+
});
|
|
5854
5880
|
if (taskTypes.length !== 1) {
|
|
5855
5881
|
throw new ParseError(spaceTrim__default["default"](function (block) { return "\n Unknown section type \"".concat(normalized, "\"\n\n Supported section types are:\n ").concat(block(SectionTypes.join(', ')), "\n "); }));
|
|
5856
5882
|
}
|
|
@@ -6209,7 +6235,7 @@
|
|
|
6209
6235
|
/**
|
|
6210
6236
|
* Description of the FORMAT command
|
|
6211
6237
|
*/
|
|
6212
|
-
description: spaceTrim__default["default"]("\n Expect command describes the desired output of the
|
|
6238
|
+
description: spaceTrim__default["default"]("\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 "),
|
|
6213
6239
|
/**
|
|
6214
6240
|
* Link to documentation
|
|
6215
6241
|
*/
|
|
@@ -6695,7 +6721,7 @@
|
|
|
6695
6721
|
/**
|
|
6696
6722
|
* Description of the FORMAT command
|
|
6697
6723
|
*/
|
|
6698
|
-
description: spaceTrim__default["default"]("\n Format command describes the desired output of the
|
|
6724
|
+
description: spaceTrim__default["default"]("\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 "),
|
|
6699
6725
|
/**
|
|
6700
6726
|
* Link to documentation
|
|
6701
6727
|
*/
|
|
@@ -6759,19 +6785,45 @@
|
|
|
6759
6785
|
description: "@@@",
|
|
6760
6786
|
documentationUrl: "https://github.com/webgptorg/promptbook/discussions/174",
|
|
6761
6787
|
pipelineInterface: {
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6788
|
+
inputParameters: [
|
|
6789
|
+
{
|
|
6790
|
+
name: 'previousTitle',
|
|
6791
|
+
description: "Previous title of the conversation",
|
|
6792
|
+
isInput: true,
|
|
6793
|
+
isOutput: false,
|
|
6794
|
+
},
|
|
6795
|
+
{
|
|
6796
|
+
name: 'previousConversationSummary',
|
|
6797
|
+
description: "Previous conversation summary",
|
|
6798
|
+
isInput: true,
|
|
6799
|
+
isOutput: false,
|
|
6800
|
+
},
|
|
6801
|
+
{ name: 'userMessage', description: "User message", isInput: true, isOutput: false },
|
|
6802
|
+
],
|
|
6803
|
+
outputParameters: [
|
|
6804
|
+
{ name: 'title', description: "Title of the conversation", isInput: false, isOutput: true },
|
|
6805
|
+
{ name: 'conversationSummary', description: "Summary of the conversation", isInput: false, isOutput: true },
|
|
6806
|
+
{ name: 'chatbotResponse', description: "Chatbot response", isInput: false, isOutput: true },
|
|
6807
|
+
],
|
|
6808
|
+
},
|
|
6809
|
+
};
|
|
6773
6810
|
|
|
6774
|
-
|
|
6811
|
+
/**
|
|
6812
|
+
* Generator is form of app that @@@
|
|
6813
|
+
*
|
|
6814
|
+
* @public exported from `@promptbook/core`
|
|
6815
|
+
*/
|
|
6816
|
+
var GeneratorFormfactorDefinition = {
|
|
6817
|
+
name: 'GENERATOR',
|
|
6818
|
+
description: "@@@",
|
|
6819
|
+
documentationUrl: "https://github.com/webgptorg/promptbook/discussions/184",
|
|
6820
|
+
pipelineInterface: {
|
|
6821
|
+
inputParameters: [
|
|
6822
|
+
/* @@@ */
|
|
6823
|
+
],
|
|
6824
|
+
outputParameters: [
|
|
6825
|
+
/* @@@ */
|
|
6826
|
+
],
|
|
6775
6827
|
},
|
|
6776
6828
|
};
|
|
6777
6829
|
|
|
@@ -6783,8 +6835,8 @@
|
|
|
6783
6835
|
* @public exported from `@promptbook/core`
|
|
6784
6836
|
*/
|
|
6785
6837
|
var GENERIC_PIPELINE_INTERFACE = {
|
|
6786
|
-
|
|
6787
|
-
|
|
6838
|
+
inputParameters: [],
|
|
6839
|
+
outputParameters: [],
|
|
6788
6840
|
};
|
|
6789
6841
|
/**
|
|
6790
6842
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -6812,10 +6864,10 @@
|
|
|
6812
6864
|
description: "@@@",
|
|
6813
6865
|
documentationUrl: "https://github.com/webgptorg/promptbook/discussions/177",
|
|
6814
6866
|
pipelineInterface: {
|
|
6815
|
-
|
|
6867
|
+
inputParameters: [
|
|
6816
6868
|
/* @@@ */
|
|
6817
6869
|
],
|
|
6818
|
-
|
|
6870
|
+
outputParameters: [
|
|
6819
6871
|
/* @@@ */
|
|
6820
6872
|
],
|
|
6821
6873
|
},
|
|
@@ -6831,8 +6883,22 @@
|
|
|
6831
6883
|
description: "@@@",
|
|
6832
6884
|
documentationUrl: "https://github.com/webgptorg/promptbook/discussions/176",
|
|
6833
6885
|
pipelineInterface: {
|
|
6834
|
-
|
|
6835
|
-
|
|
6886
|
+
inputParameters: [
|
|
6887
|
+
{
|
|
6888
|
+
name: 'inputSheet',
|
|
6889
|
+
description: "Input sheet to be processed as csv",
|
|
6890
|
+
isInput: true,
|
|
6891
|
+
isOutput: false,
|
|
6892
|
+
},
|
|
6893
|
+
],
|
|
6894
|
+
outputParameters: [
|
|
6895
|
+
{
|
|
6896
|
+
name: 'outputSheet',
|
|
6897
|
+
description: "Output sheet as csv",
|
|
6898
|
+
isInput: false,
|
|
6899
|
+
isOutput: true,
|
|
6900
|
+
},
|
|
6901
|
+
],
|
|
6836
6902
|
},
|
|
6837
6903
|
};
|
|
6838
6904
|
|
|
@@ -6846,9 +6912,23 @@
|
|
|
6846
6912
|
description: "@@@",
|
|
6847
6913
|
documentationUrl: "https://github.com/webgptorg/promptbook/discussions/175",
|
|
6848
6914
|
pipelineInterface: {
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
6915
|
+
inputParameters: [
|
|
6916
|
+
{
|
|
6917
|
+
name: 'inputMessage',
|
|
6918
|
+
description: "Input message to be translated",
|
|
6919
|
+
isInput: true,
|
|
6920
|
+
isOutput: false,
|
|
6921
|
+
},
|
|
6922
|
+
],
|
|
6923
|
+
outputParameters: [
|
|
6924
|
+
{
|
|
6925
|
+
name: 'outputMessage',
|
|
6926
|
+
description: "Translated output message",
|
|
6927
|
+
isInput: false,
|
|
6928
|
+
isOutput: true,
|
|
6929
|
+
},
|
|
6930
|
+
],
|
|
6931
|
+
// <- TODO: [🤓] Maybe add {summary}
|
|
6852
6932
|
// <- TODO: [🧠] maybe change to {inputText}, {inputText} / or make system for any name of first input and first outpur parameter
|
|
6853
6933
|
},
|
|
6854
6934
|
};
|
|
@@ -6864,6 +6944,7 @@
|
|
|
6864
6944
|
TranslatorFormfactorDefinition,
|
|
6865
6945
|
SheetsFormfactorDefinition,
|
|
6866
6946
|
MatcherFormfactorDefinition,
|
|
6947
|
+
GeneratorFormfactorDefinition,
|
|
6867
6948
|
];
|
|
6868
6949
|
/**
|
|
6869
6950
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -6976,7 +7057,7 @@
|
|
|
6976
7057
|
/**
|
|
6977
7058
|
* Description of the JOKER command
|
|
6978
7059
|
*/
|
|
6979
|
-
description: "Joker parameter is used instead of executing the
|
|
7060
|
+
description: "Joker parameter is used instead of executing the task result if jokers value meets the expectations requirements",
|
|
6980
7061
|
/**
|
|
6981
7062
|
* Link to documentation
|
|
6982
7063
|
*/
|
|
@@ -7204,7 +7285,7 @@
|
|
|
7204
7285
|
/**
|
|
7205
7286
|
* Description of the PARAMETER command
|
|
7206
7287
|
*/
|
|
7207
|
-
description: "Describes one parameter of the
|
|
7288
|
+
description: "Describes one parameter of the task",
|
|
7208
7289
|
/**
|
|
7209
7290
|
* Link to documentation
|
|
7210
7291
|
*/
|
|
@@ -7560,7 +7641,7 @@
|
|
|
7560
7641
|
spaceTrim(
|
|
7561
7642
|
`
|
|
7562
7643
|
URL must not contain hash
|
|
7563
|
-
Hash is used for identification of the
|
|
7644
|
+
Hash is used for identification of the section of the pipeline
|
|
7564
7645
|
`,
|
|
7565
7646
|
),
|
|
7566
7647
|
);
|
|
@@ -7616,7 +7697,7 @@
|
|
|
7616
7697
|
/**
|
|
7617
7698
|
* Description of the ACTION command
|
|
7618
7699
|
*/
|
|
7619
|
-
description: "Actions influences from the pipeline or
|
|
7700
|
+
description: "Actions influences from the pipeline or task into external world. Like turning on a light, sending an email, etc.",
|
|
7620
7701
|
/**
|
|
7621
7702
|
* Link to documentation
|
|
7622
7703
|
*/
|
|
@@ -7682,7 +7763,7 @@
|
|
|
7682
7763
|
/**
|
|
7683
7764
|
* Description of the INSTRUMENT command
|
|
7684
7765
|
*/
|
|
7685
|
-
description: "Instrument command is used to specify the instrument to be used in the pipeline or
|
|
7766
|
+
description: "Instrument command is used to specify the instrument to be used in the pipeline or task like search, calculate, etc.",
|
|
7686
7767
|
/**
|
|
7687
7768
|
* Link to documentation
|
|
7688
7769
|
*/
|
|
@@ -7816,7 +7897,6 @@
|
|
|
7816
7897
|
normalized = normalized.split('(').join('');
|
|
7817
7898
|
normalized = normalized.split(')').join('');
|
|
7818
7899
|
normalized = normalizeTo_SCREAMING_CASE(normalized);
|
|
7819
|
-
normalized = normalized.split('DIALOGUE').join('DIALOG'); // <- TODO: !!!!!! Move to sectionCommandParser
|
|
7820
7900
|
var items = raw
|
|
7821
7901
|
.trim()
|
|
7822
7902
|
// Note: [🐡]
|
|
@@ -8004,7 +8084,7 @@
|
|
|
8004
8084
|
function extractOneBlockFromMarkdown(markdown) {
|
|
8005
8085
|
var codeBlocks = extractAllBlocksFromMarkdown(markdown);
|
|
8006
8086
|
if (codeBlocks.length !== 1) {
|
|
8007
|
-
throw new ParseError(spaceTrim__default["default"](function (block) { return "\n There should be exactly 1 code block in
|
|
8087
|
+
throw new ParseError(spaceTrim__default["default"](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 "); }));
|
|
8008
8088
|
}
|
|
8009
8089
|
return codeBlocks[0];
|
|
8010
8090
|
}
|
|
@@ -8311,7 +8391,7 @@
|
|
|
8311
8391
|
var command = parseCommand(listItem, 'PIPELINE_HEAD');
|
|
8312
8392
|
var commandParser = getParserForCommand(command);
|
|
8313
8393
|
if (commandParser.isUsedInPipelineHead !== true /* <- Note: [🦦][4] */) {
|
|
8314
|
-
throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n Command ".concat(command.type, " is not allowed in the head of the
|
|
8394
|
+
throw new ParseError(spaceTrim.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: [🚞]
|
|
8315
8395
|
}
|
|
8316
8396
|
try {
|
|
8317
8397
|
commandParser.$applyToPipelineJson(command, $pipelineJson);
|
|
@@ -8343,7 +8423,7 @@
|
|
|
8343
8423
|
}
|
|
8344
8424
|
var _loop_2 = function (section) {
|
|
8345
8425
|
var e_5, _l, e_6, _m;
|
|
8346
|
-
// TODO: Parse
|
|
8426
|
+
// TODO: Parse section's description (the content out of the codeblock and lists)
|
|
8347
8427
|
var listItems_2 = extractAllListItemsFromMarkdown(section.content);
|
|
8348
8428
|
var _o = extractOneBlockFromMarkdown(section.content), language = _o.language, content = _o.content;
|
|
8349
8429
|
// TODO: [🎾][1] DRY description
|
|
@@ -8374,7 +8454,7 @@
|
|
|
8374
8454
|
resultingParameterNameMatch.groups.resultingParamName !== undefined) {
|
|
8375
8455
|
$taskJson.resultingParameterName = resultingParameterNameMatch.groups.resultingParamName;
|
|
8376
8456
|
}
|
|
8377
|
-
// TODO: [🥥] Maybe move this logic to `$
|
|
8457
|
+
// TODO: [🥥] Maybe move this logic to `$parseAndApplyPipelineTaskCommands`
|
|
8378
8458
|
var commands = listItems_2.map(function (listItem) { return ({
|
|
8379
8459
|
listItem: listItem,
|
|
8380
8460
|
command: parseCommand(listItem, 'PIPELINE_TASK'),
|
|
@@ -8389,7 +8469,7 @@
|
|
|
8389
8469
|
var _loop_4 = function (listItem, command) {
|
|
8390
8470
|
var commandParser = getParserForCommand(command);
|
|
8391
8471
|
if (commandParser.isUsedInPipelineTask !== true /* <- Note: [🦦][4] */) {
|
|
8392
|
-
throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n Command ".concat(command.type, " is not allowed in the
|
|
8472
|
+
throw new ParseError(spaceTrim.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: [🚞]
|
|
8393
8473
|
}
|
|
8394
8474
|
try {
|
|
8395
8475
|
commandParser.$applyToTaskJson(
|
|
@@ -8400,7 +8480,7 @@
|
|
|
8400
8480
|
if (!(error instanceof ParseError)) {
|
|
8401
8481
|
throw error;
|
|
8402
8482
|
}
|
|
8403
|
-
throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n Command ".concat(command.type, " failed to apply to the
|
|
8483
|
+
throw new ParseError(spaceTrim.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: [🚞]
|
|
8404
8484
|
}
|
|
8405
8485
|
if (command.type === 'PARAMETER') {
|
|
8406
8486
|
defineParam(command);
|
|
@@ -8421,10 +8501,10 @@
|
|
|
8421
8501
|
}
|
|
8422
8502
|
finally { if (e_5) throw e_5.error; }
|
|
8423
8503
|
}
|
|
8424
|
-
// TODO: [🍧] Should be done in
|
|
8504
|
+
// TODO: [🍧] Should be done in SECTION command
|
|
8425
8505
|
if ($taskJson.taskType === 'SCRIPT_TASK') {
|
|
8426
8506
|
if (!language) {
|
|
8427
|
-
throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n You must specify the language of the script in the SCRIPT
|
|
8507
|
+
throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n You must specify the language of the script in the `SCRIPT` task\n\n ".concat(block(getPipelineIdentification()), "\n "); }));
|
|
8428
8508
|
}
|
|
8429
8509
|
if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
|
|
8430
8510
|
throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n Script language ".concat(language, " is not supported.\n\n Supported languages are:\n ").concat(block(SUPPORTED_SCRIPT_LANGUAGES.join(', ')), "\n\n "); }));
|
|
@@ -8435,7 +8515,7 @@
|
|
|
8435
8515
|
try {
|
|
8436
8516
|
for (var _q = (e_6 = void 0, __values($taskJson.dependentParameterNames)), _r = _q.next(); !_r.done; _r = _q.next()) {
|
|
8437
8517
|
var parameterName = _r.value;
|
|
8438
|
-
// TODO: [🧠] This definition should be made first in the
|
|
8518
|
+
// TODO: [🧠] This definition should be made first in the task
|
|
8439
8519
|
defineParam({
|
|
8440
8520
|
parameterName: parameterName,
|
|
8441
8521
|
parameterDescription: null,
|
|
@@ -8460,7 +8540,7 @@
|
|
|
8460
8540
|
(block) => `
|
|
8461
8541
|
Model requirements are defined for the block type ${
|
|
8462
8542
|
$taskJson.taskType
|
|
8463
|
-
} which is not a PROMPT
|
|
8543
|
+
} which is not a \`PROMPT\` task
|
|
8464
8544
|
|
|
8465
8545
|
This should be avoided by the \`modelCommandParser\`
|
|
8466
8546
|
|
|
@@ -8479,7 +8559,7 @@
|
|
|
8479
8559
|
};
|
|
8480
8560
|
try {
|
|
8481
8561
|
// =============================================================
|
|
8482
|
-
// Note: 4️⃣ Process each
|
|
8562
|
+
// Note: 4️⃣ Process each section of the pipeline
|
|
8483
8563
|
for (var pipelineSections_1 = __values(pipelineSections), pipelineSections_1_1 = pipelineSections_1.next(); !pipelineSections_1_1.done; pipelineSections_1_1 = pipelineSections_1.next()) {
|
|
8484
8564
|
var section = pipelineSections_1_1.value;
|
|
8485
8565
|
_loop_2(section);
|
|
@@ -8496,7 +8576,7 @@
|
|
|
8496
8576
|
// Note: 5️⃣ Mark parameters as INPUT if not explicitly set
|
|
8497
8577
|
if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isInput; })) {
|
|
8498
8578
|
var _loop_3 = function (parameter) {
|
|
8499
|
-
var isThisParameterResulting = $pipelineJson.tasks.some(function (
|
|
8579
|
+
var isThisParameterResulting = $pipelineJson.tasks.some(function (task) { return task.resultingParameterName === parameter.name; });
|
|
8500
8580
|
if (!isThisParameterResulting) {
|
|
8501
8581
|
parameter.isInput = true;
|
|
8502
8582
|
}
|
|
@@ -10577,7 +10657,7 @@
|
|
|
10577
10657
|
// TODO: [🧅] DRY command arguments
|
|
10578
10658
|
makeCommand.argument('[path]',
|
|
10579
10659
|
// <- TODO: [🧟♂️] Unite path to promptbook collection argument
|
|
10580
|
-
'Path to promptbook collection directory',
|
|
10660
|
+
'Path to promptbook collection directory', DEFAULT_BOOKS_DIRNAME);
|
|
10581
10661
|
makeCommand.option('--project-name', "Name of the project for whom collection is", 'Untitled Promptbook project');
|
|
10582
10662
|
makeCommand.option('-f, --format <format>', spaceTrim__default["default"]("\n Output format of builded collection \"javascript\", \"typescript\" or \"json\"\n\n Note: You can use multiple formats separated by comma\n "), 'javascript' /* <- Note: [🏳🌈] */);
|
|
10583
10663
|
makeCommand.option('--no-validation', "Do not validate logic of pipelines in collection", true);
|
|
@@ -10805,8 +10885,8 @@
|
|
|
10805
10885
|
* @public exported from `@promptbook/utils`
|
|
10806
10886
|
*/
|
|
10807
10887
|
function renderPromptbookMermaid(pipelineJson, options) {
|
|
10808
|
-
var _a = (options || {}).
|
|
10809
|
-
var
|
|
10888
|
+
var _a = (options || {}).linkTask, linkTask = _a === void 0 ? function () { return null; } : _a;
|
|
10889
|
+
var parameterNameToTaskName = function (parameterName) {
|
|
10810
10890
|
var parameter = pipelineJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
|
|
10811
10891
|
if (!parameter) {
|
|
10812
10892
|
throw new UnexpectedError("Could not find {".concat(parameterName, "}"));
|
|
@@ -10814,19 +10894,19 @@
|
|
|
10814
10894
|
if (parameter.isInput) {
|
|
10815
10895
|
return 'input';
|
|
10816
10896
|
}
|
|
10817
|
-
var
|
|
10818
|
-
if (!
|
|
10819
|
-
throw new Error("Could not find
|
|
10897
|
+
var task = pipelineJson.tasks.find(function (task) { return task.resultingParameterName === parameterName; });
|
|
10898
|
+
if (!task) {
|
|
10899
|
+
throw new Error("Could not find task for {".concat(parameterName, "}"));
|
|
10820
10900
|
}
|
|
10821
|
-
return normalizeTo_camelCase('
|
|
10901
|
+
return normalizeTo_camelCase('task-' + titleToName(task.title));
|
|
10822
10902
|
};
|
|
10823
10903
|
var promptbookMermaid = spaceTrim.spaceTrim(function (block) { return "\n\n %% \uD83D\uDD2E Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually\n\n flowchart LR\n subgraph \"".concat(pipelineJson.title, "\"\n\n direction TB\n\n input((Input)):::input\n ").concat(block(pipelineJson.tasks
|
|
10824
10904
|
.flatMap(function (_a) {
|
|
10825
10905
|
var title = _a.title, dependentParameterNames = _a.dependentParameterNames, resultingParameterName = _a.resultingParameterName;
|
|
10826
10906
|
return __spreadArray([
|
|
10827
|
-
"".concat(
|
|
10907
|
+
"".concat(parameterNameToTaskName(resultingParameterName), "(\"").concat(title, "\")")
|
|
10828
10908
|
], __read(dependentParameterNames.map(function (dependentParameterName) {
|
|
10829
|
-
return "".concat(
|
|
10909
|
+
return "".concat(parameterNameToTaskName(dependentParameterName), "--\"{").concat(dependentParameterName, "}\"-->").concat(parameterNameToTaskName(resultingParameterName));
|
|
10830
10910
|
})), false);
|
|
10831
10911
|
})
|
|
10832
10912
|
.join('\n')), "\n\n ").concat(block(pipelineJson.parameters
|
|
@@ -10836,17 +10916,17 @@
|
|
|
10836
10916
|
})
|
|
10837
10917
|
.map(function (_a) {
|
|
10838
10918
|
var name = _a.name;
|
|
10839
|
-
return "".concat(
|
|
10919
|
+
return "".concat(parameterNameToTaskName(name), "--\"{").concat(name, "}\"-->output");
|
|
10840
10920
|
})
|
|
10841
10921
|
.join('\n')), "\n output((Output)):::output\n\n ").concat(block(pipelineJson.tasks
|
|
10842
|
-
.map(function (
|
|
10843
|
-
var link =
|
|
10922
|
+
.map(function (task) {
|
|
10923
|
+
var link = linkTask(task);
|
|
10844
10924
|
if (link === null) {
|
|
10845
10925
|
return '';
|
|
10846
10926
|
}
|
|
10847
10927
|
var href = link.href, title = link.title;
|
|
10848
|
-
var
|
|
10849
|
-
return "click ".concat(
|
|
10928
|
+
var taskName = parameterNameToTaskName(task.resultingParameterName);
|
|
10929
|
+
return "click ".concat(taskName, " href \"").concat(href, "\" \"").concat(title, "\";");
|
|
10850
10930
|
})
|
|
10851
10931
|
.filter(function (line) { return line !== ''; })
|
|
10852
10932
|
.join('\n')), "\n\n classDef input color: grey;\n classDef output color: grey;\n\n end;\n\n "); });
|
|
@@ -10877,7 +10957,7 @@
|
|
|
10877
10957
|
case 1:
|
|
10878
10958
|
pipelineJson = _a.sent();
|
|
10879
10959
|
promptbookMermaid_1 = renderPromptbookMermaid(pipelineJson, {
|
|
10880
|
-
|
|
10960
|
+
linkTask: function (task) {
|
|
10881
10961
|
return { href: "#".concat(task.name), title: task.title };
|
|
10882
10962
|
},
|
|
10883
10963
|
});
|
|
@@ -11220,7 +11300,7 @@
|
|
|
11220
11300
|
if (/^\s*\p{Extended_Pictographic}/u.test(promptExecution.prompt.title)) {
|
|
11221
11301
|
hash = '-' + hash;
|
|
11222
11302
|
}
|
|
11223
|
-
// TODO: Make working hash link for the
|
|
11303
|
+
// TODO: Make working hash link for the task in md + pdf
|
|
11224
11304
|
return "- [".concat(promptExecution.prompt.title, "](#").concat(hash, ")");
|
|
11225
11305
|
})
|
|
11226
11306
|
.join('\n');
|
|
@@ -11229,7 +11309,7 @@
|
|
|
11229
11309
|
'## ⌚ Time chart' +
|
|
11230
11310
|
'\n\n' +
|
|
11231
11311
|
createMarkdownChart({
|
|
11232
|
-
nameHeader: '
|
|
11312
|
+
nameHeader: 'Task',
|
|
11233
11313
|
valueHeader: 'Timeline',
|
|
11234
11314
|
items: timingItems,
|
|
11235
11315
|
width: chartsWidth,
|
|
@@ -11240,7 +11320,7 @@
|
|
|
11240
11320
|
'## 💸 Cost chart' +
|
|
11241
11321
|
'\n\n' +
|
|
11242
11322
|
createMarkdownChart({
|
|
11243
|
-
nameHeader: '
|
|
11323
|
+
nameHeader: 'Task',
|
|
11244
11324
|
valueHeader: 'Cost',
|
|
11245
11325
|
items: costItems,
|
|
11246
11326
|
width: chartsWidth,
|
|
@@ -11539,7 +11619,7 @@
|
|
|
11539
11619
|
return [4 /*yield*/, prompts__default["default"](questions)];
|
|
11540
11620
|
case 16:
|
|
11541
11621
|
response = _m.sent();
|
|
11542
|
-
// <- TODO: [🧠] Change behavior according to the formfactor
|
|
11622
|
+
// <- TODO: [🧠][🍼] Change behavior according to the formfactor
|
|
11543
11623
|
inputParameters = __assign(__assign({}, inputParameters), response);
|
|
11544
11624
|
// TODO: Maybe do some validation of the response (and --json argument which is passed)
|
|
11545
11625
|
if (isVerbose) {
|