@promptbook/markdown-utils 0.75.0-0 → 0.75.0-2
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 +1 -0
- package/esm/index.es.js +276 -236
- package/esm/index.es.js.map +1 -1
- package/esm/typings/promptbook-collection/index.d.ts +6 -6
- package/esm/typings/src/_packages/core.index.d.ts +29 -19
- package/esm/typings/src/_packages/types.index.d.ts +58 -50
- package/esm/typings/src/_packages/utils.index.d.ts +4 -4
- package/esm/typings/src/cli/cli-commands/about.d.ts +1 -0
- package/esm/typings/src/cli/cli-commands/hello.d.ts +1 -0
- package/esm/typings/src/cli/cli-commands/make.d.ts +1 -0
- package/esm/typings/src/cli/cli-commands/prettify.d.ts +1 -0
- package/esm/typings/src/cli/cli-commands/run.d.ts +1 -0
- package/esm/typings/src/cli/cli-commands/test-command.d.ts +1 -0
- package/esm/typings/src/cli/main.d.ts +1 -0
- package/esm/typings/src/collection/PipelineCollection.d.ts +1 -1
- package/esm/typings/src/collection/SimplePipelineCollection.d.ts +1 -1
- package/esm/typings/src/collection/collectionToJson.d.ts +1 -1
- package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +1 -1
- package/esm/typings/src/collection/constructors/createCollectionFromPromise.d.ts +1 -1
- package/esm/typings/src/commands/EXPECT/ExpectCommand.d.ts +2 -2
- package/esm/typings/src/commands/EXPECT/expectCommandParser.d.ts +2 -2
- package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +2 -2
- package/esm/typings/src/commands/FORMAT/formatCommandParser.d.ts +2 -2
- package/esm/typings/src/commands/JOKER/jokerCommandParser.d.ts +2 -2
- package/esm/typings/src/commands/POSTPROCESS/postprocessCommandParser.d.ts +2 -2
- package/esm/typings/src/commands/SECTION/SectionCommand.d.ts +11 -0
- package/esm/typings/src/commands/SECTION/SectionType.d.ts +13 -0
- package/esm/typings/src/commands/{TEMPLATE/templateCommandParser.d.ts → SECTION/sectionCommandParser.d.ts} +6 -6
- package/esm/typings/src/commands/_common/types/Command.d.ts +1 -1
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +17 -17
- package/esm/typings/src/commands/_common/types/CommandUsagePlaces.d.ts +1 -1
- package/esm/typings/src/commands/index.d.ts +4 -1
- package/esm/typings/src/config.d.ts +3 -1
- package/esm/typings/src/conversion/pipelineJsonToString.d.ts +2 -2
- package/esm/typings/src/conversion/pipelineStringToJson.d.ts +2 -2
- package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +3 -3
- package/esm/typings/src/conversion/prettify/prettifyPipelineString.d.ts +1 -1
- package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +3 -3
- package/esm/typings/src/conversion/utils/{extractParameterNamesFromTemplate.d.ts → extractParameterNamesFromTask.d.ts} +2 -2
- package/esm/typings/src/conversion/utils/renameParameter.d.ts +1 -1
- package/esm/typings/src/conversion/validation/_importPipeline.d.ts +3 -2
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +1 -1
- package/esm/typings/src/errors/index.d.ts +3 -0
- package/esm/typings/src/execution/PipelineExecutorResult.d.ts +2 -2
- package/esm/typings/src/execution/PromptResultUsage.d.ts +1 -1
- package/esm/typings/src/execution/createPipelineExecutor/{$OngoingTemplateResult.d.ts → $OngoingTaskResult.d.ts} +1 -1
- package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorOptions.d.ts +1 -1
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +1 -1
- package/esm/typings/src/execution/createPipelineExecutor/{20-executeTemplate.d.ts → 20-executeTask.d.ts} +7 -7
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +5 -5
- package/esm/typings/src/execution/createPipelineExecutor/filterJustOutputParameters.d.ts +1 -1
- package/esm/typings/src/execution/createPipelineExecutor/{getContextForTemplate.d.ts → getContextForTask.d.ts} +2 -2
- package/esm/typings/src/execution/createPipelineExecutor/{getExamplesForTemplate.d.ts → getExamplesForTask.d.ts} +2 -2
- package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTask.d.ts +27 -0
- package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTask.d.ts +30 -0
- package/esm/typings/src/{types → execution}/execution-report/ExecutionPromptReportJson.d.ts +2 -2
- package/esm/typings/src/{types → execution}/execution-report/ExecutionReportJson.d.ts +4 -4
- package/esm/typings/src/{types → execution}/execution-report/ExecutionReportStringOptions.d.ts +1 -1
- package/esm/typings/src/execution/utils/checkExpectations.d.ts +1 -1
- package/esm/typings/src/execution/utils/usage-constants.d.ts +3 -0
- package/esm/typings/src/formats/index.d.ts +3 -0
- package/esm/typings/src/formfactors/_boilerplate/BoilerplateFormfactorDefinition.d.ts +14 -0
- package/esm/typings/src/formfactors/_common/AbstractFormfactorDefinition.d.ts +9 -1
- package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +4 -1
- package/esm/typings/src/formfactors/chatbot/ChatbotFormfactorDefinition.d.ts +15 -0
- package/esm/typings/src/formfactors/generic/GenericFormfactorDefinition.d.ts +5 -1
- package/esm/typings/src/formfactors/index.d.ts +39 -3
- package/esm/typings/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +14 -0
- package/esm/typings/src/formfactors/sheets/SheetsFormfactorDefinition.d.ts +14 -0
- package/esm/typings/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +14 -0
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -0
- package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +3 -0
- package/esm/typings/src/llm-providers/anthropic-claude/register-constructor.d.ts +1 -0
- package/esm/typings/src/llm-providers/azure-openai/register-configuration.d.ts +3 -0
- package/esm/typings/src/llm-providers/azure-openai/register-constructor.d.ts +1 -0
- package/esm/typings/src/llm-providers/mocked/$fakeTextToExpectations.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -0
- package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +3 -0
- package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +1 -0
- package/esm/typings/src/personas/preparePersona.d.ts +1 -1
- package/esm/typings/src/pipeline/{pipeline-interface → PipelineInterface}/PipelineInterface.d.ts +5 -2
- package/esm/typings/src/pipeline/PipelineInterface/constants.d.ts +14 -0
- package/esm/typings/src/pipeline/{pipeline-interface → PipelineInterface}/getPipelineInterface.d.ts +3 -1
- package/esm/typings/src/pipeline/{pipeline-interface → PipelineInterface}/isPipelineImplementingInterface.d.ts +5 -1
- package/esm/typings/src/pipeline/{pipeline-interface → PipelineInterface}/isPipelineInterfacesEqual.d.ts +2 -0
- package/esm/typings/src/pipeline/PipelineJson/DialogTaskJson.d.ts +13 -0
- package/esm/typings/src/{types → pipeline}/PipelineJson/Expectations.d.ts +2 -2
- package/esm/typings/src/{types → pipeline}/PipelineJson/KnowledgePieceJson.d.ts +7 -6
- package/esm/typings/src/{types → pipeline}/PipelineJson/KnowledgeSourceJson.d.ts +3 -3
- package/esm/typings/src/pipeline/PipelineJson/ParameterJson.d.ts +96 -0
- package/esm/typings/src/{types → pipeline}/PipelineJson/PersonaJson.d.ts +4 -4
- package/esm/typings/src/{types → pipeline}/PipelineJson/PipelineJson.d.ts +10 -10
- package/esm/typings/src/{types → pipeline}/PipelineJson/PreparationJson.d.ts +1 -1
- package/esm/typings/src/{types/PipelineJson/PromptTemplateJson.d.ts → pipeline/PipelineJson/PromptTaskJson.d.ts} +8 -8
- package/esm/typings/src/pipeline/PipelineJson/ScriptTaskJson.d.ts +20 -0
- package/esm/typings/src/pipeline/PipelineJson/SimpleTaskJson.d.ts +13 -0
- package/esm/typings/src/pipeline/PipelineJson/TaskJson.d.ts +11 -0
- package/esm/typings/src/{types/PipelineJson/TemplateJsonCommon.d.ts → pipeline/PipelineJson/TaskJsonCommon.d.ts} +13 -13
- package/esm/typings/src/{types → pipeline}/PipelineString.d.ts +1 -1
- package/esm/typings/src/prepare/isPipelinePrepared.d.ts +2 -2
- package/esm/typings/src/prepare/preparePipeline.d.ts +1 -1
- package/esm/typings/src/prepare/{prepareTemplates.d.ts → prepareTasks.d.ts} +7 -7
- package/esm/typings/src/prepare/unpreparePipeline.d.ts +1 -1
- package/esm/typings/src/scrapers/_common/Scraper.d.ts +1 -1
- package/esm/typings/src/scrapers/_common/prepareKnowledgePieces.d.ts +2 -2
- package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +1 -1
- package/esm/typings/src/scrapers/document/DocumentScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/document/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/document/register-metadata.d.ts +3 -0
- package/esm/typings/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/document-legacy/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +3 -0
- package/esm/typings/src/scrapers/markdown/MarkdownScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/markdown/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +3 -0
- package/esm/typings/src/scrapers/pdf/PdfScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/pdf/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +3 -0
- package/esm/typings/src/scrapers/website/WebsiteScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/website/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/website/register-metadata.d.ts +3 -0
- package/esm/typings/src/scripting/javascript/postprocessing-functions.d.ts +1 -0
- package/esm/typings/src/types/Prompt.d.ts +1 -1
- package/esm/typings/src/types/TaskProgress.d.ts +2 -2
- package/esm/typings/src/types/typeAliasEmoji.d.ts +3 -0
- package/esm/typings/src/types/typeAliases.d.ts +1 -0
- package/esm/typings/src/utils/emojis.d.ts +1 -0
- package/esm/typings/src/utils/expectation-counters/{config.d.ts → constants.d.ts} +4 -0
- package/esm/typings/src/utils/expectation-counters/countCharacters.d.ts +1 -1
- package/esm/typings/src/utils/expectation-counters/countLines.d.ts +1 -1
- package/esm/typings/src/utils/expectation-counters/countPages.d.ts +1 -1
- package/esm/typings/src/utils/expectation-counters/countParagraphs.d.ts +1 -1
- package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +1 -1
- package/esm/typings/src/utils/expectation-counters/countWords.d.ts +1 -1
- package/esm/typings/src/utils/expectation-counters/index.d.ts +3 -2
- package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +3 -0
- package/esm/typings/src/utils/parameters/extractParameterNames.d.ts +2 -2
- package/esm/typings/src/utils/serialization/clonePipeline.d.ts +1 -1
- package/esm/typings/src/version.d.ts +2 -1
- package/package.json +4 -3
- package/umd/index.umd.js +276 -236
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/commands/TEMPLATE/TemplateCommand.d.ts +0 -11
- package/esm/typings/src/commands/TEMPLATE/TemplateTypes.d.ts +0 -15
- package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTemplate.d.ts +0 -27
- package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTemplate.d.ts +0 -30
- package/esm/typings/src/formfactors/chat/ChatFormfactorDefinition.d.ts +0 -10
- package/esm/typings/src/types/PipelineJson/DialogTemplateJson.d.ts +0 -13
- package/esm/typings/src/types/PipelineJson/ParameterJson.d.ts +0 -39
- package/esm/typings/src/types/PipelineJson/ScriptTemplateJson.d.ts +0 -20
- package/esm/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +0 -13
- package/esm/typings/src/types/PipelineJson/TemplateJson.d.ts +0 -11
- /package/esm/typings/src/commands/{TEMPLATE/templateCommand.test.d.ts → SECTION/sectionCommand.test.d.ts} +0 -0
- /package/esm/typings/src/conversion/utils/{extractParameterNamesFromTemplate.test.d.ts → extractParameterNamesFromTask.test.d.ts} +0 -0
- /package/esm/typings/src/{types → execution}/execution-report/ExecutionReportString.d.ts +0 -0
- /package/esm/typings/src/{types → execution}/execution-report/countWorkingDuration.d.ts +0 -0
- /package/esm/typings/src/{types → execution}/execution-report/countWorkingDuration.test.d.ts +0 -0
- /package/esm/typings/src/{types → execution}/execution-report/executionReportJsonToString.d.ts +0 -0
package/esm/index.es.js
CHANGED
|
@@ -20,9 +20,10 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
20
20
|
*
|
|
21
21
|
* @see https://github.com/webgptorg/promptbook
|
|
22
22
|
*/
|
|
23
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.
|
|
23
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.75.0-1';
|
|
24
24
|
/**
|
|
25
25
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
26
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
26
27
|
*/
|
|
27
28
|
|
|
28
29
|
/*! *****************************************************************************
|
|
@@ -355,7 +356,7 @@ function extractJsonBlock(markdown) {
|
|
|
355
356
|
* TODO: [🏢] Make this logic part of `JsonFormatDefinition` or `isValidJsonString`
|
|
356
357
|
*/
|
|
357
358
|
|
|
358
|
-
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}],
|
|
359
|
+
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:"./promptbook-collection/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:"./promptbook-collection/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:"./promptbook-collection/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:"./promptbook-collection/prepare-persona.book.md"}];
|
|
359
360
|
|
|
360
361
|
/**
|
|
361
362
|
* Prettify the html code
|
|
@@ -400,7 +401,7 @@ function prettifyMarkdown(content) {
|
|
|
400
401
|
*/
|
|
401
402
|
function pipelineJsonToString(pipelineJson) {
|
|
402
403
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
|
|
403
|
-
var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters,
|
|
404
|
+
var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, tasks = pipelineJson.tasks;
|
|
404
405
|
var pipelineString = "# ".concat(title);
|
|
405
406
|
if (description) {
|
|
406
407
|
pipelineString += '\n\n';
|
|
@@ -450,13 +451,13 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
450
451
|
pipelineString += '\n\n';
|
|
451
452
|
pipelineString += commands.map(function (command) { return "- ".concat(command); }).join('\n');
|
|
452
453
|
try {
|
|
453
|
-
for (var
|
|
454
|
-
var template =
|
|
454
|
+
for (var tasks_1 = __values(tasks), tasks_1_1 = tasks_1.next(); !tasks_1_1.done; tasks_1_1 = tasks_1.next()) {
|
|
455
|
+
var template = tasks_1_1.value;
|
|
455
456
|
var
|
|
456
457
|
/* Note: Not using:> name, */
|
|
457
458
|
title_1 = template.title, description_1 = template.description,
|
|
458
459
|
/* Note: dependentParameterNames, */
|
|
459
|
-
jokers = template.jokerParameterNames,
|
|
460
|
+
jokers = template.jokerParameterNames, taskType = template.taskType, content = template.content, postprocessing = template.postprocessingFunctionNames, expectations = template.expectations, format = template.format, resultingParameterName = template.resultingParameterName;
|
|
460
461
|
pipelineString += '\n\n';
|
|
461
462
|
pipelineString += "## ".concat(title_1);
|
|
462
463
|
if (description_1) {
|
|
@@ -465,7 +466,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
465
466
|
}
|
|
466
467
|
var commands_1 = [];
|
|
467
468
|
var contentLanguage = 'text';
|
|
468
|
-
if (
|
|
469
|
+
if (taskType === 'PROMPT_TASK') {
|
|
469
470
|
var modelRequirements = template.modelRequirements;
|
|
470
471
|
var _l = modelRequirements || {}, modelName = _l.modelName, modelVariant = _l.modelVariant;
|
|
471
472
|
commands_1.push("EXECUTE PROMPT TEMPLATE");
|
|
@@ -476,11 +477,11 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
476
477
|
commands_1.push("MODEL NAME `".concat(modelName, "`"));
|
|
477
478
|
}
|
|
478
479
|
}
|
|
479
|
-
else if (
|
|
480
|
+
else if (taskType === 'SIMPLE_TASK') {
|
|
480
481
|
commands_1.push("SIMPLE TEMPLATE");
|
|
481
482
|
// Note: Nothing special here
|
|
482
483
|
}
|
|
483
|
-
else if (
|
|
484
|
+
else if (taskType === 'SCRIPT_TASK') {
|
|
484
485
|
commands_1.push("SCRIPT TEMPLATE");
|
|
485
486
|
if (template.contentLanguage) {
|
|
486
487
|
contentLanguage = template.contentLanguage;
|
|
@@ -489,7 +490,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
489
490
|
contentLanguage = '';
|
|
490
491
|
}
|
|
491
492
|
}
|
|
492
|
-
else if (
|
|
493
|
+
else if (taskType === 'DIALOG_TASK') {
|
|
493
494
|
commands_1.push("DIALOG TEMPLATE");
|
|
494
495
|
// Note: Nothing special here
|
|
495
496
|
} // <- }else if([🅱]
|
|
@@ -571,7 +572,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
571
572
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
572
573
|
finally {
|
|
573
574
|
try {
|
|
574
|
-
if (
|
|
575
|
+
if (tasks_1_1 && !tasks_1_1.done && (_c = tasks_1.return)) _c.call(tasks_1);
|
|
575
576
|
}
|
|
576
577
|
finally { if (e_3) throw e_3.error; }
|
|
577
578
|
}
|
|
@@ -910,6 +911,8 @@ var IS_PIPELINE_LOGIC_VALIDATED = just(
|
|
|
910
911
|
// Note: In normal situations, we check the pipeline logic:
|
|
911
912
|
true);
|
|
912
913
|
/**
|
|
914
|
+
* TODO: Extract `constants.ts` from `config.ts`
|
|
915
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
913
916
|
* TODO: [🧠][🧜♂️] Maybe join remoteUrl and path into single value
|
|
914
917
|
*/
|
|
915
918
|
|
|
@@ -1146,24 +1149,23 @@ function validatePipelineCore(pipeline) {
|
|
|
1146
1149
|
throw new ParseError(spaceTrim$1(function (block) { return "\n Pipeline is valid JSON but with wrong structure\n\n `PipelineJson.parameters` expected to be an array, but got ".concat(typeof pipeline.parameters, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1147
1150
|
}
|
|
1148
1151
|
// TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
|
|
1149
|
-
if (!Array.isArray(pipeline.
|
|
1152
|
+
if (!Array.isArray(pipeline.tasks)) {
|
|
1150
1153
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
1151
|
-
throw new ParseError(spaceTrim$1(function (block) { return "\n Pipeline is valid JSON but with wrong structure\n\n `PipelineJson.
|
|
1154
|
+
throw new ParseError(spaceTrim$1(function (block) { return "\n Pipeline is valid JSON but with wrong structure\n\n `PipelineJson.tasks` expected to be an array, but got ".concat(typeof pipeline.tasks, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1152
1155
|
}
|
|
1153
1156
|
var _loop_1 = function (parameter) {
|
|
1154
1157
|
if (parameter.isInput && parameter.isOutput) {
|
|
1155
|
-
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n\n Parameter {".concat(parameter.name, "} can not be both input and output\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1158
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n\n Parameter `{".concat(parameter.name, "}` can not be both input and output\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1156
1159
|
}
|
|
1157
1160
|
// Note: Testing that parameter is either intermediate or output BUT not created and unused
|
|
1158
1161
|
if (!parameter.isInput &&
|
|
1159
1162
|
!parameter.isOutput &&
|
|
1160
|
-
!pipeline.
|
|
1161
|
-
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter {".concat(parameter.name, "} is created but not used\n\n You can declare {").concat(parameter.name, "} as output parameter by adding in the header:\n - OUTPUT PARAMETER `{").concat(parameter.name, "}` ").concat(parameter.description || '', "\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
|
|
1163
|
+
!pipeline.tasks.some(function (task) { return task.dependentParameterNames.includes(parameter.name); })) {
|
|
1164
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is created but not used\n\n You can declare {").concat(parameter.name, "} as output parameter by adding in the header:\n - OUTPUT PARAMETER `{").concat(parameter.name, "}` ").concat(parameter.description || '', "\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
|
|
1162
1165
|
}
|
|
1163
|
-
// Note: Testing that parameter is either input or result of some
|
|
1164
|
-
if (!parameter.isInput &&
|
|
1165
|
-
|
|
1166
|
-
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter {".concat(parameter.name, "} is declared but not defined\n\n You can do one of these:\n 1) Remove declaration of {").concat(parameter.name, "}\n 2) Add template that results in -> {").concat(parameter.name, "}\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1166
|
+
// Note: Testing that parameter is either input or result of some task
|
|
1167
|
+
if (!parameter.isInput && !pipeline.tasks.some(function (task) { return task.resultingParameterName === parameter.name; })) {
|
|
1168
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is declared but not defined\n\n You can do one of these:\n 1) Remove declaration of `{").concat(parameter.name, "}`\n 2) Add task that results in `-> {").concat(parameter.name, "}`\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1167
1169
|
}
|
|
1168
1170
|
};
|
|
1169
1171
|
try {
|
|
@@ -1180,7 +1182,7 @@ function validatePipelineCore(pipeline) {
|
|
|
1180
1182
|
}
|
|
1181
1183
|
finally { if (e_1) throw e_1.error; }
|
|
1182
1184
|
}
|
|
1183
|
-
// Note: All input parameters are defined - so that they can be used as result of some
|
|
1185
|
+
// Note: All input parameters are defined - so that they can be used as result of some task
|
|
1184
1186
|
var definedParameters = new Set(pipeline.parameters.filter(function (_a) {
|
|
1185
1187
|
var isInput = _a.isInput;
|
|
1186
1188
|
return isInput;
|
|
@@ -1188,27 +1190,27 @@ function validatePipelineCore(pipeline) {
|
|
|
1188
1190
|
var name = _a.name;
|
|
1189
1191
|
return name;
|
|
1190
1192
|
}));
|
|
1191
|
-
var _loop_2 = function (
|
|
1193
|
+
var _loop_2 = function (task) {
|
|
1192
1194
|
var e_4, _h, e_5, _j;
|
|
1193
|
-
if (definedParameters.has(
|
|
1194
|
-
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter {".concat(
|
|
1195
|
+
if (definedParameters.has(task.resultingParameterName)) {
|
|
1196
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter `{".concat(task.resultingParameterName, "}` is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1195
1197
|
}
|
|
1196
|
-
if (RESERVED_PARAMETER_NAMES.includes(
|
|
1197
|
-
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter name {".concat(
|
|
1198
|
+
if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
|
|
1199
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter name {".concat(task.resultingParameterName, "} is reserved, please use different name\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1198
1200
|
}
|
|
1199
|
-
definedParameters.add(
|
|
1200
|
-
if (
|
|
1201
|
-
if (!
|
|
1202
|
-
!
|
|
1203
|
-
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Joker parameters are used for {".concat(
|
|
1201
|
+
definedParameters.add(task.resultingParameterName);
|
|
1202
|
+
if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
|
|
1203
|
+
if (!task.format &&
|
|
1204
|
+
!task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
|
|
1205
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Joker parameters are used for {".concat(task.resultingParameterName, "} but no expectations are defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1204
1206
|
}
|
|
1205
1207
|
var _loop_4 = function (joker) {
|
|
1206
|
-
if (!
|
|
1207
|
-
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter {".concat(joker, "} is used for {").concat(
|
|
1208
|
+
if (!task.dependentParameterNames.includes(joker)) {
|
|
1209
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter `{".concat(joker, "}` is used for {").concat(task.resultingParameterName, "} as joker but not in `dependentParameterNames`\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1208
1210
|
}
|
|
1209
1211
|
};
|
|
1210
1212
|
try {
|
|
1211
|
-
for (var _k = (e_4 = void 0, __values(
|
|
1213
|
+
for (var _k = (e_4 = void 0, __values(task.jokerParameterNames)), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
1212
1214
|
var joker = _l.value;
|
|
1213
1215
|
_loop_4(joker);
|
|
1214
1216
|
}
|
|
@@ -1221,7 +1223,7 @@ function validatePipelineCore(pipeline) {
|
|
|
1221
1223
|
finally { if (e_4) throw e_4.error; }
|
|
1222
1224
|
}
|
|
1223
1225
|
}
|
|
1224
|
-
if (
|
|
1226
|
+
if (task.expectations) {
|
|
1225
1227
|
var _loop_5 = function (unit, min, max) {
|
|
1226
1228
|
if (min !== undefined && max !== undefined && min > max) {
|
|
1227
1229
|
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Min expectation (=".concat(min, ") of ").concat(unit, " is higher than max expectation (=").concat(max, ")\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
@@ -1234,7 +1236,7 @@ function validatePipelineCore(pipeline) {
|
|
|
1234
1236
|
}
|
|
1235
1237
|
};
|
|
1236
1238
|
try {
|
|
1237
|
-
for (var _m = (e_5 = void 0, __values(Object.entries(
|
|
1239
|
+
for (var _m = (e_5 = void 0, __values(Object.entries(task.expectations))), _o = _m.next(); !_o.done; _o = _m.next()) {
|
|
1238
1240
|
var _p = __read(_o.value, 2), unit = _p[0], _q = _p[1], min = _q.min, max = _q.max;
|
|
1239
1241
|
_loop_5(unit, min, max);
|
|
1240
1242
|
}
|
|
@@ -1249,10 +1251,10 @@ function validatePipelineCore(pipeline) {
|
|
|
1249
1251
|
}
|
|
1250
1252
|
};
|
|
1251
1253
|
try {
|
|
1252
|
-
// Note: Checking each
|
|
1253
|
-
for (var _f = __values(pipeline.
|
|
1254
|
-
var
|
|
1255
|
-
_loop_2(
|
|
1254
|
+
// Note: Checking each task individually
|
|
1255
|
+
for (var _f = __values(pipeline.tasks), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
1256
|
+
var task = _g.value;
|
|
1257
|
+
_loop_2(task);
|
|
1256
1258
|
}
|
|
1257
1259
|
}
|
|
1258
1260
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
@@ -1286,37 +1288,48 @@ function validatePipelineCore(pipeline) {
|
|
|
1286
1288
|
}
|
|
1287
1289
|
finally { if (e_3) throw e_3.error; }
|
|
1288
1290
|
}
|
|
1289
|
-
var unresovedTemplates = __spreadArray([], __read(pipeline.
|
|
1291
|
+
var unresovedTemplates = __spreadArray([], __read(pipeline.tasks), false);
|
|
1290
1292
|
var loopLimit = LOOP_LIMIT;
|
|
1291
1293
|
var _loop_3 = function () {
|
|
1292
1294
|
if (loopLimit-- < 0) {
|
|
1293
1295
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
1294
1296
|
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Loop limit reached during detection of circular dependencies in `validatePipeline`\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
1295
1297
|
}
|
|
1296
|
-
var currentlyResovedTemplates = unresovedTemplates.filter(function (
|
|
1297
|
-
return
|
|
1298
|
+
var currentlyResovedTemplates = unresovedTemplates.filter(function (task) {
|
|
1299
|
+
return task.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
|
|
1298
1300
|
});
|
|
1299
1301
|
if (currentlyResovedTemplates.length === 0) {
|
|
1300
1302
|
throw new PipelineLogicError(
|
|
1301
1303
|
// TODO: [🐎] DRY
|
|
1302
|
-
spaceTrim$1(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
|
|
1304
|
+
spaceTrim$1(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(unresovedTemplates
|
|
1303
1305
|
.map(function (_a) {
|
|
1304
1306
|
var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
|
|
1305
|
-
return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
|
|
1306
|
-
.map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
|
|
1307
|
+
return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
|
|
1308
|
+
.map(function (dependentParameterName) { return "`{".concat(dependentParameterName, "}`"); })
|
|
1307
1309
|
.join(' and '));
|
|
1308
1310
|
})
|
|
1309
|
-
.join('\n')), "\n\n Resolved
|
|
1311
|
+
.join('\n')), "\n\n **Resolved:**\n ").concat(block(resovedParameters
|
|
1312
|
+
.filter(function (name) {
|
|
1313
|
+
return !RESERVED_PARAMETER_NAMES.includes(name);
|
|
1314
|
+
})
|
|
1315
|
+
.map(function (name) { return "- Parameter `{".concat(name, "}`"); })
|
|
1316
|
+
.join('\n')), "\n\n\n **Reserved (which are available):**\n ").concat(block(resovedParameters
|
|
1317
|
+
.filter(function (name) {
|
|
1318
|
+
return RESERVED_PARAMETER_NAMES.includes(name);
|
|
1319
|
+
})
|
|
1320
|
+
.map(function (name) { return "- Parameter `{".concat(name, "}`"); })
|
|
1321
|
+
.join('\n')), "\n\n\n "); }));
|
|
1310
1322
|
}
|
|
1311
1323
|
resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTemplates.map(function (_a) {
|
|
1312
1324
|
var resultingParameterName = _a.resultingParameterName;
|
|
1313
1325
|
return resultingParameterName;
|
|
1314
1326
|
})), false);
|
|
1315
|
-
unresovedTemplates = unresovedTemplates.filter(function (
|
|
1327
|
+
unresovedTemplates = unresovedTemplates.filter(function (task) { return !currentlyResovedTemplates.includes(task); });
|
|
1316
1328
|
};
|
|
1317
1329
|
while (unresovedTemplates.length > 0) {
|
|
1318
1330
|
_loop_3();
|
|
1319
1331
|
}
|
|
1332
|
+
// TODO: !!!!!! Test that pipeline interface implements declared formfactor interface
|
|
1320
1333
|
}
|
|
1321
1334
|
/**
|
|
1322
1335
|
* TODO: !! [🧞♀️] Do not allow joker + foreach
|
|
@@ -1373,9 +1386,9 @@ var PipelineUrlError = /** @class */ (function (_super) {
|
|
|
1373
1386
|
}(Error));
|
|
1374
1387
|
|
|
1375
1388
|
/**
|
|
1376
|
-
* Parses the
|
|
1389
|
+
* Parses the task and returns the list of all parameter names
|
|
1377
1390
|
*
|
|
1378
|
-
* @param template the
|
|
1391
|
+
* @param template the task with parameters in {curly} braces
|
|
1379
1392
|
* @returns the list of parameter names
|
|
1380
1393
|
* @public exported from `@promptbook/utils`
|
|
1381
1394
|
*/
|
|
@@ -1406,10 +1419,10 @@ function extractParameterNames(template) {
|
|
|
1406
1419
|
* @public exported from `@promptbook/core`
|
|
1407
1420
|
*/
|
|
1408
1421
|
function unpreparePipeline(pipeline) {
|
|
1409
|
-
var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources,
|
|
1422
|
+
var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, tasks = pipeline.tasks;
|
|
1410
1423
|
personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
|
|
1411
1424
|
knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
|
|
1412
|
-
|
|
1425
|
+
tasks = tasks.map(function (template) {
|
|
1413
1426
|
var dependentParameterNames = template.dependentParameterNames;
|
|
1414
1427
|
var parameterNames = extractParameterNames(template.preparedContent || '');
|
|
1415
1428
|
dependentParameterNames = dependentParameterNames.filter(function (dependentParameterName) { return !parameterNames.has(dependentParameterName); });
|
|
@@ -1417,7 +1430,7 @@ function unpreparePipeline(pipeline) {
|
|
|
1417
1430
|
delete templateUnprepared.preparedContent;
|
|
1418
1431
|
return templateUnprepared;
|
|
1419
1432
|
});
|
|
1420
|
-
return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), {
|
|
1433
|
+
return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), { tasks: tasks, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }));
|
|
1421
1434
|
}
|
|
1422
1435
|
/**
|
|
1423
1436
|
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
@@ -1849,6 +1862,9 @@ function normalizeToKebabCase(text) {
|
|
|
1849
1862
|
normalizedName = normalizedName.replace(/-$/, '');
|
|
1850
1863
|
return normalizedName;
|
|
1851
1864
|
}
|
|
1865
|
+
/**
|
|
1866
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
1867
|
+
*/
|
|
1852
1868
|
|
|
1853
1869
|
/**
|
|
1854
1870
|
* Removes emojis from a string and fix whitespaces
|
|
@@ -2050,6 +2066,9 @@ var ERRORS = {
|
|
|
2050
2066
|
UnexpectedError: UnexpectedError,
|
|
2051
2067
|
// TODO: [🪑]> VersionMismatchError,
|
|
2052
2068
|
};
|
|
2069
|
+
/**
|
|
2070
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2071
|
+
*/
|
|
2053
2072
|
|
|
2054
2073
|
/**
|
|
2055
2074
|
* Deserializes the error object
|
|
@@ -2111,8 +2130,8 @@ function isPipelinePrepared(pipeline) {
|
|
|
2111
2130
|
return false;
|
|
2112
2131
|
}
|
|
2113
2132
|
/*
|
|
2114
|
-
TODO: [🧠][🍫] `
|
|
2115
|
-
> if (!pipeline.
|
|
2133
|
+
TODO: [🧠][🍫] `tasks` can not be determined if they are fully prepared SO ignoring them
|
|
2134
|
+
> if (!pipeline.tasks.every(({ preparedContent }) => preparedContent === undefined)) {
|
|
2116
2135
|
> return false;
|
|
2117
2136
|
> }
|
|
2118
2137
|
*/
|
|
@@ -2125,7 +2144,7 @@ function isPipelinePrepared(pipeline) {
|
|
|
2125
2144
|
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
2126
2145
|
* - [🏍] ? Is context in each template
|
|
2127
2146
|
* - [♨] Are examples prepared
|
|
2128
|
-
* - [♨] Are
|
|
2147
|
+
* - [♨] Are tasks prepared
|
|
2129
2148
|
*/
|
|
2130
2149
|
|
|
2131
2150
|
/**
|
|
@@ -2273,6 +2292,9 @@ $deepFreeze({
|
|
|
2273
2292
|
pagesCount: { value: 0, isUncertain: true },
|
|
2274
2293
|
},
|
|
2275
2294
|
});
|
|
2295
|
+
/**
|
|
2296
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2297
|
+
*/
|
|
2276
2298
|
|
|
2277
2299
|
/**
|
|
2278
2300
|
* @@@
|
|
@@ -2672,8 +2694,8 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
|
|
|
2672
2694
|
else if (errors.length > 1) {
|
|
2673
2695
|
throw new PipelineExecutionError(
|
|
2674
2696
|
// TODO: Tell which execution tools failed like
|
|
2675
|
-
// 1) OpenAI throw PipelineExecutionError: Parameter {knowledge} is not defined
|
|
2676
|
-
// 2) AnthropicClaude throw PipelineExecutionError: Parameter {knowledge} is not defined
|
|
2697
|
+
// 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
2698
|
+
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
2677
2699
|
// 3) ...
|
|
2678
2700
|
spaceTrim(function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors
|
|
2679
2701
|
.map(function (error, i) { return "".concat(i + 1, ") **").concat(error.name || 'Error', ":** ").concat(error.message); })
|
|
@@ -3459,7 +3481,7 @@ TODO: [🧊] This is how it can look in future
|
|
|
3459
3481
|
*/
|
|
3460
3482
|
function clonePipeline(pipeline) {
|
|
3461
3483
|
// Note: Not using spread operator (...) because @@@
|
|
3462
|
-
var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, bookVersion = pipeline.bookVersion, description = pipeline.description, formfactorName = pipeline.formfactorName, parameters = pipeline.parameters,
|
|
3484
|
+
var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, bookVersion = pipeline.bookVersion, description = pipeline.description, formfactorName = pipeline.formfactorName, parameters = pipeline.parameters, tasks = pipeline.tasks, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
|
|
3463
3485
|
return {
|
|
3464
3486
|
pipelineUrl: pipelineUrl,
|
|
3465
3487
|
sourceFile: sourceFile,
|
|
@@ -3468,7 +3490,7 @@ function clonePipeline(pipeline) {
|
|
|
3468
3490
|
description: description,
|
|
3469
3491
|
formfactorName: formfactorName,
|
|
3470
3492
|
parameters: parameters,
|
|
3471
|
-
|
|
3493
|
+
tasks: tasks,
|
|
3472
3494
|
knowledgeSources: knowledgeSources,
|
|
3473
3495
|
knowledgePieces: knowledgePieces,
|
|
3474
3496
|
personas: personas,
|
|
@@ -3484,17 +3506,17 @@ function clonePipeline(pipeline) {
|
|
|
3484
3506
|
*
|
|
3485
3507
|
* @public exported from `@promptbook/core`
|
|
3486
3508
|
*/
|
|
3487
|
-
function
|
|
3509
|
+
function prepareTasks(pipeline, tools, options) {
|
|
3488
3510
|
return __awaiter(this, void 0, void 0, function () {
|
|
3489
|
-
var _a, maxParallelCount,
|
|
3511
|
+
var _a, maxParallelCount, tasks, knowledgePiecesCount, tasksPrepared;
|
|
3490
3512
|
var _this = this;
|
|
3491
3513
|
return __generator(this, function (_b) {
|
|
3492
3514
|
switch (_b.label) {
|
|
3493
3515
|
case 0:
|
|
3494
3516
|
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
return [4 /*yield*/, forEachAsync(
|
|
3517
|
+
tasks = pipeline.tasks, pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
|
|
3518
|
+
tasksPrepared = new Array(tasks.length);
|
|
3519
|
+
return [4 /*yield*/, forEachAsync(tasks, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (template, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
3498
3520
|
var dependentParameterNames, preparedContent, preparedTemplate;
|
|
3499
3521
|
return __generator(this, function (_a) {
|
|
3500
3522
|
dependentParameterNames = template.dependentParameterNames;
|
|
@@ -3507,13 +3529,13 @@ function prepareTemplates(pipeline, tools, options) {
|
|
|
3507
3529
|
], false);
|
|
3508
3530
|
}
|
|
3509
3531
|
preparedTemplate = __assign(__assign({}, template), { dependentParameterNames: dependentParameterNames, preparedContent: preparedContent });
|
|
3510
|
-
|
|
3532
|
+
tasksPrepared[index] = preparedTemplate;
|
|
3511
3533
|
return [2 /*return*/];
|
|
3512
3534
|
});
|
|
3513
3535
|
}); })];
|
|
3514
3536
|
case 1:
|
|
3515
3537
|
_b.sent();
|
|
3516
|
-
return [2 /*return*/, {
|
|
3538
|
+
return [2 /*return*/, { tasksPrepared: tasksPrepared }];
|
|
3517
3539
|
}
|
|
3518
3540
|
});
|
|
3519
3541
|
});
|
|
@@ -3521,7 +3543,7 @@ function prepareTemplates(pipeline, tools, options) {
|
|
|
3521
3543
|
/**
|
|
3522
3544
|
* TODO: [🧠] Add context to each template (if missing)
|
|
3523
3545
|
* TODO: [🧠] What is better name `prepareTemplate` or `prepareTemplateAndParameters`
|
|
3524
|
-
* TODO: [♨][main] !!! Prepare index the examples and maybe
|
|
3546
|
+
* TODO: [♨][main] !!! Prepare index the examples and maybe tasks
|
|
3525
3547
|
* TODO: Write tests for `preparePipeline`
|
|
3526
3548
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
3527
3549
|
* TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
|
|
@@ -3538,12 +3560,12 @@ function prepareTemplates(pipeline, tools, options) {
|
|
|
3538
3560
|
*/
|
|
3539
3561
|
function preparePipeline(pipeline, tools, options) {
|
|
3540
3562
|
return __awaiter(this, void 0, void 0, function () {
|
|
3541
|
-
var rootDirname, _a, maxParallelCount, _b, isVerbose, parameters,
|
|
3563
|
+
var rootDirname, _a, maxParallelCount, _b, isVerbose, parameters, tasks,
|
|
3542
3564
|
/*
|
|
3543
3565
|
<- TODO: [🧠][🪑] `promptbookVersion` */
|
|
3544
3566
|
knowledgeSources /*
|
|
3545
3567
|
<- TODO: [🧊] `knowledgePieces` */, personas /*
|
|
3546
|
-
<- TODO: [🧊] `preparations` */, _llms, llmTools, llmToolsWithUsage, currentPreparation, preparations, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared,
|
|
3568
|
+
<- TODO: [🧊] `preparations` */, _llms, llmTools, llmToolsWithUsage, currentPreparation, preparations, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared, tasksPrepared /* TODO: parameters: parametersPrepared*/;
|
|
3547
3569
|
var _this = this;
|
|
3548
3570
|
return __generator(this, function (_c) {
|
|
3549
3571
|
switch (_c.label) {
|
|
@@ -3552,7 +3574,7 @@ function preparePipeline(pipeline, tools, options) {
|
|
|
3552
3574
|
return [2 /*return*/, pipeline];
|
|
3553
3575
|
}
|
|
3554
3576
|
rootDirname = options.rootDirname, _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a, _b = options.isVerbose, isVerbose = _b === void 0 ? DEFAULT_IS_VERBOSE : _b;
|
|
3555
|
-
parameters = pipeline.parameters,
|
|
3577
|
+
parameters = pipeline.parameters, tasks = pipeline.tasks, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
|
|
3556
3578
|
if (tools === undefined || tools.llm === undefined) {
|
|
3557
3579
|
throw new MissingToolsError('LLM tools are required for preparing the pipeline');
|
|
3558
3580
|
}
|
|
@@ -3595,9 +3617,9 @@ function preparePipeline(pipeline, tools, options) {
|
|
|
3595
3617
|
case 2:
|
|
3596
3618
|
partialknowledgePiecesPrepared = _c.sent();
|
|
3597
3619
|
knowledgePiecesPrepared = partialknowledgePiecesPrepared.map(function (piece) { return (__assign(__assign({}, piece), { preparationIds: [/* TODO: [🧊] -> */ currentPreparation.id] })); });
|
|
3598
|
-
return [4 /*yield*/,
|
|
3620
|
+
return [4 /*yield*/, prepareTasks({
|
|
3599
3621
|
parameters: parameters,
|
|
3600
|
-
|
|
3622
|
+
tasks: tasks,
|
|
3601
3623
|
knowledgePiecesCount: knowledgePiecesPrepared.length,
|
|
3602
3624
|
}, __assign(__assign({}, tools), { llm: llmToolsWithUsage }), {
|
|
3603
3625
|
rootDirname: rootDirname,
|
|
@@ -3605,12 +3627,12 @@ function preparePipeline(pipeline, tools, options) {
|
|
|
3605
3627
|
isVerbose: isVerbose,
|
|
3606
3628
|
})];
|
|
3607
3629
|
case 3:
|
|
3608
|
-
|
|
3630
|
+
tasksPrepared = (_c.sent()).tasksPrepared;
|
|
3609
3631
|
// ----- /Templates preparation -----
|
|
3610
3632
|
// Note: Count total usage
|
|
3611
3633
|
currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
|
|
3612
|
-
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), {
|
|
3613
|
-
// <- TODO: [🪓] Here should be no need for spreading new array, just `
|
|
3634
|
+
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { tasks: __spreadArray([], __read(tasksPrepared), false),
|
|
3635
|
+
// <- TODO: [🪓] Here should be no need for spreading new array, just ` tasks: tasksPrepared`
|
|
3614
3636
|
knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }))];
|
|
3615
3637
|
}
|
|
3616
3638
|
});
|
|
@@ -3682,9 +3704,9 @@ function extractVariables(script) {
|
|
|
3682
3704
|
* @throws {ParseError} if the script is invalid
|
|
3683
3705
|
* @public exported from `@promptbook/utils`
|
|
3684
3706
|
*/
|
|
3685
|
-
function
|
|
3707
|
+
function extractParameterNamesFromTask(template) {
|
|
3686
3708
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
3687
|
-
var title = template.title, description = template.description,
|
|
3709
|
+
var title = template.title, description = template.description, taskType = template.taskType, content = template.content, preparedContent = template.preparedContent, jokerParameterNames = template.jokerParameterNames, foreach = template.foreach;
|
|
3688
3710
|
var parameterNames = new Set();
|
|
3689
3711
|
try {
|
|
3690
3712
|
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()) {
|
|
@@ -3699,7 +3721,7 @@ function extractParameterNamesFromTemplate(template) {
|
|
|
3699
3721
|
}
|
|
3700
3722
|
finally { if (e_1) throw e_1.error; }
|
|
3701
3723
|
}
|
|
3702
|
-
if (
|
|
3724
|
+
if (taskType === 'SCRIPT_TASK') {
|
|
3703
3725
|
try {
|
|
3704
3726
|
for (var _g = __values(extractVariables(content)), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
3705
3727
|
var parameterName = _h.value;
|
|
@@ -4109,6 +4131,9 @@ var FORMAT_DEFINITIONS = [
|
|
|
4109
4131
|
TextFormatDefinition,
|
|
4110
4132
|
CsvFormatDefinition,
|
|
4111
4133
|
];
|
|
4134
|
+
/**
|
|
4135
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
4136
|
+
*/
|
|
4112
4137
|
|
|
4113
4138
|
/**
|
|
4114
4139
|
* Maps available parameters to expected parameters
|
|
@@ -4194,11 +4219,11 @@ function replaceParameters(template, parameters) {
|
|
|
4194
4219
|
for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
4195
4220
|
var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
|
|
4196
4221
|
if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
|
|
4197
|
-
throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
|
|
4222
|
+
throw new UnexpectedError("Parameter `{".concat(parameterName, "}` has missing value"));
|
|
4198
4223
|
}
|
|
4199
4224
|
else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
|
|
4200
4225
|
// TODO: [🍵]
|
|
4201
|
-
throw new UnexpectedError("Parameter {".concat(parameterName, "} is restricted to use"));
|
|
4226
|
+
throw new UnexpectedError("Parameter `{".concat(parameterName, "}` is restricted to use"));
|
|
4202
4227
|
}
|
|
4203
4228
|
}
|
|
4204
4229
|
}
|
|
@@ -4209,7 +4234,7 @@ function replaceParameters(template, parameters) {
|
|
|
4209
4234
|
}
|
|
4210
4235
|
finally { if (e_1) throw e_1.error; }
|
|
4211
4236
|
}
|
|
4212
|
-
var
|
|
4237
|
+
var replacedTemplates = template;
|
|
4213
4238
|
var match;
|
|
4214
4239
|
var loopLimit = LOOP_LIMIT;
|
|
4215
4240
|
var _loop_1 = function () {
|
|
@@ -4225,11 +4250,11 @@ function replaceParameters(template, parameters) {
|
|
|
4225
4250
|
throw new PipelineExecutionError('Parameter is already opened or not closed');
|
|
4226
4251
|
}
|
|
4227
4252
|
if (parameters[parameterName] === undefined) {
|
|
4228
|
-
throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
|
|
4253
|
+
throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
|
|
4229
4254
|
}
|
|
4230
4255
|
var parameterValue = parameters[parameterName];
|
|
4231
4256
|
if (parameterValue === undefined) {
|
|
4232
|
-
throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
|
|
4257
|
+
throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
|
|
4233
4258
|
}
|
|
4234
4259
|
parameterValue = parameterValue.toString();
|
|
4235
4260
|
if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
|
|
@@ -4238,24 +4263,24 @@ function replaceParameters(template, parameters) {
|
|
|
4238
4263
|
.map(function (line, index) { return (index === 0 ? line : "".concat(precol).concat(line)); })
|
|
4239
4264
|
.join('\n');
|
|
4240
4265
|
}
|
|
4241
|
-
|
|
4242
|
-
|
|
4266
|
+
replacedTemplates =
|
|
4267
|
+
replacedTemplates.substring(0, match.index + precol.length) +
|
|
4243
4268
|
parameterValue +
|
|
4244
|
-
|
|
4269
|
+
replacedTemplates.substring(match.index + precol.length + parameterName.length + 2);
|
|
4245
4270
|
};
|
|
4246
4271
|
while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
|
|
4247
|
-
.exec(
|
|
4272
|
+
.exec(replacedTemplates))) {
|
|
4248
4273
|
_loop_1();
|
|
4249
4274
|
}
|
|
4250
4275
|
// [💫] Check if there are parameters that are not closed properly
|
|
4251
|
-
if (/{\w+$/.test(
|
|
4276
|
+
if (/{\w+$/.test(replacedTemplates)) {
|
|
4252
4277
|
throw new PipelineExecutionError('Parameter is not closed');
|
|
4253
4278
|
}
|
|
4254
4279
|
// [💫] Check if there are parameters that are not opened properly
|
|
4255
|
-
if (/^\w+}/.test(
|
|
4280
|
+
if (/^\w+}/.test(replacedTemplates)) {
|
|
4256
4281
|
throw new PipelineExecutionError('Parameter is not opened');
|
|
4257
4282
|
}
|
|
4258
|
-
return
|
|
4283
|
+
return replacedTemplates;
|
|
4259
4284
|
}
|
|
4260
4285
|
|
|
4261
4286
|
/**
|
|
@@ -4285,6 +4310,10 @@ var CHARACTERS_PER_STANDARD_LINE = 63;
|
|
|
4285
4310
|
* @public exported from `@promptbook/utils`
|
|
4286
4311
|
*/
|
|
4287
4312
|
var LINES_PER_STANDARD_PAGE = 44;
|
|
4313
|
+
/**
|
|
4314
|
+
* TODO: [🧠] Should be this `constants.ts` or `config.ts`?
|
|
4315
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
4316
|
+
*/
|
|
4288
4317
|
|
|
4289
4318
|
/**
|
|
4290
4319
|
* Counts number of lines in the text
|
|
@@ -4363,6 +4392,7 @@ var CountUtils = {
|
|
|
4363
4392
|
};
|
|
4364
4393
|
/**
|
|
4365
4394
|
* TODO: [🧠][🤠] This should be probbably as part of `TextFormatDefinition`
|
|
4395
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
4366
4396
|
*/
|
|
4367
4397
|
|
|
4368
4398
|
/**
|
|
@@ -4411,12 +4441,12 @@ function checkExpectations(expectations, value) {
|
|
|
4411
4441
|
*/
|
|
4412
4442
|
function executeAttempts(options) {
|
|
4413
4443
|
return __awaiter(this, void 0, void 0, function () {
|
|
4414
|
-
var jokerParameterNames, priority, maxAttempts, preparedContent, parameters,
|
|
4444
|
+
var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTaskResult, _llms, llmTools, _loop_1, attempt, state_1;
|
|
4415
4445
|
return __generator(this, function (_a) {
|
|
4416
4446
|
switch (_a.label) {
|
|
4417
4447
|
case 0:
|
|
4418
|
-
jokerParameterNames = options.jokerParameterNames, priority = options.priority, maxAttempts = options.maxAttempts, preparedContent = options.preparedContent, parameters = options.parameters,
|
|
4419
|
-
$
|
|
4448
|
+
jokerParameterNames = options.jokerParameterNames, priority = options.priority, maxAttempts = options.maxAttempts, preparedContent = options.preparedContent, parameters = options.parameters, task = options.task, preparedPipeline = options.preparedPipeline, tools = options.tools, $executionReport = options.$executionReport, pipelineIdentification = options.pipelineIdentification, maxExecutionAttempts = options.maxExecutionAttempts;
|
|
4449
|
+
$ongoingTaskResult = {
|
|
4420
4450
|
$result: null,
|
|
4421
4451
|
$resultString: null,
|
|
4422
4452
|
$expectError: null,
|
|
@@ -4436,52 +4466,51 @@ function executeAttempts(options) {
|
|
|
4436
4466
|
if (isJokerAttempt && !jokerParameterName) {
|
|
4437
4467
|
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Joker not found in attempt ".concat(attempt, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
4438
4468
|
}
|
|
4439
|
-
$
|
|
4440
|
-
$
|
|
4441
|
-
$
|
|
4469
|
+
$ongoingTaskResult.$result = null;
|
|
4470
|
+
$ongoingTaskResult.$resultString = null;
|
|
4471
|
+
$ongoingTaskResult.$expectError = null;
|
|
4442
4472
|
if (isJokerAttempt) {
|
|
4443
4473
|
if (parameters[jokerParameterName] === undefined) {
|
|
4444
4474
|
throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Joker parameter {".concat(jokerParameterName, "} not defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
4445
4475
|
// <- TODO: This is maybe `PipelineLogicError` which should be detected in `validatePipeline` and here just thrown as `UnexpectedError`
|
|
4446
4476
|
}
|
|
4447
4477
|
else {
|
|
4448
|
-
$
|
|
4478
|
+
$ongoingTaskResult.$resultString = parameters[jokerParameterName];
|
|
4449
4479
|
}
|
|
4450
4480
|
}
|
|
4451
4481
|
_t.label = 1;
|
|
4452
4482
|
case 1:
|
|
4453
4483
|
_t.trys.push([1, 43, 44, 45]);
|
|
4454
4484
|
if (!!isJokerAttempt) return [3 /*break*/, 25];
|
|
4455
|
-
_b =
|
|
4485
|
+
_b = task.taskType;
|
|
4456
4486
|
switch (_b) {
|
|
4457
|
-
case '
|
|
4458
|
-
case '
|
|
4459
|
-
case '
|
|
4460
|
-
case '
|
|
4487
|
+
case 'SIMPLE_TASK': return [3 /*break*/, 2];
|
|
4488
|
+
case 'PROMPT_TASK': return [3 /*break*/, 3];
|
|
4489
|
+
case 'SCRIPT_TASK': return [3 /*break*/, 11];
|
|
4490
|
+
case 'DIALOG_TASK': return [3 /*break*/, 22];
|
|
4461
4491
|
}
|
|
4462
4492
|
return [3 /*break*/, 24];
|
|
4463
4493
|
case 2:
|
|
4464
|
-
$
|
|
4494
|
+
$ongoingTaskResult.$resultString = replaceParameters(preparedContent, parameters);
|
|
4465
4495
|
return [3 /*break*/, 25];
|
|
4466
4496
|
case 3:
|
|
4467
|
-
modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (
|
|
4468
|
-
$
|
|
4469
|
-
title:
|
|
4497
|
+
modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (task.modelRequirements || {}));
|
|
4498
|
+
$ongoingTaskResult.$prompt = {
|
|
4499
|
+
title: task.title,
|
|
4470
4500
|
pipelineUrl: "".concat(preparedPipeline.pipelineUrl
|
|
4471
4501
|
? preparedPipeline.pipelineUrl
|
|
4472
|
-
: 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(
|
|
4473
|
-
// <- TODO: Here should be maybe also subformat index to distinguish between same
|
|
4502
|
+
: 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(task.name
|
|
4503
|
+
// <- TODO: Here should be maybe also subformat index to distinguish between same task with different subformat values
|
|
4474
4504
|
),
|
|
4475
4505
|
parameters: parameters,
|
|
4476
4506
|
content: preparedContent,
|
|
4477
4507
|
modelRequirements: modelRequirements,
|
|
4478
4508
|
expectations: __assign(__assign({}, (preparedPipeline.personas.find(function (_a) {
|
|
4479
4509
|
var name = _a.name;
|
|
4480
|
-
return name ===
|
|
4481
|
-
}) ||
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
postprocessingFunctionNames: template.postprocessingFunctionNames,
|
|
4510
|
+
return name === task.personaName;
|
|
4511
|
+
}) || {})), task.expectations),
|
|
4512
|
+
format: task.format,
|
|
4513
|
+
postprocessingFunctionNames: task.postprocessingFunctionNames,
|
|
4485
4514
|
}; // <- TODO: Not very good type guard
|
|
4486
4515
|
_c = modelRequirements.modelVariant;
|
|
4487
4516
|
switch (_c) {
|
|
@@ -4491,36 +4520,35 @@ function executeAttempts(options) {
|
|
|
4491
4520
|
}
|
|
4492
4521
|
return [3 /*break*/, 9];
|
|
4493
4522
|
case 4:
|
|
4494
|
-
_d = $
|
|
4523
|
+
_d = $ongoingTaskResult;
|
|
4495
4524
|
return [4 /*yield*/, llmTools.callChatModel(
|
|
4496
4525
|
// <- TODO: [🧁] Check that `callChatModel` is defined
|
|
4497
|
-
$deepFreeze($
|
|
4526
|
+
$deepFreeze($ongoingTaskResult.$prompt))];
|
|
4498
4527
|
case 5:
|
|
4499
4528
|
_d.$chatResult = _t.sent();
|
|
4500
4529
|
// TODO: [🍬] Destroy chatThread
|
|
4501
|
-
$
|
|
4502
|
-
$
|
|
4530
|
+
$ongoingTaskResult.$result = $ongoingTaskResult.$chatResult;
|
|
4531
|
+
$ongoingTaskResult.$resultString = $ongoingTaskResult.$chatResult.content;
|
|
4503
4532
|
return [3 /*break*/, 10];
|
|
4504
4533
|
case 6:
|
|
4505
|
-
_e = $
|
|
4534
|
+
_e = $ongoingTaskResult;
|
|
4506
4535
|
return [4 /*yield*/, llmTools.callCompletionModel(
|
|
4507
4536
|
// <- TODO: [🧁] Check that `callCompletionModel` is defined
|
|
4508
|
-
$deepFreeze($
|
|
4537
|
+
$deepFreeze($ongoingTaskResult.$prompt))];
|
|
4509
4538
|
case 7:
|
|
4510
4539
|
_e.$completionResult = _t.sent();
|
|
4511
|
-
$
|
|
4512
|
-
$
|
|
4513
|
-
$ongoingTemplateResult.$completionResult.content;
|
|
4540
|
+
$ongoingTaskResult.$result = $ongoingTaskResult.$completionResult;
|
|
4541
|
+
$ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
|
|
4514
4542
|
return [3 /*break*/, 10];
|
|
4515
4543
|
case 8: throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Embedding model can not be used in pipeline\n\n This should be catched during parsing\n\n ".concat(block(pipelineIdentification), "\n\n "); }));
|
|
4516
|
-
case 9: throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Unknown model variant \"".concat(
|
|
4544
|
+
case 9: throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Unknown model variant \"".concat(task.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
|
|
4517
4545
|
case 10: return [3 /*break*/, 25];
|
|
4518
4546
|
case 11:
|
|
4519
4547
|
if (arrayableToArray(tools.script).length === 0) {
|
|
4520
4548
|
throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n No script execution tools are available\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
4521
4549
|
}
|
|
4522
|
-
if (!
|
|
4523
|
-
throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Script language is not defined for SCRIPT
|
|
4550
|
+
if (!task.contentLanguage) {
|
|
4551
|
+
throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Script language is not defined for SCRIPT TASK \"".concat(task.name, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
4524
4552
|
}
|
|
4525
4553
|
_t.label = 12;
|
|
4526
4554
|
case 12:
|
|
@@ -4533,9 +4561,9 @@ function executeAttempts(options) {
|
|
|
4533
4561
|
_t.label = 14;
|
|
4534
4562
|
case 14:
|
|
4535
4563
|
_t.trys.push([14, 16, , 17]);
|
|
4536
|
-
_h = $
|
|
4564
|
+
_h = $ongoingTaskResult;
|
|
4537
4565
|
return [4 /*yield*/, scriptTools.execute($deepFreeze({
|
|
4538
|
-
scriptLanguage:
|
|
4566
|
+
scriptLanguage: task.contentLanguage,
|
|
4539
4567
|
script: preparedContent,
|
|
4540
4568
|
parameters: parameters,
|
|
4541
4569
|
}))];
|
|
@@ -4550,7 +4578,7 @@ function executeAttempts(options) {
|
|
|
4550
4578
|
if (error_1 instanceof UnexpectedError) {
|
|
4551
4579
|
throw error_1;
|
|
4552
4580
|
}
|
|
4553
|
-
$
|
|
4581
|
+
$ongoingTaskResult.$scriptPipelineExecutionErrors.push(error_1);
|
|
4554
4582
|
return [3 /*break*/, 17];
|
|
4555
4583
|
case 17:
|
|
4556
4584
|
_g = _f.next();
|
|
@@ -4567,14 +4595,14 @@ function executeAttempts(options) {
|
|
|
4567
4595
|
finally { if (e_1) throw e_1.error; }
|
|
4568
4596
|
return [7 /*endfinally*/];
|
|
4569
4597
|
case 21:
|
|
4570
|
-
if ($
|
|
4598
|
+
if ($ongoingTaskResult.$resultString !== null) {
|
|
4571
4599
|
return [3 /*break*/, 25];
|
|
4572
4600
|
}
|
|
4573
|
-
if ($
|
|
4574
|
-
throw $
|
|
4601
|
+
if ($ongoingTaskResult.$scriptPipelineExecutionErrors.length === 1) {
|
|
4602
|
+
throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
|
|
4575
4603
|
}
|
|
4576
4604
|
else {
|
|
4577
|
-
throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Script execution failed ".concat($
|
|
4605
|
+
throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Script execution failed ".concat($ongoingTaskResult.$scriptPipelineExecutionErrors.length, "x\n\n ").concat(block(pipelineIdentification), "\n\n ").concat(block($ongoingTaskResult.$scriptPipelineExecutionErrors
|
|
4578
4606
|
.map(function (error) { return '- ' + error.message; })
|
|
4579
4607
|
.join('\n\n')), "\n "); }));
|
|
4580
4608
|
}
|
|
@@ -4582,27 +4610,27 @@ function executeAttempts(options) {
|
|
|
4582
4610
|
if (tools.userInterface === undefined) {
|
|
4583
4611
|
throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n User interface tools are not available\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
4584
4612
|
}
|
|
4585
|
-
// TODO: [🌹] When making next attempt for `DIALOG
|
|
4586
|
-
_j = $
|
|
4613
|
+
// TODO: [🌹] When making next attempt for `DIALOG TASK`, preserve the previous user input
|
|
4614
|
+
_j = $ongoingTaskResult;
|
|
4587
4615
|
return [4 /*yield*/, tools.userInterface.promptDialog($deepFreeze({
|
|
4588
|
-
promptTitle:
|
|
4589
|
-
promptMessage: replaceParameters(
|
|
4616
|
+
promptTitle: task.title,
|
|
4617
|
+
promptMessage: replaceParameters(task.description || '', parameters),
|
|
4590
4618
|
defaultValue: replaceParameters(preparedContent, parameters),
|
|
4591
4619
|
// TODO: [🧠] !! Figure out how to define placeholder in .book.md file
|
|
4592
4620
|
placeholder: undefined,
|
|
4593
4621
|
priority: priority,
|
|
4594
4622
|
}))];
|
|
4595
4623
|
case 23:
|
|
4596
|
-
// TODO: [🌹] When making next attempt for `DIALOG
|
|
4624
|
+
// TODO: [🌹] When making next attempt for `DIALOG TASK`, preserve the previous user input
|
|
4597
4625
|
_j.$resultString = _t.sent();
|
|
4598
4626
|
return [3 /*break*/, 25];
|
|
4599
|
-
case 24: throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Unknown execution type \"".concat(
|
|
4627
|
+
case 24: throw new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Unknown execution type \"".concat(task.taskType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
4600
4628
|
case 25:
|
|
4601
|
-
if (!(!isJokerAttempt &&
|
|
4629
|
+
if (!(!isJokerAttempt && task.postprocessingFunctionNames)) return [3 /*break*/, 42];
|
|
4602
4630
|
_t.label = 26;
|
|
4603
4631
|
case 26:
|
|
4604
4632
|
_t.trys.push([26, 40, 41, 42]);
|
|
4605
|
-
_k = (e_3 = void 0, __values(
|
|
4633
|
+
_k = (e_3 = void 0, __values(task.postprocessingFunctionNames)), _l = _k.next();
|
|
4606
4634
|
_t.label = 27;
|
|
4607
4635
|
case 27:
|
|
4608
4636
|
if (!!_l.done) return [3 /*break*/, 39];
|
|
@@ -4619,13 +4647,13 @@ function executeAttempts(options) {
|
|
|
4619
4647
|
_t.label = 30;
|
|
4620
4648
|
case 30:
|
|
4621
4649
|
_t.trys.push([30, 32, , 33]);
|
|
4622
|
-
_p = $
|
|
4650
|
+
_p = $ongoingTaskResult;
|
|
4623
4651
|
return [4 /*yield*/, scriptTools.execute({
|
|
4624
4652
|
scriptLanguage: "javascript" /* <- TODO: Try it in each languages; In future allow postprocessing with arbitrary combination of languages to combine */,
|
|
4625
4653
|
script: "".concat(functionName, "(resultString)"),
|
|
4626
4654
|
parameters: {
|
|
4627
|
-
resultString: $
|
|
4628
|
-
// Note: No ...
|
|
4655
|
+
resultString: $ongoingTaskResult.$resultString || '',
|
|
4656
|
+
// Note: No ...parametersForTask, because working with result only
|
|
4629
4657
|
},
|
|
4630
4658
|
})];
|
|
4631
4659
|
case 31:
|
|
@@ -4641,7 +4669,7 @@ function executeAttempts(options) {
|
|
|
4641
4669
|
throw error_2;
|
|
4642
4670
|
}
|
|
4643
4671
|
postprocessingError = error_2;
|
|
4644
|
-
$
|
|
4672
|
+
$ongoingTaskResult.$scriptPipelineExecutionErrors.push(error_2);
|
|
4645
4673
|
return [3 /*break*/, 33];
|
|
4646
4674
|
case 33:
|
|
4647
4675
|
_o = _m.next();
|
|
@@ -4678,12 +4706,12 @@ function executeAttempts(options) {
|
|
|
4678
4706
|
return [7 /*endfinally*/];
|
|
4679
4707
|
case 42:
|
|
4680
4708
|
// TODO: [💝] Unite object for expecting amount and format
|
|
4681
|
-
if (
|
|
4682
|
-
if (
|
|
4683
|
-
if (!isValidJsonString($
|
|
4709
|
+
if (task.format) {
|
|
4710
|
+
if (task.format === 'JSON') {
|
|
4711
|
+
if (!isValidJsonString($ongoingTaskResult.$resultString || '')) {
|
|
4684
4712
|
// TODO: [🏢] Do more universally via `FormatDefinition`
|
|
4685
4713
|
try {
|
|
4686
|
-
$
|
|
4714
|
+
$ongoingTaskResult.$resultString = extractJsonBlock($ongoingTaskResult.$resultString || '');
|
|
4687
4715
|
}
|
|
4688
4716
|
catch (error) {
|
|
4689
4717
|
throw new ExpectError(spaceTrim$1(function (block) { return "\n Expected valid JSON string\n\n ".concat(block(
|
|
@@ -4692,12 +4720,12 @@ function executeAttempts(options) {
|
|
|
4692
4720
|
}
|
|
4693
4721
|
}
|
|
4694
4722
|
else {
|
|
4695
|
-
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Unknown format \"".concat(
|
|
4723
|
+
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Unknown format \"".concat(task.format, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
4696
4724
|
}
|
|
4697
4725
|
}
|
|
4698
4726
|
// TODO: [💝] Unite object for expecting amount and format
|
|
4699
|
-
if (
|
|
4700
|
-
checkExpectations(
|
|
4727
|
+
if (task.expectations) {
|
|
4728
|
+
checkExpectations(task.expectations, $ongoingTaskResult.$resultString || '');
|
|
4701
4729
|
}
|
|
4702
4730
|
return [2 /*return*/, "break-attempts"];
|
|
4703
4731
|
case 43:
|
|
@@ -4705,38 +4733,38 @@ function executeAttempts(options) {
|
|
|
4705
4733
|
if (!(error_3 instanceof ExpectError)) {
|
|
4706
4734
|
throw error_3;
|
|
4707
4735
|
}
|
|
4708
|
-
$
|
|
4736
|
+
$ongoingTaskResult.$expectError = error_3;
|
|
4709
4737
|
return [3 /*break*/, 45];
|
|
4710
4738
|
case 44:
|
|
4711
4739
|
if (!isJokerAttempt &&
|
|
4712
|
-
|
|
4713
|
-
$
|
|
4740
|
+
task.taskType === 'PROMPT_TASK' &&
|
|
4741
|
+
$ongoingTaskResult.$prompt
|
|
4714
4742
|
// <- Note: [2] When some expected parameter is not defined, error will occur in replaceParameters
|
|
4715
4743
|
// In that case we don’t want to make a report about it because it’s not a llm execution error
|
|
4716
4744
|
) {
|
|
4717
|
-
// TODO: [🧠] Maybe put other
|
|
4745
|
+
// TODO: [🧠] Maybe put other taskTypes into report
|
|
4718
4746
|
$executionReport.promptExecutions.push({
|
|
4719
|
-
prompt: __assign({}, $
|
|
4720
|
-
result: $
|
|
4721
|
-
error: $
|
|
4747
|
+
prompt: __assign({}, $ongoingTaskResult.$prompt),
|
|
4748
|
+
result: $ongoingTaskResult.$result || undefined,
|
|
4749
|
+
error: $ongoingTaskResult.$expectError === null
|
|
4722
4750
|
? undefined
|
|
4723
|
-
: serializeError($
|
|
4751
|
+
: serializeError($ongoingTaskResult.$expectError),
|
|
4724
4752
|
});
|
|
4725
4753
|
}
|
|
4726
4754
|
return [7 /*endfinally*/];
|
|
4727
4755
|
case 45:
|
|
4728
|
-
if ($
|
|
4756
|
+
if ($ongoingTaskResult.$expectError !== null && attempt === maxAttempts - 1) {
|
|
4729
4757
|
throw new PipelineExecutionError(spaceTrim$1(function (block) {
|
|
4730
4758
|
var _a, _b, _c;
|
|
4731
|
-
return "\n LLM execution failed ".concat(maxExecutionAttempts, "x\n\n ").concat(block(pipelineIdentification), "\n\n ---\n The Prompt:\n ").concat(block((((_a = $
|
|
4759
|
+
return "\n LLM execution failed ".concat(maxExecutionAttempts, "x\n\n ").concat(block(pipelineIdentification), "\n\n ---\n The Prompt:\n ").concat(block((((_a = $ongoingTaskResult.$prompt) === null || _a === void 0 ? void 0 : _a.content) || '')
|
|
4732
4760
|
.split('\n')
|
|
4733
4761
|
.map(function (line) { return "> ".concat(line); })
|
|
4734
|
-
.join('\n')), "\n\n Last error ").concat(((_b = $
|
|
4762
|
+
.join('\n')), "\n\n Last error ").concat(((_b = $ongoingTaskResult.$expectError) === null || _b === void 0 ? void 0 : _b.name) || '', ":\n ").concat(block((((_c = $ongoingTaskResult.$expectError) === null || _c === void 0 ? void 0 : _c.message) || '')
|
|
4735
4763
|
.split('\n')
|
|
4736
4764
|
.map(function (line) { return "> ".concat(line); })
|
|
4737
|
-
.join('\n')), "\n\n Last result:\n ").concat(block($
|
|
4765
|
+
.join('\n')), "\n\n Last result:\n ").concat(block($ongoingTaskResult.$resultString === null
|
|
4738
4766
|
? 'null'
|
|
4739
|
-
: $
|
|
4767
|
+
: $ongoingTaskResult.$resultString
|
|
4740
4768
|
.split('\n')
|
|
4741
4769
|
.map(function (line) { return "> ".concat(line); })
|
|
4742
4770
|
.join('\n')), "\n ---\n ");
|
|
@@ -4761,10 +4789,10 @@ function executeAttempts(options) {
|
|
|
4761
4789
|
attempt++;
|
|
4762
4790
|
return [3 /*break*/, 1];
|
|
4763
4791
|
case 4:
|
|
4764
|
-
if ($
|
|
4792
|
+
if ($ongoingTaskResult.$resultString === null) {
|
|
4765
4793
|
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
4766
4794
|
}
|
|
4767
|
-
return [2 /*return*/, $
|
|
4795
|
+
return [2 /*return*/, $ongoingTaskResult.$resultString];
|
|
4768
4796
|
}
|
|
4769
4797
|
});
|
|
4770
4798
|
});
|
|
@@ -4780,36 +4808,36 @@ function executeAttempts(options) {
|
|
|
4780
4808
|
*/
|
|
4781
4809
|
function executeFormatSubvalues(options) {
|
|
4782
4810
|
return __awaiter(this, void 0, void 0, function () {
|
|
4783
|
-
var
|
|
4811
|
+
var task, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
|
|
4784
4812
|
var _this = this;
|
|
4785
4813
|
return __generator(this, function (_a) {
|
|
4786
4814
|
switch (_a.label) {
|
|
4787
4815
|
case 0:
|
|
4788
|
-
|
|
4789
|
-
if (
|
|
4816
|
+
task = options.task, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, csvSettings = options.csvSettings, pipelineIdentification = options.pipelineIdentification;
|
|
4817
|
+
if (task.foreach === undefined) {
|
|
4790
4818
|
return [2 /*return*/, /* not await */ executeAttempts(options)];
|
|
4791
4819
|
}
|
|
4792
4820
|
if (jokerParameterNames.length !== 0) {
|
|
4793
4821
|
throw new UnexpectedError(spaceTrim(function (block) { return "\n JOKER parameters are not supported together with FOREACH command\n\n [\uD83E\uDDDE\u200D\u2640\uFE0F] This should be prevented in `validatePipeline`\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
4794
4822
|
}
|
|
4795
|
-
parameterValue = parameters[
|
|
4823
|
+
parameterValue = parameters[task.foreach.parameterName] || '';
|
|
4796
4824
|
formatDefinition = FORMAT_DEFINITIONS.find(function (formatDefinition) {
|
|
4797
|
-
return __spreadArray([formatDefinition.formatName], __read((formatDefinition.aliases || [])), false).includes(
|
|
4825
|
+
return __spreadArray([formatDefinition.formatName], __read((formatDefinition.aliases || [])), false).includes(task.foreach.formatName);
|
|
4798
4826
|
});
|
|
4799
4827
|
if (formatDefinition === undefined) {
|
|
4800
4828
|
throw new UnexpectedError(
|
|
4801
4829
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
4802
|
-
spaceTrim(function (block) { return "\n Unsupported format \"".concat(
|
|
4830
|
+
spaceTrim(function (block) { return "\n Unsupported format \"".concat(task.foreach.formatName, "\"\n\n Available formats:\n ").concat(block(FORMAT_DEFINITIONS.map(function (formatDefinition) { return formatDefinition.formatName; })
|
|
4803
4831
|
.map(function (formatName) { return "- ".concat(formatName); })
|
|
4804
4832
|
.join('\n')), "\n\n [\u26F7] This should never happen because format name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
4805
4833
|
}
|
|
4806
4834
|
subvalueDefinition = formatDefinition.subvalueDefinitions.find(function (subvalueDefinition) {
|
|
4807
|
-
return __spreadArray([subvalueDefinition.subvalueName], __read((subvalueDefinition.aliases || [])), false).includes(
|
|
4835
|
+
return __spreadArray([subvalueDefinition.subvalueName], __read((subvalueDefinition.aliases || [])), false).includes(task.foreach.subformatName);
|
|
4808
4836
|
});
|
|
4809
4837
|
if (subvalueDefinition === undefined) {
|
|
4810
4838
|
throw new UnexpectedError(
|
|
4811
4839
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
4812
|
-
spaceTrim(function (block) { return "\n Unsupported subformat name \"".concat(
|
|
4840
|
+
spaceTrim(function (block) { return "\n Unsupported subformat name \"".concat(task.foreach.subformatName, "\" for format \"").concat(task.foreach.formatName, "\"\n\n Available subformat names for format \"").concat(formatDefinition.formatName, "\":\n ").concat(block(formatDefinition.subvalueDefinitions
|
|
4813
4841
|
.map(function (subvalueDefinition) { return subvalueDefinition.subvalueName; })
|
|
4814
4842
|
.map(function (subvalueName) { return "- ".concat(subvalueName); })
|
|
4815
4843
|
.join('\n')), "\n\n [\u26F7] This should never happen because subformat name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
@@ -4818,7 +4846,7 @@ function executeFormatSubvalues(options) {
|
|
|
4818
4846
|
formatSettings = csvSettings;
|
|
4819
4847
|
// <- TODO: [🤹♂️] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
|
|
4820
4848
|
}
|
|
4821
|
-
return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue,
|
|
4849
|
+
return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, task.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
4822
4850
|
var mappedParameters, allSubparameters, subresultString;
|
|
4823
4851
|
return __generator(this, function (_a) {
|
|
4824
4852
|
switch (_a.label) {
|
|
@@ -4827,7 +4855,7 @@ function executeFormatSubvalues(options) {
|
|
|
4827
4855
|
// TODO: When done [🐚] Report progress also for each subvalue here
|
|
4828
4856
|
try {
|
|
4829
4857
|
mappedParameters = mapAvailableToExpectedParameters({
|
|
4830
|
-
expectedParameters: Object.fromEntries(
|
|
4858
|
+
expectedParameters: Object.fromEntries(task.foreach.inputSubparameterNames.map(function (subparameterName) { return [subparameterName, null]; })),
|
|
4831
4859
|
availableParameters: subparameters,
|
|
4832
4860
|
});
|
|
4833
4861
|
}
|
|
@@ -4860,7 +4888,7 @@ function executeFormatSubvalues(options) {
|
|
|
4860
4888
|
*
|
|
4861
4889
|
* @private internal utility of `createPipelineExecutor`
|
|
4862
4890
|
*/
|
|
4863
|
-
function
|
|
4891
|
+
function getContextForTask(task) {
|
|
4864
4892
|
return __awaiter(this, void 0, void 0, function () {
|
|
4865
4893
|
return __generator(this, function (_a) {
|
|
4866
4894
|
return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [🏍] Implement */];
|
|
@@ -4873,15 +4901,10 @@ function getContextForTemplate(template) {
|
|
|
4873
4901
|
*
|
|
4874
4902
|
* @private internal utility of `createPipelineExecutor`
|
|
4875
4903
|
*/
|
|
4876
|
-
function
|
|
4904
|
+
function getExamplesForTask(task) {
|
|
4877
4905
|
return __awaiter(this, void 0, void 0, function () {
|
|
4878
|
-
var preparedPipeline;
|
|
4879
4906
|
return __generator(this, function (_a) {
|
|
4880
|
-
|
|
4881
|
-
return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
|
|
4882
|
-
var content = _a.content;
|
|
4883
|
-
return "- ".concat(content);
|
|
4884
|
-
}).join('\n')];
|
|
4907
|
+
return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [♨] Implement */];
|
|
4885
4908
|
});
|
|
4886
4909
|
});
|
|
4887
4910
|
}
|
|
@@ -4891,10 +4914,15 @@ function getKnowledgeForTemplate(options) {
|
|
|
4891
4914
|
*
|
|
4892
4915
|
* @private internal utility of `createPipelineExecutor`
|
|
4893
4916
|
*/
|
|
4894
|
-
function
|
|
4917
|
+
function getKnowledgeForTask(options) {
|
|
4895
4918
|
return __awaiter(this, void 0, void 0, function () {
|
|
4919
|
+
var preparedPipeline;
|
|
4896
4920
|
return __generator(this, function (_a) {
|
|
4897
|
-
|
|
4921
|
+
preparedPipeline = options.preparedPipeline, options.task;
|
|
4922
|
+
return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
|
|
4923
|
+
var content = _a.content;
|
|
4924
|
+
return "- ".concat(content);
|
|
4925
|
+
}).join('\n')];
|
|
4898
4926
|
});
|
|
4899
4927
|
});
|
|
4900
4928
|
}
|
|
@@ -4904,21 +4932,21 @@ function getExamplesForTemplate(template) {
|
|
|
4904
4932
|
*
|
|
4905
4933
|
* @private internal utility of `createPipelineExecutor`
|
|
4906
4934
|
*/
|
|
4907
|
-
function
|
|
4935
|
+
function getReservedParametersForTask(options) {
|
|
4908
4936
|
return __awaiter(this, void 0, void 0, function () {
|
|
4909
|
-
var preparedPipeline,
|
|
4937
|
+
var preparedPipeline, task, pipelineIdentification, context, knowledge, examples, currentDate, modelName, reservedParameters, _loop_1, RESERVED_PARAMETER_NAMES_1, RESERVED_PARAMETER_NAMES_1_1, parameterName;
|
|
4910
4938
|
var e_1, _a;
|
|
4911
4939
|
return __generator(this, function (_b) {
|
|
4912
4940
|
switch (_b.label) {
|
|
4913
4941
|
case 0:
|
|
4914
|
-
preparedPipeline = options.preparedPipeline,
|
|
4915
|
-
return [4 /*yield*/,
|
|
4942
|
+
preparedPipeline = options.preparedPipeline, task = options.task, pipelineIdentification = options.pipelineIdentification;
|
|
4943
|
+
return [4 /*yield*/, getContextForTask()];
|
|
4916
4944
|
case 1:
|
|
4917
4945
|
context = _b.sent();
|
|
4918
|
-
return [4 /*yield*/,
|
|
4946
|
+
return [4 /*yield*/, getKnowledgeForTask({ preparedPipeline: preparedPipeline, task: task })];
|
|
4919
4947
|
case 2:
|
|
4920
4948
|
knowledge = _b.sent();
|
|
4921
|
-
return [4 /*yield*/,
|
|
4949
|
+
return [4 /*yield*/, getExamplesForTask()];
|
|
4922
4950
|
case 3:
|
|
4923
4951
|
examples = _b.sent();
|
|
4924
4952
|
currentDate = new Date().toISOString();
|
|
@@ -4961,31 +4989,31 @@ function getReservedParametersForTemplate(options) {
|
|
|
4961
4989
|
*
|
|
4962
4990
|
* @private internal utility of `createPipelineExecutor`
|
|
4963
4991
|
*/
|
|
4964
|
-
function
|
|
4992
|
+
function executeTask(options) {
|
|
4965
4993
|
return __awaiter(this, void 0, void 0, function () {
|
|
4966
|
-
var
|
|
4994
|
+
var currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, _a, maxExecutionAttempts, name, title, priority, usedParameterNames, dependentParameterNames, definedParameters, _b, _c, _d, definedParameterNames, parameters, _loop_1, _e, _f, parameterName, maxAttempts, jokerParameterNames, preparedContent, resultString;
|
|
4967
4995
|
var e_1, _g, _h;
|
|
4968
4996
|
return __generator(this, function (_j) {
|
|
4969
4997
|
switch (_j.label) {
|
|
4970
4998
|
case 0:
|
|
4971
|
-
|
|
4972
|
-
name = "pipeline-executor-frame-".concat(
|
|
4973
|
-
title =
|
|
4974
|
-
priority = preparedPipeline.
|
|
4999
|
+
currentTask = options.currentTask, preparedPipeline = options.preparedPipeline, parametersToPass = options.parametersToPass, tools = options.tools, onProgress = options.onProgress, $executionReport = options.$executionReport, pipelineIdentification = options.pipelineIdentification, _a = options.maxExecutionAttempts, maxExecutionAttempts = _a === void 0 ? DEFAULT_MAX_EXECUTION_ATTEMPTS : _a;
|
|
5000
|
+
name = "pipeline-executor-frame-".concat(currentTask.name);
|
|
5001
|
+
title = currentTask.title;
|
|
5002
|
+
priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
|
|
4975
5003
|
return [4 /*yield*/, onProgress({
|
|
4976
5004
|
name: name,
|
|
4977
5005
|
title: title,
|
|
4978
5006
|
isStarted: false,
|
|
4979
5007
|
isDone: false,
|
|
4980
|
-
|
|
4981
|
-
parameterName:
|
|
5008
|
+
taskType: currentTask.taskType,
|
|
5009
|
+
parameterName: currentTask.resultingParameterName,
|
|
4982
5010
|
parameterValue: null,
|
|
4983
5011
|
// <- [🍸]
|
|
4984
5012
|
})];
|
|
4985
5013
|
case 1:
|
|
4986
5014
|
_j.sent();
|
|
4987
|
-
usedParameterNames =
|
|
4988
|
-
dependentParameterNames = new Set(
|
|
5015
|
+
usedParameterNames = extractParameterNamesFromTask(currentTask);
|
|
5016
|
+
dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
4989
5017
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
4990
5018
|
if (union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)).size !== 0) {
|
|
4991
5019
|
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Dependent parameters are not consistent with used parameters:\n\n Dependent parameters:\n ".concat(Array.from(dependentParameterNames)
|
|
@@ -4996,9 +5024,9 @@ function executeTemplate(options) {
|
|
|
4996
5024
|
}
|
|
4997
5025
|
_c = (_b = Object).freeze;
|
|
4998
5026
|
_d = [{}];
|
|
4999
|
-
return [4 /*yield*/,
|
|
5027
|
+
return [4 /*yield*/, getReservedParametersForTask({
|
|
5000
5028
|
preparedPipeline: preparedPipeline,
|
|
5001
|
-
|
|
5029
|
+
task: currentTask,
|
|
5002
5030
|
pipelineIdentification: pipelineIdentification,
|
|
5003
5031
|
})];
|
|
5004
5032
|
case 2:
|
|
@@ -5016,11 +5044,11 @@ function executeTemplate(options) {
|
|
|
5016
5044
|
else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
|
|
5017
5045
|
// Houston, we have a problem
|
|
5018
5046
|
// Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
|
|
5019
|
-
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Parameter {".concat(parameterName, "} is NOT defined\n BUT used in
|
|
5047
|
+
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Parameter `{".concat(parameterName, "}` is NOT defined\n BUT used in task \"").concat(currentTask.title || currentTask.name, "\"\n\n This should be catched in `validatePipeline`\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
|
|
5020
5048
|
}
|
|
5021
5049
|
};
|
|
5022
5050
|
try {
|
|
5023
|
-
// Note: [2] Check that all used parameters are defined and removing unused parameters for this
|
|
5051
|
+
// Note: [2] Check that all used parameters are defined and removing unused parameters for this task
|
|
5024
5052
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
5025
5053
|
for (_e = __values(Array.from(union(definedParameterNames, usedParameterNames, dependentParameterNames))), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
5026
5054
|
parameterName = _f.value;
|
|
@@ -5036,18 +5064,16 @@ function executeTemplate(options) {
|
|
|
5036
5064
|
}
|
|
5037
5065
|
// Note: [👨👨👧] Now we can freeze `parameters` because we are sure that all and only used parameters are defined and are not going to be changed
|
|
5038
5066
|
Object.freeze(parameters);
|
|
5039
|
-
maxAttempts =
|
|
5040
|
-
jokerParameterNames =
|
|
5041
|
-
preparedContent = (
|
|
5042
|
-
.split('{content}')
|
|
5043
|
-
.join(currentTemplate.content);
|
|
5067
|
+
maxAttempts = currentTask.taskType === 'DIALOG_TASK' ? Infinity : maxExecutionAttempts;
|
|
5068
|
+
jokerParameterNames = currentTask.jokerParameterNames || [];
|
|
5069
|
+
preparedContent = (currentTask.preparedContent || '{content}').split('{content}').join(currentTask.content);
|
|
5044
5070
|
return [4 /*yield*/, executeFormatSubvalues({
|
|
5045
5071
|
jokerParameterNames: jokerParameterNames,
|
|
5046
5072
|
priority: priority,
|
|
5047
5073
|
maxAttempts: maxAttempts,
|
|
5048
5074
|
preparedContent: preparedContent,
|
|
5049
5075
|
parameters: parameters,
|
|
5050
|
-
|
|
5076
|
+
task: currentTask,
|
|
5051
5077
|
preparedPipeline: preparedPipeline,
|
|
5052
5078
|
tools: tools,
|
|
5053
5079
|
$executionReport: $executionReport,
|
|
@@ -5060,15 +5086,15 @@ function executeTemplate(options) {
|
|
|
5060
5086
|
title: title,
|
|
5061
5087
|
isStarted: true,
|
|
5062
5088
|
isDone: true,
|
|
5063
|
-
|
|
5064
|
-
parameterName:
|
|
5089
|
+
taskType: currentTask.taskType,
|
|
5090
|
+
parameterName: currentTask.resultingParameterName,
|
|
5065
5091
|
parameterValue: resultString,
|
|
5066
5092
|
// <- [🍸]
|
|
5067
5093
|
})];
|
|
5068
5094
|
case 4:
|
|
5069
5095
|
_j.sent();
|
|
5070
5096
|
return [2 /*return*/, Object.freeze((_h = {},
|
|
5071
|
-
_h[
|
|
5097
|
+
_h[currentTask.resultingParameterName] =
|
|
5072
5098
|
// <- Note: [👩👩👧] No need to detect parameter collision here because pipeline checks logic consistency during construction
|
|
5073
5099
|
resultString,
|
|
5074
5100
|
_h))];
|
|
@@ -5095,7 +5121,7 @@ function filterJustOutputParameters(options) {
|
|
|
5095
5121
|
var _loop_1 = function (parameter) {
|
|
5096
5122
|
if (parametersToPass[parameter.name] === undefined) {
|
|
5097
5123
|
// [4]
|
|
5098
|
-
$warnings.push(new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Parameter {".concat(parameter.name, "} should be an output parameter, but it was not generated during pipeline execution\n\n ").concat(block(pipelineIdentification), "\n "); })));
|
|
5124
|
+
$warnings.push(new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Parameter `{".concat(parameter.name, "}` should be an output parameter, but it was not generated during pipeline execution\n\n ").concat(block(pipelineIdentification), "\n "); })));
|
|
5099
5125
|
return "continue";
|
|
5100
5126
|
}
|
|
5101
5127
|
outputParameters[parameter.name] = parametersToPass[parameter.name] || '';
|
|
@@ -5130,7 +5156,7 @@ function filterJustOutputParameters(options) {
|
|
|
5130
5156
|
*/
|
|
5131
5157
|
function executePipeline(options) {
|
|
5132
5158
|
return __awaiter(this, void 0, void 0, function () {
|
|
5133
|
-
var inputParameters, tools, onProgress, pipeline, setPreparedPipeline, pipelineIdentification, maxParallelCount, rootDirname, _a, isVerbose, preparedPipeline, errors, warnings, executionReport, isReturned, _b, _c, parameter, e_1_1, _loop_1, _d, _e, parameterName, state_1, e_2_1, parametersToPass, resovedParameterNames_1,
|
|
5159
|
+
var inputParameters, tools, onProgress, pipeline, setPreparedPipeline, pipelineIdentification, maxParallelCount, rootDirname, _a, isVerbose, preparedPipeline, errors, warnings, executionReport, isReturned, _b, _c, parameter, e_1_1, _loop_1, _d, _e, parameterName, state_1, e_2_1, parametersToPass, resovedParameterNames_1, unresovedTasks_1, resolving_1, loopLimit, _loop_2, error_1, usage_1, outputParameters_1, usage, outputParameters;
|
|
5134
5160
|
var e_1, _f, e_2, _g;
|
|
5135
5161
|
return __generator(this, function (_h) {
|
|
5136
5162
|
switch (_h.label) {
|
|
@@ -5182,7 +5208,7 @@ function executePipeline(options) {
|
|
|
5182
5208
|
case 6: return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
|
|
5183
5209
|
isSuccessful: false,
|
|
5184
5210
|
errors: __spreadArray([
|
|
5185
|
-
new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter"))
|
|
5211
|
+
new PipelineExecutionError("Parameter `{".concat(parameter.name, "}` is required as an input parameter"))
|
|
5186
5212
|
], __read(errors), false).map(serializeError),
|
|
5187
5213
|
warnings: [],
|
|
5188
5214
|
executionReport: executionReport,
|
|
@@ -5230,7 +5256,7 @@ function executePipeline(options) {
|
|
|
5230
5256
|
case 3: return [2 /*return*/, { value: $asDeeplyFrozenSerializableJson(spaceTrim$1(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
|
|
5231
5257
|
isSuccessful: false,
|
|
5232
5258
|
errors: __spreadArray([
|
|
5233
|
-
new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Parameter {".concat(parameter.name, "} is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
|
|
5259
|
+
new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
|
|
5234
5260
|
], __read(errors), false).map(serializeError),
|
|
5235
5261
|
warnings: warnings.map(serializeError),
|
|
5236
5262
|
executionReport: executionReport,
|
|
@@ -5284,11 +5310,11 @@ function executePipeline(options) {
|
|
|
5284
5310
|
var name = _a.name;
|
|
5285
5311
|
return name;
|
|
5286
5312
|
});
|
|
5287
|
-
|
|
5313
|
+
unresovedTasks_1 = __spreadArray([], __read(preparedPipeline.tasks), false);
|
|
5288
5314
|
resolving_1 = [];
|
|
5289
5315
|
loopLimit = LOOP_LIMIT;
|
|
5290
5316
|
_loop_2 = function () {
|
|
5291
|
-
var
|
|
5317
|
+
var currentTask, work_1;
|
|
5292
5318
|
return __generator(this, function (_k) {
|
|
5293
5319
|
switch (_k.label) {
|
|
5294
5320
|
case 0:
|
|
@@ -5296,31 +5322,41 @@ function executePipeline(options) {
|
|
|
5296
5322
|
// Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
|
|
5297
5323
|
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Loop limit reached during resolving parameters pipeline execution\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
5298
5324
|
}
|
|
5299
|
-
|
|
5300
|
-
return
|
|
5325
|
+
currentTask = unresovedTasks_1.find(function (task) {
|
|
5326
|
+
return task.dependentParameterNames.every(function (name) {
|
|
5301
5327
|
return __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), __read(RESERVED_PARAMETER_NAMES), false).includes(name);
|
|
5302
5328
|
});
|
|
5303
5329
|
});
|
|
5304
|
-
if (!(!
|
|
5330
|
+
if (!(!currentTask && resolving_1.length === 0)) return [3 /*break*/, 1];
|
|
5305
5331
|
throw new UnexpectedError(
|
|
5306
5332
|
// TODO: [🐎] DRY
|
|
5307
|
-
spaceTrim$1(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n Can not resolve
|
|
5333
|
+
spaceTrim$1(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTasks_1
|
|
5308
5334
|
.map(function (_a) {
|
|
5309
5335
|
var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
|
|
5310
|
-
return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
|
|
5311
|
-
.map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
|
|
5336
|
+
return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
|
|
5337
|
+
.map(function (dependentParameterName) { return "`{".concat(dependentParameterName, "}`"); })
|
|
5312
5338
|
.join(' and '));
|
|
5313
5339
|
})
|
|
5314
|
-
.join('\n')), "\n\n Resolved
|
|
5340
|
+
.join('\n')), "\n\n **Resolved:**\n ").concat(block(resovedParameterNames_1
|
|
5341
|
+
.filter(function (name) {
|
|
5342
|
+
return !RESERVED_PARAMETER_NAMES.includes(name);
|
|
5343
|
+
})
|
|
5344
|
+
.map(function (name) { return "- Parameter `{".concat(name, "}`"); })
|
|
5345
|
+
.join('\n')), "\n\n **Reserved (which are available):**\n ").concat(block(resovedParameterNames_1
|
|
5346
|
+
.filter(function (name) {
|
|
5347
|
+
return RESERVED_PARAMETER_NAMES.includes(name);
|
|
5348
|
+
})
|
|
5349
|
+
.map(function (name) { return "- Parameter `{".concat(name, "}`"); })
|
|
5350
|
+
.join('\n')), "\n\n *Note: This should be catched in `validatePipeline`*\n "); }));
|
|
5315
5351
|
case 1:
|
|
5316
|
-
if (!!
|
|
5352
|
+
if (!!currentTask) return [3 /*break*/, 3];
|
|
5317
5353
|
/* [🤹♂️] */ return [4 /*yield*/, Promise.race(resolving_1)];
|
|
5318
5354
|
case 2:
|
|
5319
5355
|
/* [🤹♂️] */ _k.sent();
|
|
5320
5356
|
return [3 /*break*/, 4];
|
|
5321
5357
|
case 3:
|
|
5322
|
-
|
|
5323
|
-
work_1 =
|
|
5358
|
+
unresovedTasks_1 = unresovedTasks_1.filter(function (task) { return task !== currentTask; });
|
|
5359
|
+
work_1 = executeTask(__assign(__assign({}, options), { currentTask: currentTask, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (progress) {
|
|
5324
5360
|
if (isReturned) {
|
|
5325
5361
|
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(progress, null, 4)
|
|
5326
5362
|
.split('\n')
|
|
@@ -5330,16 +5366,16 @@ function executePipeline(options) {
|
|
|
5330
5366
|
if (onProgress) {
|
|
5331
5367
|
onProgress(progress);
|
|
5332
5368
|
}
|
|
5333
|
-
}, $executionReport: executionReport, pipelineIdentification: spaceTrim$1(function (block) { return "\n ".concat(block(pipelineIdentification), "\n
|
|
5369
|
+
}, $executionReport: executionReport, pipelineIdentification: spaceTrim$1(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Task name: ").concat(currentTask.name, "\n Task title: ").concat(currentTask.title, "\n "); }) }))
|
|
5334
5370
|
.then(function (newParametersToPass) {
|
|
5335
5371
|
parametersToPass = __assign(__assign({}, newParametersToPass), parametersToPass);
|
|
5336
|
-
resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [
|
|
5372
|
+
resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [currentTask.resultingParameterName], false);
|
|
5337
5373
|
})
|
|
5338
5374
|
.then(function () {
|
|
5339
5375
|
resolving_1 = resolving_1.filter(function (w) { return w !== work_1; });
|
|
5340
5376
|
});
|
|
5341
5377
|
// <- Note: Errors are catched here [3]
|
|
5342
|
-
// TODO: BUT if in multiple
|
|
5378
|
+
// TODO: BUT if in multiple tasks are errors, only the first one is catched so maybe we should catch errors here and save them to errors array here
|
|
5343
5379
|
resolving_1.push(work_1);
|
|
5344
5380
|
_k.label = 4;
|
|
5345
5381
|
case 4: return [2 /*return*/];
|
|
@@ -5348,7 +5384,7 @@ function executePipeline(options) {
|
|
|
5348
5384
|
};
|
|
5349
5385
|
_h.label = 21;
|
|
5350
5386
|
case 21:
|
|
5351
|
-
if (!(
|
|
5387
|
+
if (!(unresovedTasks_1.length > 0)) return [3 /*break*/, 23];
|
|
5352
5388
|
return [5 /*yield**/, _loop_2()];
|
|
5353
5389
|
case 22:
|
|
5354
5390
|
_h.sent();
|
|
@@ -5506,6 +5542,9 @@ var markdownScraperMetadata = $deepFreeze({
|
|
|
5506
5542
|
* @public exported from `@promptbook/cli`
|
|
5507
5543
|
*/
|
|
5508
5544
|
$scrapersMetadataRegister.register(markdownScraperMetadata);
|
|
5545
|
+
/**
|
|
5546
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
5547
|
+
*/
|
|
5509
5548
|
|
|
5510
5549
|
/**
|
|
5511
5550
|
* Scraper for markdown files
|
|
@@ -5700,6 +5739,7 @@ var createMarkdownScraper = Object.assign(function (tools, options) {
|
|
|
5700
5739
|
var _MarkdownScraperRegistration = $scrapersRegister.register(createMarkdownScraper);
|
|
5701
5740
|
/**
|
|
5702
5741
|
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
5742
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
5703
5743
|
*/
|
|
5704
5744
|
|
|
5705
5745
|
/**
|