@promptbook/markdown-utils 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 +46 -30
- package/esm/index.es.js +46 -46
- 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 +46 -46
- 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
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
*
|
|
23
23
|
* @see https://github.com/webgptorg/promptbook
|
|
24
24
|
*/
|
|
25
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.75.0
|
|
25
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.75.0';
|
|
26
26
|
/**
|
|
27
27
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
28
28
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -271,7 +271,7 @@
|
|
|
271
271
|
function extractOneBlockFromMarkdown(markdown) {
|
|
272
272
|
var codeBlocks = extractAllBlocksFromMarkdown(markdown);
|
|
273
273
|
if (codeBlocks.length !== 1) {
|
|
274
|
-
throw new ParseError(spaceTrim__default["default"](function (block) { return "\n There should be exactly 1 code block in
|
|
274
|
+
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 "); }));
|
|
275
275
|
}
|
|
276
276
|
return codeBlocks[0];
|
|
277
277
|
}
|
|
@@ -358,7 +358,7 @@
|
|
|
358
358
|
* TODO: [🏢] Make this logic part of `JsonFormatDefinition` or `isValidJsonString`
|
|
359
359
|
*/
|
|
360
360
|
|
|
361
|
-
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:"./
|
|
361
|
+
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"}];
|
|
362
362
|
|
|
363
363
|
/**
|
|
364
364
|
* Prettify the html code
|
|
@@ -424,7 +424,7 @@
|
|
|
424
424
|
return isInput;
|
|
425
425
|
})), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
426
426
|
var parameter = _h.value;
|
|
427
|
-
commands.push("INPUT PARAMETER ".concat(
|
|
427
|
+
commands.push("INPUT PARAMETER ".concat(taskParameterJsonToString(parameter)));
|
|
428
428
|
}
|
|
429
429
|
}
|
|
430
430
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
@@ -440,7 +440,7 @@
|
|
|
440
440
|
return isOutput;
|
|
441
441
|
})), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
442
442
|
var parameter = _k.value;
|
|
443
|
-
commands.push("OUTPUT PARAMETER ".concat(
|
|
443
|
+
commands.push("OUTPUT PARAMETER ".concat(taskParameterJsonToString(parameter)));
|
|
444
444
|
}
|
|
445
445
|
}
|
|
446
446
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
@@ -454,12 +454,12 @@
|
|
|
454
454
|
pipelineString += commands.map(function (command) { return "- ".concat(command); }).join('\n');
|
|
455
455
|
try {
|
|
456
456
|
for (var tasks_1 = __values(tasks), tasks_1_1 = tasks_1.next(); !tasks_1_1.done; tasks_1_1 = tasks_1.next()) {
|
|
457
|
-
var
|
|
457
|
+
var task = tasks_1_1.value;
|
|
458
458
|
var
|
|
459
459
|
/* Note: Not using:> name, */
|
|
460
|
-
title_1 =
|
|
460
|
+
title_1 = task.title, description_1 = task.description,
|
|
461
461
|
/* Note: dependentParameterNames, */
|
|
462
|
-
jokers =
|
|
462
|
+
jokers = task.jokerParameterNames, taskType = task.taskType, content = task.content, postprocessing = task.postprocessingFunctionNames, expectations = task.expectations, format = task.format, resultingParameterName = task.resultingParameterName;
|
|
463
463
|
pipelineString += '\n\n';
|
|
464
464
|
pipelineString += "## ".concat(title_1);
|
|
465
465
|
if (description_1) {
|
|
@@ -469,9 +469,10 @@
|
|
|
469
469
|
var commands_1 = [];
|
|
470
470
|
var contentLanguage = 'text';
|
|
471
471
|
if (taskType === 'PROMPT_TASK') {
|
|
472
|
-
var modelRequirements =
|
|
472
|
+
var modelRequirements = task.modelRequirements;
|
|
473
473
|
var _l = modelRequirements || {}, modelName = _l.modelName, modelVariant = _l.modelVariant;
|
|
474
|
-
|
|
474
|
+
// Note: Do nothing, it is default
|
|
475
|
+
// commands.push(`PROMPT`);
|
|
475
476
|
if (modelVariant) {
|
|
476
477
|
commands_1.push("MODEL VARIANT ".concat(capitalize(modelVariant)));
|
|
477
478
|
}
|
|
@@ -484,16 +485,16 @@
|
|
|
484
485
|
// Note: Nothing special here
|
|
485
486
|
}
|
|
486
487
|
else if (taskType === 'SCRIPT_TASK') {
|
|
487
|
-
commands_1.push("SCRIPT
|
|
488
|
-
if (
|
|
489
|
-
contentLanguage =
|
|
488
|
+
commands_1.push("SCRIPT");
|
|
489
|
+
if (task.contentLanguage) {
|
|
490
|
+
contentLanguage = task.contentLanguage;
|
|
490
491
|
}
|
|
491
492
|
else {
|
|
492
493
|
contentLanguage = '';
|
|
493
494
|
}
|
|
494
495
|
}
|
|
495
496
|
else if (taskType === 'DIALOG_TASK') {
|
|
496
|
-
commands_1.push("DIALOG
|
|
497
|
+
commands_1.push("DIALOG");
|
|
497
498
|
// Note: Nothing special here
|
|
498
499
|
} // <- }else if([🅱]
|
|
499
500
|
if (jokers) {
|
|
@@ -568,7 +569,7 @@
|
|
|
568
569
|
pipelineString += '\n';
|
|
569
570
|
pipelineString += '```';
|
|
570
571
|
pipelineString += '\n\n';
|
|
571
|
-
pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!! If the parameter here has description, add it and use
|
|
572
|
+
pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!! If the parameter here has description, add it and use taskParameterJsonToString
|
|
572
573
|
}
|
|
573
574
|
}
|
|
574
575
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
@@ -583,8 +584,8 @@
|
|
|
583
584
|
/**
|
|
584
585
|
* @private internal utility of `pipelineJsonToString`
|
|
585
586
|
*/
|
|
586
|
-
function
|
|
587
|
-
var name =
|
|
587
|
+
function taskParameterJsonToString(taskParameterJson) {
|
|
588
|
+
var name = taskParameterJson.name, description = taskParameterJson.description;
|
|
588
589
|
var parameterString = "{".concat(name, "}");
|
|
589
590
|
if (description) {
|
|
590
591
|
parameterString = "".concat(parameterString, " ").concat(description);
|
|
@@ -592,7 +593,7 @@
|
|
|
592
593
|
return parameterString;
|
|
593
594
|
}
|
|
594
595
|
/**
|
|
595
|
-
* TODO: [🛋] Implement new features and commands into `pipelineJsonToString` + `
|
|
596
|
+
* TODO: [🛋] Implement new features and commands into `pipelineJsonToString` + `taskParameterJsonToString` , use `stringifyCommand`
|
|
596
597
|
* TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
|
|
597
598
|
* TODO: [🏛] Maybe make some markdown builder
|
|
598
599
|
* TODO: [🏛] Escape all
|
|
@@ -818,7 +819,6 @@
|
|
|
818
819
|
* @private within the repository
|
|
819
820
|
*/
|
|
820
821
|
var GENERATOR_WARNING = "\u26A0\uFE0F WARNING: This code has been generated so that any manual changes will be overwritten";
|
|
821
|
-
// <- TODO: [🐊] Pick the best claim
|
|
822
822
|
/**
|
|
823
823
|
* When the title is not provided, the default title is used
|
|
824
824
|
*
|
|
@@ -1290,20 +1290,20 @@
|
|
|
1290
1290
|
}
|
|
1291
1291
|
finally { if (e_3) throw e_3.error; }
|
|
1292
1292
|
}
|
|
1293
|
-
var
|
|
1293
|
+
var unresovedTasks = __spreadArray([], __read(pipeline.tasks), false);
|
|
1294
1294
|
var loopLimit = LOOP_LIMIT;
|
|
1295
1295
|
var _loop_3 = function () {
|
|
1296
1296
|
if (loopLimit-- < 0) {
|
|
1297
1297
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
1298
1298
|
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 "); }));
|
|
1299
1299
|
}
|
|
1300
|
-
var
|
|
1300
|
+
var currentlyResovedTasks = unresovedTasks.filter(function (task) {
|
|
1301
1301
|
return task.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
|
|
1302
1302
|
});
|
|
1303
|
-
if (
|
|
1303
|
+
if (currentlyResovedTasks.length === 0) {
|
|
1304
1304
|
throw new PipelineLogicError(
|
|
1305
1305
|
// TODO: [🐎] DRY
|
|
1306
|
-
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(
|
|
1306
|
+
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
|
|
1307
1307
|
.map(function (_a) {
|
|
1308
1308
|
var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
|
|
1309
1309
|
return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
|
|
@@ -1322,13 +1322,13 @@
|
|
|
1322
1322
|
.map(function (name) { return "- Parameter `{".concat(name, "}`"); })
|
|
1323
1323
|
.join('\n')), "\n\n\n "); }));
|
|
1324
1324
|
}
|
|
1325
|
-
resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(
|
|
1325
|
+
resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTasks.map(function (_a) {
|
|
1326
1326
|
var resultingParameterName = _a.resultingParameterName;
|
|
1327
1327
|
return resultingParameterName;
|
|
1328
1328
|
})), false);
|
|
1329
|
-
|
|
1329
|
+
unresovedTasks = unresovedTasks.filter(function (task) { return !currentlyResovedTasks.includes(task); });
|
|
1330
1330
|
};
|
|
1331
|
-
while (
|
|
1331
|
+
while (unresovedTasks.length > 0) {
|
|
1332
1332
|
_loop_3();
|
|
1333
1333
|
}
|
|
1334
1334
|
// TODO: !!!!!! Test that pipeline interface implements declared formfactor interface
|
|
@@ -1390,7 +1390,7 @@
|
|
|
1390
1390
|
/**
|
|
1391
1391
|
* Parses the task and returns the list of all parameter names
|
|
1392
1392
|
*
|
|
1393
|
-
* @param template the
|
|
1393
|
+
* @param template the string template with parameters in {curly} braces
|
|
1394
1394
|
* @returns the list of parameter names
|
|
1395
1395
|
* @public exported from `@promptbook/utils`
|
|
1396
1396
|
*/
|
|
@@ -1424,13 +1424,13 @@
|
|
|
1424
1424
|
var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, tasks = pipeline.tasks;
|
|
1425
1425
|
personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
|
|
1426
1426
|
knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
|
|
1427
|
-
tasks = tasks.map(function (
|
|
1428
|
-
var dependentParameterNames =
|
|
1429
|
-
var parameterNames = extractParameterNames(
|
|
1427
|
+
tasks = tasks.map(function (task) {
|
|
1428
|
+
var dependentParameterNames = task.dependentParameterNames;
|
|
1429
|
+
var parameterNames = extractParameterNames(task.preparedContent || '');
|
|
1430
1430
|
dependentParameterNames = dependentParameterNames.filter(function (dependentParameterName) { return !parameterNames.has(dependentParameterName); });
|
|
1431
|
-
var
|
|
1432
|
-
delete
|
|
1433
|
-
return
|
|
1431
|
+
var taskUnprepared = __assign(__assign({}, task), { dependentParameterNames: dependentParameterNames });
|
|
1432
|
+
delete taskUnprepared.preparedContent;
|
|
1433
|
+
return taskUnprepared;
|
|
1434
1434
|
});
|
|
1435
1435
|
return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), { tasks: tasks, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }));
|
|
1436
1436
|
}
|
|
@@ -2144,7 +2144,7 @@
|
|
|
2144
2144
|
* TODO: [🐠] Maybe base this on `makeValidator`
|
|
2145
2145
|
* TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
|
|
2146
2146
|
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
2147
|
-
* - [🏍] ? Is context in each
|
|
2147
|
+
* - [🏍] ? Is context in each task
|
|
2148
2148
|
* - [♨] Are examples prepared
|
|
2149
2149
|
* - [♨] Are tasks prepared
|
|
2150
2150
|
*/
|
|
@@ -3518,10 +3518,10 @@
|
|
|
3518
3518
|
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
|
|
3519
3519
|
tasks = pipeline.tasks, pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
|
|
3520
3520
|
tasksPrepared = new Array(tasks.length);
|
|
3521
|
-
return [4 /*yield*/, forEachAsync(tasks, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (
|
|
3522
|
-
var dependentParameterNames, preparedContent,
|
|
3521
|
+
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 () {
|
|
3522
|
+
var dependentParameterNames, preparedContent, preparedTask;
|
|
3523
3523
|
return __generator(this, function (_a) {
|
|
3524
|
-
dependentParameterNames =
|
|
3524
|
+
dependentParameterNames = task.dependentParameterNames;
|
|
3525
3525
|
preparedContent = undefined;
|
|
3526
3526
|
if (knowledgePiecesCount > 0 && !dependentParameterNames.includes('knowledge')) {
|
|
3527
3527
|
preparedContent = spaceTrim.spaceTrim("\n {content}\n\n ## Knowledge\n\n {knowledge}\n ");
|
|
@@ -3530,8 +3530,8 @@
|
|
|
3530
3530
|
'knowledge',
|
|
3531
3531
|
], false);
|
|
3532
3532
|
}
|
|
3533
|
-
|
|
3534
|
-
tasksPrepared[index] =
|
|
3533
|
+
preparedTask = __assign(__assign({}, task), { dependentParameterNames: dependentParameterNames, preparedContent: preparedContent });
|
|
3534
|
+
tasksPrepared[index] = preparedTask;
|
|
3535
3535
|
return [2 /*return*/];
|
|
3536
3536
|
});
|
|
3537
3537
|
}); })];
|
|
@@ -3543,8 +3543,8 @@
|
|
|
3543
3543
|
});
|
|
3544
3544
|
}
|
|
3545
3545
|
/**
|
|
3546
|
-
* TODO: [🧠] Add context to each
|
|
3547
|
-
* TODO: [🧠] What is better name `
|
|
3546
|
+
* TODO: [🧠] Add context to each task (if missing)
|
|
3547
|
+
* TODO: [🧠] What is better name `prepareTask` or `prepareTaskAndParameters`
|
|
3548
3548
|
* TODO: [♨][main] !!! Prepare index the examples and maybe tasks
|
|
3549
3549
|
* TODO: Write tests for `preparePipeline`
|
|
3550
3550
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
@@ -3630,7 +3630,7 @@
|
|
|
3630
3630
|
})];
|
|
3631
3631
|
case 3:
|
|
3632
3632
|
tasksPrepared = (_c.sent()).tasksPrepared;
|
|
3633
|
-
// ----- /
|
|
3633
|
+
// ----- /Tasks preparation -----
|
|
3634
3634
|
// Note: Count total usage
|
|
3635
3635
|
currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
|
|
3636
3636
|
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { tasks: __spreadArray([], __read(tasksPrepared), false),
|
|
@@ -3699,16 +3699,16 @@
|
|
|
3699
3699
|
*/
|
|
3700
3700
|
|
|
3701
3701
|
/**
|
|
3702
|
-
* Parses the
|
|
3702
|
+
* Parses the task and returns the set of all used parameters
|
|
3703
3703
|
*
|
|
3704
|
-
* @param
|
|
3704
|
+
* @param task the task with used parameters
|
|
3705
3705
|
* @returns the set of parameter names
|
|
3706
3706
|
* @throws {ParseError} if the script is invalid
|
|
3707
3707
|
* @public exported from `@promptbook/utils`
|
|
3708
3708
|
*/
|
|
3709
|
-
function extractParameterNamesFromTask(
|
|
3709
|
+
function extractParameterNamesFromTask(task) {
|
|
3710
3710
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
3711
|
-
var title =
|
|
3711
|
+
var title = task.title, description = task.description, taskType = task.taskType, content = task.content, preparedContent = task.preparedContent, jokerParameterNames = task.jokerParameterNames, foreach = task.foreach;
|
|
3712
3712
|
var parameterNames = new Set();
|
|
3713
3713
|
try {
|
|
3714
3714
|
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()) {
|