@promptbook/pdf 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 +45 -44
- 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 +2 -2
- package/umd/index.umd.js +45 -44
- 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
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
function TODO_USE() {
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
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:"./
|
|
179
|
+
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"}];
|
|
180
180
|
|
|
181
181
|
/**
|
|
182
182
|
* Prettify the html code
|
|
@@ -251,7 +251,7 @@
|
|
|
251
251
|
return isInput;
|
|
252
252
|
})), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
253
253
|
var parameter = _h.value;
|
|
254
|
-
commands.push("INPUT PARAMETER ".concat(
|
|
254
|
+
commands.push("INPUT PARAMETER ".concat(taskParameterJsonToString(parameter)));
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
257
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
@@ -267,7 +267,7 @@
|
|
|
267
267
|
return isOutput;
|
|
268
268
|
})), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
269
269
|
var parameter = _k.value;
|
|
270
|
-
commands.push("OUTPUT PARAMETER ".concat(
|
|
270
|
+
commands.push("OUTPUT PARAMETER ".concat(taskParameterJsonToString(parameter)));
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
273
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
@@ -281,12 +281,12 @@
|
|
|
281
281
|
pipelineString += commands.map(function (command) { return "- ".concat(command); }).join('\n');
|
|
282
282
|
try {
|
|
283
283
|
for (var tasks_1 = __values(tasks), tasks_1_1 = tasks_1.next(); !tasks_1_1.done; tasks_1_1 = tasks_1.next()) {
|
|
284
|
-
var
|
|
284
|
+
var task = tasks_1_1.value;
|
|
285
285
|
var
|
|
286
286
|
/* Note: Not using:> name, */
|
|
287
|
-
title_1 =
|
|
287
|
+
title_1 = task.title, description_1 = task.description,
|
|
288
288
|
/* Note: dependentParameterNames, */
|
|
289
|
-
jokers =
|
|
289
|
+
jokers = task.jokerParameterNames, taskType = task.taskType, content = task.content, postprocessing = task.postprocessingFunctionNames, expectations = task.expectations, format = task.format, resultingParameterName = task.resultingParameterName;
|
|
290
290
|
pipelineString += '\n\n';
|
|
291
291
|
pipelineString += "## ".concat(title_1);
|
|
292
292
|
if (description_1) {
|
|
@@ -296,9 +296,10 @@
|
|
|
296
296
|
var commands_1 = [];
|
|
297
297
|
var contentLanguage = 'text';
|
|
298
298
|
if (taskType === 'PROMPT_TASK') {
|
|
299
|
-
var modelRequirements =
|
|
299
|
+
var modelRequirements = task.modelRequirements;
|
|
300
300
|
var _l = modelRequirements || {}, modelName = _l.modelName, modelVariant = _l.modelVariant;
|
|
301
|
-
|
|
301
|
+
// Note: Do nothing, it is default
|
|
302
|
+
// commands.push(`PROMPT`);
|
|
302
303
|
if (modelVariant) {
|
|
303
304
|
commands_1.push("MODEL VARIANT ".concat(capitalize(modelVariant)));
|
|
304
305
|
}
|
|
@@ -311,16 +312,16 @@
|
|
|
311
312
|
// Note: Nothing special here
|
|
312
313
|
}
|
|
313
314
|
else if (taskType === 'SCRIPT_TASK') {
|
|
314
|
-
commands_1.push("SCRIPT
|
|
315
|
-
if (
|
|
316
|
-
contentLanguage =
|
|
315
|
+
commands_1.push("SCRIPT");
|
|
316
|
+
if (task.contentLanguage) {
|
|
317
|
+
contentLanguage = task.contentLanguage;
|
|
317
318
|
}
|
|
318
319
|
else {
|
|
319
320
|
contentLanguage = '';
|
|
320
321
|
}
|
|
321
322
|
}
|
|
322
323
|
else if (taskType === 'DIALOG_TASK') {
|
|
323
|
-
commands_1.push("DIALOG
|
|
324
|
+
commands_1.push("DIALOG");
|
|
324
325
|
// Note: Nothing special here
|
|
325
326
|
} // <- }else if([🅱]
|
|
326
327
|
if (jokers) {
|
|
@@ -395,7 +396,7 @@
|
|
|
395
396
|
pipelineString += '\n';
|
|
396
397
|
pipelineString += '```';
|
|
397
398
|
pipelineString += '\n\n';
|
|
398
|
-
pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!! If the parameter here has description, add it and use
|
|
399
|
+
pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!! If the parameter here has description, add it and use taskParameterJsonToString
|
|
399
400
|
}
|
|
400
401
|
}
|
|
401
402
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
@@ -410,8 +411,8 @@
|
|
|
410
411
|
/**
|
|
411
412
|
* @private internal utility of `pipelineJsonToString`
|
|
412
413
|
*/
|
|
413
|
-
function
|
|
414
|
-
var name =
|
|
414
|
+
function taskParameterJsonToString(taskParameterJson) {
|
|
415
|
+
var name = taskParameterJson.name, description = taskParameterJson.description;
|
|
415
416
|
var parameterString = "{".concat(name, "}");
|
|
416
417
|
if (description) {
|
|
417
418
|
parameterString = "".concat(parameterString, " ").concat(description);
|
|
@@ -419,7 +420,7 @@
|
|
|
419
420
|
return parameterString;
|
|
420
421
|
}
|
|
421
422
|
/**
|
|
422
|
-
* TODO: [🛋] Implement new features and commands into `pipelineJsonToString` + `
|
|
423
|
+
* TODO: [🛋] Implement new features and commands into `pipelineJsonToString` + `taskParameterJsonToString` , use `stringifyCommand`
|
|
423
424
|
* TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
|
|
424
425
|
* TODO: [🏛] Maybe make some markdown builder
|
|
425
426
|
* TODO: [🏛] Escape all
|
|
@@ -1123,20 +1124,20 @@
|
|
|
1123
1124
|
}
|
|
1124
1125
|
finally { if (e_3) throw e_3.error; }
|
|
1125
1126
|
}
|
|
1126
|
-
var
|
|
1127
|
+
var unresovedTasks = __spreadArray([], __read(pipeline.tasks), false);
|
|
1127
1128
|
var loopLimit = LOOP_LIMIT;
|
|
1128
1129
|
var _loop_3 = function () {
|
|
1129
1130
|
if (loopLimit-- < 0) {
|
|
1130
1131
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
1131
1132
|
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 "); }));
|
|
1132
1133
|
}
|
|
1133
|
-
var
|
|
1134
|
+
var currentlyResovedTasks = unresovedTasks.filter(function (task) {
|
|
1134
1135
|
return task.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
|
|
1135
1136
|
});
|
|
1136
|
-
if (
|
|
1137
|
+
if (currentlyResovedTasks.length === 0) {
|
|
1137
1138
|
throw new PipelineLogicError(
|
|
1138
1139
|
// TODO: [🐎] DRY
|
|
1139
|
-
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(
|
|
1140
|
+
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
|
|
1140
1141
|
.map(function (_a) {
|
|
1141
1142
|
var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
|
|
1142
1143
|
return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
|
|
@@ -1155,13 +1156,13 @@
|
|
|
1155
1156
|
.map(function (name) { return "- Parameter `{".concat(name, "}`"); })
|
|
1156
1157
|
.join('\n')), "\n\n\n "); }));
|
|
1157
1158
|
}
|
|
1158
|
-
resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(
|
|
1159
|
+
resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTasks.map(function (_a) {
|
|
1159
1160
|
var resultingParameterName = _a.resultingParameterName;
|
|
1160
1161
|
return resultingParameterName;
|
|
1161
1162
|
})), false);
|
|
1162
|
-
|
|
1163
|
+
unresovedTasks = unresovedTasks.filter(function (task) { return !currentlyResovedTasks.includes(task); });
|
|
1163
1164
|
};
|
|
1164
|
-
while (
|
|
1165
|
+
while (unresovedTasks.length > 0) {
|
|
1165
1166
|
_loop_3();
|
|
1166
1167
|
}
|
|
1167
1168
|
// TODO: !!!!!! Test that pipeline interface implements declared formfactor interface
|
|
@@ -1223,7 +1224,7 @@
|
|
|
1223
1224
|
/**
|
|
1224
1225
|
* Parses the task and returns the list of all parameter names
|
|
1225
1226
|
*
|
|
1226
|
-
* @param template the
|
|
1227
|
+
* @param template the string template with parameters in {curly} braces
|
|
1227
1228
|
* @returns the list of parameter names
|
|
1228
1229
|
* @public exported from `@promptbook/utils`
|
|
1229
1230
|
*/
|
|
@@ -1257,13 +1258,13 @@
|
|
|
1257
1258
|
var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, tasks = pipeline.tasks;
|
|
1258
1259
|
personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
|
|
1259
1260
|
knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
|
|
1260
|
-
tasks = tasks.map(function (
|
|
1261
|
-
var dependentParameterNames =
|
|
1262
|
-
var parameterNames = extractParameterNames(
|
|
1261
|
+
tasks = tasks.map(function (task) {
|
|
1262
|
+
var dependentParameterNames = task.dependentParameterNames;
|
|
1263
|
+
var parameterNames = extractParameterNames(task.preparedContent || '');
|
|
1263
1264
|
dependentParameterNames = dependentParameterNames.filter(function (dependentParameterName) { return !parameterNames.has(dependentParameterName); });
|
|
1264
|
-
var
|
|
1265
|
-
delete
|
|
1266
|
-
return
|
|
1265
|
+
var taskUnprepared = __assign(__assign({}, task), { dependentParameterNames: dependentParameterNames });
|
|
1266
|
+
delete taskUnprepared.preparedContent;
|
|
1267
|
+
return taskUnprepared;
|
|
1267
1268
|
});
|
|
1268
1269
|
return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), { tasks: tasks, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }));
|
|
1269
1270
|
}
|
|
@@ -1961,7 +1962,7 @@
|
|
|
1961
1962
|
* TODO: [🐠] Maybe base this on `makeValidator`
|
|
1962
1963
|
* TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
|
|
1963
1964
|
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
1964
|
-
* - [🏍] ? Is context in each
|
|
1965
|
+
* - [🏍] ? Is context in each task
|
|
1965
1966
|
* - [♨] Are examples prepared
|
|
1966
1967
|
* - [♨] Are tasks prepared
|
|
1967
1968
|
*/
|
|
@@ -3335,10 +3336,10 @@
|
|
|
3335
3336
|
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
|
|
3336
3337
|
tasks = pipeline.tasks, pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
|
|
3337
3338
|
tasksPrepared = new Array(tasks.length);
|
|
3338
|
-
return [4 /*yield*/, forEachAsync(tasks, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (
|
|
3339
|
-
var dependentParameterNames, preparedContent,
|
|
3339
|
+
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 () {
|
|
3340
|
+
var dependentParameterNames, preparedContent, preparedTask;
|
|
3340
3341
|
return __generator(this, function (_a) {
|
|
3341
|
-
dependentParameterNames =
|
|
3342
|
+
dependentParameterNames = task.dependentParameterNames;
|
|
3342
3343
|
preparedContent = undefined;
|
|
3343
3344
|
if (knowledgePiecesCount > 0 && !dependentParameterNames.includes('knowledge')) {
|
|
3344
3345
|
preparedContent = spaceTrim.spaceTrim("\n {content}\n\n ## Knowledge\n\n {knowledge}\n ");
|
|
@@ -3347,8 +3348,8 @@
|
|
|
3347
3348
|
'knowledge',
|
|
3348
3349
|
], false);
|
|
3349
3350
|
}
|
|
3350
|
-
|
|
3351
|
-
tasksPrepared[index] =
|
|
3351
|
+
preparedTask = __assign(__assign({}, task), { dependentParameterNames: dependentParameterNames, preparedContent: preparedContent });
|
|
3352
|
+
tasksPrepared[index] = preparedTask;
|
|
3352
3353
|
return [2 /*return*/];
|
|
3353
3354
|
});
|
|
3354
3355
|
}); })];
|
|
@@ -3360,8 +3361,8 @@
|
|
|
3360
3361
|
});
|
|
3361
3362
|
}
|
|
3362
3363
|
/**
|
|
3363
|
-
* TODO: [🧠] Add context to each
|
|
3364
|
-
* TODO: [🧠] What is better name `
|
|
3364
|
+
* TODO: [🧠] Add context to each task (if missing)
|
|
3365
|
+
* TODO: [🧠] What is better name `prepareTask` or `prepareTaskAndParameters`
|
|
3365
3366
|
* TODO: [♨][main] !!! Prepare index the examples and maybe tasks
|
|
3366
3367
|
* TODO: Write tests for `preparePipeline`
|
|
3367
3368
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
@@ -3447,7 +3448,7 @@
|
|
|
3447
3448
|
})];
|
|
3448
3449
|
case 3:
|
|
3449
3450
|
tasksPrepared = (_c.sent()).tasksPrepared;
|
|
3450
|
-
// ----- /
|
|
3451
|
+
// ----- /Tasks preparation -----
|
|
3451
3452
|
// Note: Count total usage
|
|
3452
3453
|
currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
|
|
3453
3454
|
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { tasks: __spreadArray([], __read(tasksPrepared), false),
|
|
@@ -3516,16 +3517,16 @@
|
|
|
3516
3517
|
*/
|
|
3517
3518
|
|
|
3518
3519
|
/**
|
|
3519
|
-
* Parses the
|
|
3520
|
+
* Parses the task and returns the set of all used parameters
|
|
3520
3521
|
*
|
|
3521
|
-
* @param
|
|
3522
|
+
* @param task the task with used parameters
|
|
3522
3523
|
* @returns the set of parameter names
|
|
3523
3524
|
* @throws {ParseError} if the script is invalid
|
|
3524
3525
|
* @public exported from `@promptbook/utils`
|
|
3525
3526
|
*/
|
|
3526
|
-
function extractParameterNamesFromTask(
|
|
3527
|
+
function extractParameterNamesFromTask(task) {
|
|
3527
3528
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
3528
|
-
var title =
|
|
3529
|
+
var title = task.title, description = task.description, taskType = task.taskType, content = task.content, preparedContent = task.preparedContent, jokerParameterNames = task.jokerParameterNames, foreach = task.foreach;
|
|
3529
3530
|
var parameterNames = new Set();
|
|
3530
3531
|
try {
|
|
3531
3532
|
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()) {
|