@promptbook/pdf 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 +279 -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 +5 -4
- package/umd/index.umd.js +279 -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
|
/*! *****************************************************************************
|
|
@@ -173,7 +174,7 @@ var NotYetImplementedError = /** @class */ (function (_super) {
|
|
|
173
174
|
function TODO_USE() {
|
|
174
175
|
}
|
|
175
176
|
|
|
176
|
-
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}],
|
|
177
|
+
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"}];
|
|
177
178
|
|
|
178
179
|
/**
|
|
179
180
|
* Prettify the html code
|
|
@@ -227,7 +228,7 @@ function capitalize(word) {
|
|
|
227
228
|
*/
|
|
228
229
|
function pipelineJsonToString(pipelineJson) {
|
|
229
230
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
|
|
230
|
-
var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters,
|
|
231
|
+
var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, tasks = pipelineJson.tasks;
|
|
231
232
|
var pipelineString = "# ".concat(title);
|
|
232
233
|
if (description) {
|
|
233
234
|
pipelineString += '\n\n';
|
|
@@ -277,13 +278,13 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
277
278
|
pipelineString += '\n\n';
|
|
278
279
|
pipelineString += commands.map(function (command) { return "- ".concat(command); }).join('\n');
|
|
279
280
|
try {
|
|
280
|
-
for (var
|
|
281
|
-
var template =
|
|
281
|
+
for (var tasks_1 = __values(tasks), tasks_1_1 = tasks_1.next(); !tasks_1_1.done; tasks_1_1 = tasks_1.next()) {
|
|
282
|
+
var template = tasks_1_1.value;
|
|
282
283
|
var
|
|
283
284
|
/* Note: Not using:> name, */
|
|
284
285
|
title_1 = template.title, description_1 = template.description,
|
|
285
286
|
/* Note: dependentParameterNames, */
|
|
286
|
-
jokers = template.jokerParameterNames,
|
|
287
|
+
jokers = template.jokerParameterNames, taskType = template.taskType, content = template.content, postprocessing = template.postprocessingFunctionNames, expectations = template.expectations, format = template.format, resultingParameterName = template.resultingParameterName;
|
|
287
288
|
pipelineString += '\n\n';
|
|
288
289
|
pipelineString += "## ".concat(title_1);
|
|
289
290
|
if (description_1) {
|
|
@@ -292,7 +293,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
292
293
|
}
|
|
293
294
|
var commands_1 = [];
|
|
294
295
|
var contentLanguage = 'text';
|
|
295
|
-
if (
|
|
296
|
+
if (taskType === 'PROMPT_TASK') {
|
|
296
297
|
var modelRequirements = template.modelRequirements;
|
|
297
298
|
var _l = modelRequirements || {}, modelName = _l.modelName, modelVariant = _l.modelVariant;
|
|
298
299
|
commands_1.push("EXECUTE PROMPT TEMPLATE");
|
|
@@ -303,11 +304,11 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
303
304
|
commands_1.push("MODEL NAME `".concat(modelName, "`"));
|
|
304
305
|
}
|
|
305
306
|
}
|
|
306
|
-
else if (
|
|
307
|
+
else if (taskType === 'SIMPLE_TASK') {
|
|
307
308
|
commands_1.push("SIMPLE TEMPLATE");
|
|
308
309
|
// Note: Nothing special here
|
|
309
310
|
}
|
|
310
|
-
else if (
|
|
311
|
+
else if (taskType === 'SCRIPT_TASK') {
|
|
311
312
|
commands_1.push("SCRIPT TEMPLATE");
|
|
312
313
|
if (template.contentLanguage) {
|
|
313
314
|
contentLanguage = template.contentLanguage;
|
|
@@ -316,7 +317,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
316
317
|
contentLanguage = '';
|
|
317
318
|
}
|
|
318
319
|
}
|
|
319
|
-
else if (
|
|
320
|
+
else if (taskType === 'DIALOG_TASK') {
|
|
320
321
|
commands_1.push("DIALOG TEMPLATE");
|
|
321
322
|
// Note: Nothing special here
|
|
322
323
|
} // <- }else if([🅱]
|
|
@@ -398,7 +399,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
398
399
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
399
400
|
finally {
|
|
400
401
|
try {
|
|
401
|
-
if (
|
|
402
|
+
if (tasks_1_1 && !tasks_1_1.done && (_c = tasks_1.return)) _c.call(tasks_1);
|
|
402
403
|
}
|
|
403
404
|
finally { if (e_3) throw e_3.error; }
|
|
404
405
|
}
|
|
@@ -724,6 +725,8 @@ var IS_PIPELINE_LOGIC_VALIDATED = just(
|
|
|
724
725
|
// Note: In normal situations, we check the pipeline logic:
|
|
725
726
|
true);
|
|
726
727
|
/**
|
|
728
|
+
* TODO: Extract `constants.ts` from `config.ts`
|
|
729
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
727
730
|
* TODO: [🧠][🧜♂️] Maybe join remoteUrl and path into single value
|
|
728
731
|
*/
|
|
729
732
|
|
|
@@ -979,24 +982,23 @@ function validatePipelineCore(pipeline) {
|
|
|
979
982
|
throw new ParseError(spaceTrim(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 "); }));
|
|
980
983
|
}
|
|
981
984
|
// TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
|
|
982
|
-
if (!Array.isArray(pipeline.
|
|
985
|
+
if (!Array.isArray(pipeline.tasks)) {
|
|
983
986
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
984
|
-
throw new ParseError(spaceTrim(function (block) { return "\n Pipeline is valid JSON but with wrong structure\n\n `PipelineJson.
|
|
987
|
+
throw new ParseError(spaceTrim(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 "); }));
|
|
985
988
|
}
|
|
986
989
|
var _loop_1 = function (parameter) {
|
|
987
990
|
if (parameter.isInput && parameter.isOutput) {
|
|
988
|
-
throw new PipelineLogicError(spaceTrim(function (block) { return "\n\n Parameter {".concat(parameter.name, "} can not be both input and output\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
991
|
+
throw new PipelineLogicError(spaceTrim(function (block) { return "\n\n Parameter `{".concat(parameter.name, "}` can not be both input and output\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
989
992
|
}
|
|
990
993
|
// Note: Testing that parameter is either intermediate or output BUT not created and unused
|
|
991
994
|
if (!parameter.isInput &&
|
|
992
995
|
!parameter.isOutput &&
|
|
993
|
-
!pipeline.
|
|
994
|
-
throw new PipelineLogicError(spaceTrim(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 "); }));
|
|
996
|
+
!pipeline.tasks.some(function (task) { return task.dependentParameterNames.includes(parameter.name); })) {
|
|
997
|
+
throw new PipelineLogicError(spaceTrim(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 "); }));
|
|
995
998
|
}
|
|
996
|
-
// Note: Testing that parameter is either input or result of some
|
|
997
|
-
if (!parameter.isInput &&
|
|
998
|
-
|
|
999
|
-
throw new PipelineLogicError(spaceTrim(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 "); }));
|
|
999
|
+
// Note: Testing that parameter is either input or result of some task
|
|
1000
|
+
if (!parameter.isInput && !pipeline.tasks.some(function (task) { return task.resultingParameterName === parameter.name; })) {
|
|
1001
|
+
throw new PipelineLogicError(spaceTrim(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 "); }));
|
|
1000
1002
|
}
|
|
1001
1003
|
};
|
|
1002
1004
|
try {
|
|
@@ -1013,7 +1015,7 @@ function validatePipelineCore(pipeline) {
|
|
|
1013
1015
|
}
|
|
1014
1016
|
finally { if (e_1) throw e_1.error; }
|
|
1015
1017
|
}
|
|
1016
|
-
// Note: All input parameters are defined - so that they can be used as result of some
|
|
1018
|
+
// Note: All input parameters are defined - so that they can be used as result of some task
|
|
1017
1019
|
var definedParameters = new Set(pipeline.parameters.filter(function (_a) {
|
|
1018
1020
|
var isInput = _a.isInput;
|
|
1019
1021
|
return isInput;
|
|
@@ -1021,27 +1023,27 @@ function validatePipelineCore(pipeline) {
|
|
|
1021
1023
|
var name = _a.name;
|
|
1022
1024
|
return name;
|
|
1023
1025
|
}));
|
|
1024
|
-
var _loop_2 = function (
|
|
1026
|
+
var _loop_2 = function (task) {
|
|
1025
1027
|
var e_4, _h, e_5, _j;
|
|
1026
|
-
if (definedParameters.has(
|
|
1027
|
-
throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter {".concat(
|
|
1028
|
+
if (definedParameters.has(task.resultingParameterName)) {
|
|
1029
|
+
throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter `{".concat(task.resultingParameterName, "}` is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1028
1030
|
}
|
|
1029
|
-
if (RESERVED_PARAMETER_NAMES.includes(
|
|
1030
|
-
throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter name {".concat(
|
|
1031
|
+
if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
|
|
1032
|
+
throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter name {".concat(task.resultingParameterName, "} is reserved, please use different name\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1031
1033
|
}
|
|
1032
|
-
definedParameters.add(
|
|
1033
|
-
if (
|
|
1034
|
-
if (!
|
|
1035
|
-
!
|
|
1036
|
-
throw new PipelineLogicError(spaceTrim(function (block) { return "\n Joker parameters are used for {".concat(
|
|
1034
|
+
definedParameters.add(task.resultingParameterName);
|
|
1035
|
+
if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
|
|
1036
|
+
if (!task.format &&
|
|
1037
|
+
!task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
|
|
1038
|
+
throw new PipelineLogicError(spaceTrim(function (block) { return "\n Joker parameters are used for {".concat(task.resultingParameterName, "} but no expectations are defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1037
1039
|
}
|
|
1038
1040
|
var _loop_4 = function (joker) {
|
|
1039
|
-
if (!
|
|
1040
|
-
throw new PipelineLogicError(spaceTrim(function (block) { return "\n Parameter {".concat(joker, "} is used for {").concat(
|
|
1041
|
+
if (!task.dependentParameterNames.includes(joker)) {
|
|
1042
|
+
throw new PipelineLogicError(spaceTrim(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 "); }));
|
|
1041
1043
|
}
|
|
1042
1044
|
};
|
|
1043
1045
|
try {
|
|
1044
|
-
for (var _k = (e_4 = void 0, __values(
|
|
1046
|
+
for (var _k = (e_4 = void 0, __values(task.jokerParameterNames)), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
1045
1047
|
var joker = _l.value;
|
|
1046
1048
|
_loop_4(joker);
|
|
1047
1049
|
}
|
|
@@ -1054,7 +1056,7 @@ function validatePipelineCore(pipeline) {
|
|
|
1054
1056
|
finally { if (e_4) throw e_4.error; }
|
|
1055
1057
|
}
|
|
1056
1058
|
}
|
|
1057
|
-
if (
|
|
1059
|
+
if (task.expectations) {
|
|
1058
1060
|
var _loop_5 = function (unit, min, max) {
|
|
1059
1061
|
if (min !== undefined && max !== undefined && min > max) {
|
|
1060
1062
|
throw new PipelineLogicError(spaceTrim(function (block) { return "\n Min expectation (=".concat(min, ") of ").concat(unit, " is higher than max expectation (=").concat(max, ")\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
@@ -1067,7 +1069,7 @@ function validatePipelineCore(pipeline) {
|
|
|
1067
1069
|
}
|
|
1068
1070
|
};
|
|
1069
1071
|
try {
|
|
1070
|
-
for (var _m = (e_5 = void 0, __values(Object.entries(
|
|
1072
|
+
for (var _m = (e_5 = void 0, __values(Object.entries(task.expectations))), _o = _m.next(); !_o.done; _o = _m.next()) {
|
|
1071
1073
|
var _p = __read(_o.value, 2), unit = _p[0], _q = _p[1], min = _q.min, max = _q.max;
|
|
1072
1074
|
_loop_5(unit, min, max);
|
|
1073
1075
|
}
|
|
@@ -1082,10 +1084,10 @@ function validatePipelineCore(pipeline) {
|
|
|
1082
1084
|
}
|
|
1083
1085
|
};
|
|
1084
1086
|
try {
|
|
1085
|
-
// Note: Checking each
|
|
1086
|
-
for (var _f = __values(pipeline.
|
|
1087
|
-
var
|
|
1088
|
-
_loop_2(
|
|
1087
|
+
// Note: Checking each task individually
|
|
1088
|
+
for (var _f = __values(pipeline.tasks), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
1089
|
+
var task = _g.value;
|
|
1090
|
+
_loop_2(task);
|
|
1089
1091
|
}
|
|
1090
1092
|
}
|
|
1091
1093
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
@@ -1119,37 +1121,48 @@ function validatePipelineCore(pipeline) {
|
|
|
1119
1121
|
}
|
|
1120
1122
|
finally { if (e_3) throw e_3.error; }
|
|
1121
1123
|
}
|
|
1122
|
-
var unresovedTemplates = __spreadArray([], __read(pipeline.
|
|
1124
|
+
var unresovedTemplates = __spreadArray([], __read(pipeline.tasks), false);
|
|
1123
1125
|
var loopLimit = LOOP_LIMIT;
|
|
1124
1126
|
var _loop_3 = function () {
|
|
1125
1127
|
if (loopLimit-- < 0) {
|
|
1126
1128
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
1127
1129
|
throw new UnexpectedError(spaceTrim(function (block) { return "\n Loop limit reached during detection of circular dependencies in `validatePipeline`\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
1128
1130
|
}
|
|
1129
|
-
var currentlyResovedTemplates = unresovedTemplates.filter(function (
|
|
1130
|
-
return
|
|
1131
|
+
var currentlyResovedTemplates = unresovedTemplates.filter(function (task) {
|
|
1132
|
+
return task.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
|
|
1131
1133
|
});
|
|
1132
1134
|
if (currentlyResovedTemplates.length === 0) {
|
|
1133
1135
|
throw new PipelineLogicError(
|
|
1134
1136
|
// TODO: [🐎] DRY
|
|
1135
|
-
spaceTrim(function (block) { return "\n\n Can not resolve some parameters:\n Either you are using a parameter that is not defined, or there are some circular dependencies.\n\n ".concat(block(pipelineIdentification), "\n\n Can not resolve
|
|
1137
|
+
spaceTrim(function (block) { return "\n\n Can not resolve some parameters:\n Either you are using a parameter that is not defined, or there are some circular dependencies.\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTemplates
|
|
1136
1138
|
.map(function (_a) {
|
|
1137
1139
|
var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
|
|
1138
|
-
return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
|
|
1139
|
-
.map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
|
|
1140
|
+
return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
|
|
1141
|
+
.map(function (dependentParameterName) { return "`{".concat(dependentParameterName, "}`"); })
|
|
1140
1142
|
.join(' and '));
|
|
1141
1143
|
})
|
|
1142
|
-
.join('\n')), "\n\n Resolved
|
|
1144
|
+
.join('\n')), "\n\n **Resolved:**\n ").concat(block(resovedParameters
|
|
1145
|
+
.filter(function (name) {
|
|
1146
|
+
return !RESERVED_PARAMETER_NAMES.includes(name);
|
|
1147
|
+
})
|
|
1148
|
+
.map(function (name) { return "- Parameter `{".concat(name, "}`"); })
|
|
1149
|
+
.join('\n')), "\n\n\n **Reserved (which are available):**\n ").concat(block(resovedParameters
|
|
1150
|
+
.filter(function (name) {
|
|
1151
|
+
return RESERVED_PARAMETER_NAMES.includes(name);
|
|
1152
|
+
})
|
|
1153
|
+
.map(function (name) { return "- Parameter `{".concat(name, "}`"); })
|
|
1154
|
+
.join('\n')), "\n\n\n "); }));
|
|
1143
1155
|
}
|
|
1144
1156
|
resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTemplates.map(function (_a) {
|
|
1145
1157
|
var resultingParameterName = _a.resultingParameterName;
|
|
1146
1158
|
return resultingParameterName;
|
|
1147
1159
|
})), false);
|
|
1148
|
-
unresovedTemplates = unresovedTemplates.filter(function (
|
|
1160
|
+
unresovedTemplates = unresovedTemplates.filter(function (task) { return !currentlyResovedTemplates.includes(task); });
|
|
1149
1161
|
};
|
|
1150
1162
|
while (unresovedTemplates.length > 0) {
|
|
1151
1163
|
_loop_3();
|
|
1152
1164
|
}
|
|
1165
|
+
// TODO: !!!!!! Test that pipeline interface implements declared formfactor interface
|
|
1153
1166
|
}
|
|
1154
1167
|
/**
|
|
1155
1168
|
* TODO: !! [🧞♀️] Do not allow joker + foreach
|
|
@@ -1206,9 +1219,9 @@ var PipelineUrlError = /** @class */ (function (_super) {
|
|
|
1206
1219
|
}(Error));
|
|
1207
1220
|
|
|
1208
1221
|
/**
|
|
1209
|
-
* Parses the
|
|
1222
|
+
* Parses the task and returns the list of all parameter names
|
|
1210
1223
|
*
|
|
1211
|
-
* @param template the
|
|
1224
|
+
* @param template the task with parameters in {curly} braces
|
|
1212
1225
|
* @returns the list of parameter names
|
|
1213
1226
|
* @public exported from `@promptbook/utils`
|
|
1214
1227
|
*/
|
|
@@ -1239,10 +1252,10 @@ function extractParameterNames(template) {
|
|
|
1239
1252
|
* @public exported from `@promptbook/core`
|
|
1240
1253
|
*/
|
|
1241
1254
|
function unpreparePipeline(pipeline) {
|
|
1242
|
-
var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources,
|
|
1255
|
+
var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, tasks = pipeline.tasks;
|
|
1243
1256
|
personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
|
|
1244
1257
|
knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
|
|
1245
|
-
|
|
1258
|
+
tasks = tasks.map(function (template) {
|
|
1246
1259
|
var dependentParameterNames = template.dependentParameterNames;
|
|
1247
1260
|
var parameterNames = extractParameterNames(template.preparedContent || '');
|
|
1248
1261
|
dependentParameterNames = dependentParameterNames.filter(function (dependentParameterName) { return !parameterNames.has(dependentParameterName); });
|
|
@@ -1250,7 +1263,7 @@ function unpreparePipeline(pipeline) {
|
|
|
1250
1263
|
delete templateUnprepared.preparedContent;
|
|
1251
1264
|
return templateUnprepared;
|
|
1252
1265
|
});
|
|
1253
|
-
return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), {
|
|
1266
|
+
return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), { tasks: tasks, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }));
|
|
1254
1267
|
}
|
|
1255
1268
|
/**
|
|
1256
1269
|
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
@@ -1682,6 +1695,9 @@ function normalizeToKebabCase(text) {
|
|
|
1682
1695
|
normalizedName = normalizedName.replace(/-$/, '');
|
|
1683
1696
|
return normalizedName;
|
|
1684
1697
|
}
|
|
1698
|
+
/**
|
|
1699
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
1700
|
+
*/
|
|
1685
1701
|
|
|
1686
1702
|
/**
|
|
1687
1703
|
* Removes emojis from a string and fix whitespaces
|
|
@@ -1867,6 +1883,9 @@ var ERRORS = {
|
|
|
1867
1883
|
UnexpectedError: UnexpectedError,
|
|
1868
1884
|
// TODO: [🪑]> VersionMismatchError,
|
|
1869
1885
|
};
|
|
1886
|
+
/**
|
|
1887
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
1888
|
+
*/
|
|
1870
1889
|
|
|
1871
1890
|
/**
|
|
1872
1891
|
* Deserializes the error object
|
|
@@ -1928,8 +1947,8 @@ function isPipelinePrepared(pipeline) {
|
|
|
1928
1947
|
return false;
|
|
1929
1948
|
}
|
|
1930
1949
|
/*
|
|
1931
|
-
TODO: [🧠][🍫] `
|
|
1932
|
-
> if (!pipeline.
|
|
1950
|
+
TODO: [🧠][🍫] `tasks` can not be determined if they are fully prepared SO ignoring them
|
|
1951
|
+
> if (!pipeline.tasks.every(({ preparedContent }) => preparedContent === undefined)) {
|
|
1933
1952
|
> return false;
|
|
1934
1953
|
> }
|
|
1935
1954
|
*/
|
|
@@ -1942,7 +1961,7 @@ function isPipelinePrepared(pipeline) {
|
|
|
1942
1961
|
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
1943
1962
|
* - [🏍] ? Is context in each template
|
|
1944
1963
|
* - [♨] Are examples prepared
|
|
1945
|
-
* - [♨] Are
|
|
1964
|
+
* - [♨] Are tasks prepared
|
|
1946
1965
|
*/
|
|
1947
1966
|
|
|
1948
1967
|
/**
|
|
@@ -2090,6 +2109,9 @@ $deepFreeze({
|
|
|
2090
2109
|
pagesCount: { value: 0, isUncertain: true },
|
|
2091
2110
|
},
|
|
2092
2111
|
});
|
|
2112
|
+
/**
|
|
2113
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2114
|
+
*/
|
|
2093
2115
|
|
|
2094
2116
|
/**
|
|
2095
2117
|
* @@@
|
|
@@ -2489,8 +2511,8 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
|
|
|
2489
2511
|
else if (errors.length > 1) {
|
|
2490
2512
|
throw new PipelineExecutionError(
|
|
2491
2513
|
// TODO: Tell which execution tools failed like
|
|
2492
|
-
// 1) OpenAI throw PipelineExecutionError: Parameter {knowledge} is not defined
|
|
2493
|
-
// 2) AnthropicClaude throw PipelineExecutionError: Parameter {knowledge} is not defined
|
|
2514
|
+
// 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
2515
|
+
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
2494
2516
|
// 3) ...
|
|
2495
2517
|
spaceTrim$1(function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors
|
|
2496
2518
|
.map(function (error, i) { return "".concat(i + 1, ") **").concat(error.name || 'Error', ":** ").concat(error.message); })
|
|
@@ -3276,7 +3298,7 @@ TODO: [🧊] This is how it can look in future
|
|
|
3276
3298
|
*/
|
|
3277
3299
|
function clonePipeline(pipeline) {
|
|
3278
3300
|
// Note: Not using spread operator (...) because @@@
|
|
3279
|
-
var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, bookVersion = pipeline.bookVersion, description = pipeline.description, formfactorName = pipeline.formfactorName, parameters = pipeline.parameters,
|
|
3301
|
+
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;
|
|
3280
3302
|
return {
|
|
3281
3303
|
pipelineUrl: pipelineUrl,
|
|
3282
3304
|
sourceFile: sourceFile,
|
|
@@ -3285,7 +3307,7 @@ function clonePipeline(pipeline) {
|
|
|
3285
3307
|
description: description,
|
|
3286
3308
|
formfactorName: formfactorName,
|
|
3287
3309
|
parameters: parameters,
|
|
3288
|
-
|
|
3310
|
+
tasks: tasks,
|
|
3289
3311
|
knowledgeSources: knowledgeSources,
|
|
3290
3312
|
knowledgePieces: knowledgePieces,
|
|
3291
3313
|
personas: personas,
|
|
@@ -3301,17 +3323,17 @@ function clonePipeline(pipeline) {
|
|
|
3301
3323
|
*
|
|
3302
3324
|
* @public exported from `@promptbook/core`
|
|
3303
3325
|
*/
|
|
3304
|
-
function
|
|
3326
|
+
function prepareTasks(pipeline, tools, options) {
|
|
3305
3327
|
return __awaiter(this, void 0, void 0, function () {
|
|
3306
|
-
var _a, maxParallelCount,
|
|
3328
|
+
var _a, maxParallelCount, tasks, knowledgePiecesCount, tasksPrepared;
|
|
3307
3329
|
var _this = this;
|
|
3308
3330
|
return __generator(this, function (_b) {
|
|
3309
3331
|
switch (_b.label) {
|
|
3310
3332
|
case 0:
|
|
3311
3333
|
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
return [4 /*yield*/, forEachAsync(
|
|
3334
|
+
tasks = pipeline.tasks, pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
|
|
3335
|
+
tasksPrepared = new Array(tasks.length);
|
|
3336
|
+
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 () {
|
|
3315
3337
|
var dependentParameterNames, preparedContent, preparedTemplate;
|
|
3316
3338
|
return __generator(this, function (_a) {
|
|
3317
3339
|
dependentParameterNames = template.dependentParameterNames;
|
|
@@ -3324,13 +3346,13 @@ function prepareTemplates(pipeline, tools, options) {
|
|
|
3324
3346
|
], false);
|
|
3325
3347
|
}
|
|
3326
3348
|
preparedTemplate = __assign(__assign({}, template), { dependentParameterNames: dependentParameterNames, preparedContent: preparedContent });
|
|
3327
|
-
|
|
3349
|
+
tasksPrepared[index] = preparedTemplate;
|
|
3328
3350
|
return [2 /*return*/];
|
|
3329
3351
|
});
|
|
3330
3352
|
}); })];
|
|
3331
3353
|
case 1:
|
|
3332
3354
|
_b.sent();
|
|
3333
|
-
return [2 /*return*/, {
|
|
3355
|
+
return [2 /*return*/, { tasksPrepared: tasksPrepared }];
|
|
3334
3356
|
}
|
|
3335
3357
|
});
|
|
3336
3358
|
});
|
|
@@ -3338,7 +3360,7 @@ function prepareTemplates(pipeline, tools, options) {
|
|
|
3338
3360
|
/**
|
|
3339
3361
|
* TODO: [🧠] Add context to each template (if missing)
|
|
3340
3362
|
* TODO: [🧠] What is better name `prepareTemplate` or `prepareTemplateAndParameters`
|
|
3341
|
-
* TODO: [♨][main] !!! Prepare index the examples and maybe
|
|
3363
|
+
* TODO: [♨][main] !!! Prepare index the examples and maybe tasks
|
|
3342
3364
|
* TODO: Write tests for `preparePipeline`
|
|
3343
3365
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
3344
3366
|
* TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
|
|
@@ -3355,12 +3377,12 @@ function prepareTemplates(pipeline, tools, options) {
|
|
|
3355
3377
|
*/
|
|
3356
3378
|
function preparePipeline(pipeline, tools, options) {
|
|
3357
3379
|
return __awaiter(this, void 0, void 0, function () {
|
|
3358
|
-
var rootDirname, _a, maxParallelCount, _b, isVerbose, parameters,
|
|
3380
|
+
var rootDirname, _a, maxParallelCount, _b, isVerbose, parameters, tasks,
|
|
3359
3381
|
/*
|
|
3360
3382
|
<- TODO: [🧠][🪑] `promptbookVersion` */
|
|
3361
3383
|
knowledgeSources /*
|
|
3362
3384
|
<- TODO: [🧊] `knowledgePieces` */, personas /*
|
|
3363
|
-
<- TODO: [🧊] `preparations` */, _llms, llmTools, llmToolsWithUsage, currentPreparation, preparations, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared,
|
|
3385
|
+
<- TODO: [🧊] `preparations` */, _llms, llmTools, llmToolsWithUsage, currentPreparation, preparations, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared, tasksPrepared /* TODO: parameters: parametersPrepared*/;
|
|
3364
3386
|
var _this = this;
|
|
3365
3387
|
return __generator(this, function (_c) {
|
|
3366
3388
|
switch (_c.label) {
|
|
@@ -3369,7 +3391,7 @@ function preparePipeline(pipeline, tools, options) {
|
|
|
3369
3391
|
return [2 /*return*/, pipeline];
|
|
3370
3392
|
}
|
|
3371
3393
|
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;
|
|
3372
|
-
parameters = pipeline.parameters,
|
|
3394
|
+
parameters = pipeline.parameters, tasks = pipeline.tasks, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
|
|
3373
3395
|
if (tools === undefined || tools.llm === undefined) {
|
|
3374
3396
|
throw new MissingToolsError('LLM tools are required for preparing the pipeline');
|
|
3375
3397
|
}
|
|
@@ -3412,9 +3434,9 @@ function preparePipeline(pipeline, tools, options) {
|
|
|
3412
3434
|
case 2:
|
|
3413
3435
|
partialknowledgePiecesPrepared = _c.sent();
|
|
3414
3436
|
knowledgePiecesPrepared = partialknowledgePiecesPrepared.map(function (piece) { return (__assign(__assign({}, piece), { preparationIds: [/* TODO: [🧊] -> */ currentPreparation.id] })); });
|
|
3415
|
-
return [4 /*yield*/,
|
|
3437
|
+
return [4 /*yield*/, prepareTasks({
|
|
3416
3438
|
parameters: parameters,
|
|
3417
|
-
|
|
3439
|
+
tasks: tasks,
|
|
3418
3440
|
knowledgePiecesCount: knowledgePiecesPrepared.length,
|
|
3419
3441
|
}, __assign(__assign({}, tools), { llm: llmToolsWithUsage }), {
|
|
3420
3442
|
rootDirname: rootDirname,
|
|
@@ -3422,12 +3444,12 @@ function preparePipeline(pipeline, tools, options) {
|
|
|
3422
3444
|
isVerbose: isVerbose,
|
|
3423
3445
|
})];
|
|
3424
3446
|
case 3:
|
|
3425
|
-
|
|
3447
|
+
tasksPrepared = (_c.sent()).tasksPrepared;
|
|
3426
3448
|
// ----- /Templates preparation -----
|
|
3427
3449
|
// Note: Count total usage
|
|
3428
3450
|
currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
|
|
3429
|
-
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), {
|
|
3430
|
-
// <- TODO: [🪓] Here should be no need for spreading new array, just `
|
|
3451
|
+
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { tasks: __spreadArray([], __read(tasksPrepared), false),
|
|
3452
|
+
// <- TODO: [🪓] Here should be no need for spreading new array, just ` tasks: tasksPrepared`
|
|
3431
3453
|
knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }))];
|
|
3432
3454
|
}
|
|
3433
3455
|
});
|
|
@@ -3499,9 +3521,9 @@ function extractVariables(script) {
|
|
|
3499
3521
|
* @throws {ParseError} if the script is invalid
|
|
3500
3522
|
* @public exported from `@promptbook/utils`
|
|
3501
3523
|
*/
|
|
3502
|
-
function
|
|
3524
|
+
function extractParameterNamesFromTask(template) {
|
|
3503
3525
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
3504
|
-
var title = template.title, description = template.description,
|
|
3526
|
+
var title = template.title, description = template.description, taskType = template.taskType, content = template.content, preparedContent = template.preparedContent, jokerParameterNames = template.jokerParameterNames, foreach = template.foreach;
|
|
3505
3527
|
var parameterNames = new Set();
|
|
3506
3528
|
try {
|
|
3507
3529
|
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()) {
|
|
@@ -3516,7 +3538,7 @@ function extractParameterNamesFromTemplate(template) {
|
|
|
3516
3538
|
}
|
|
3517
3539
|
finally { if (e_1) throw e_1.error; }
|
|
3518
3540
|
}
|
|
3519
|
-
if (
|
|
3541
|
+
if (taskType === 'SCRIPT_TASK') {
|
|
3520
3542
|
try {
|
|
3521
3543
|
for (var _g = __values(extractVariables(content)), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
3522
3544
|
var parameterName = _h.value;
|
|
@@ -3947,6 +3969,9 @@ var FORMAT_DEFINITIONS = [
|
|
|
3947
3969
|
TextFormatDefinition,
|
|
3948
3970
|
CsvFormatDefinition,
|
|
3949
3971
|
];
|
|
3972
|
+
/**
|
|
3973
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
3974
|
+
*/
|
|
3950
3975
|
|
|
3951
3976
|
/**
|
|
3952
3977
|
* Maps available parameters to expected parameters
|
|
@@ -4148,11 +4173,11 @@ function replaceParameters(template, parameters) {
|
|
|
4148
4173
|
for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
4149
4174
|
var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
|
|
4150
4175
|
if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
|
|
4151
|
-
throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
|
|
4176
|
+
throw new UnexpectedError("Parameter `{".concat(parameterName, "}` has missing value"));
|
|
4152
4177
|
}
|
|
4153
4178
|
else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
|
|
4154
4179
|
// TODO: [🍵]
|
|
4155
|
-
throw new UnexpectedError("Parameter {".concat(parameterName, "} is restricted to use"));
|
|
4180
|
+
throw new UnexpectedError("Parameter `{".concat(parameterName, "}` is restricted to use"));
|
|
4156
4181
|
}
|
|
4157
4182
|
}
|
|
4158
4183
|
}
|
|
@@ -4163,7 +4188,7 @@ function replaceParameters(template, parameters) {
|
|
|
4163
4188
|
}
|
|
4164
4189
|
finally { if (e_1) throw e_1.error; }
|
|
4165
4190
|
}
|
|
4166
|
-
var
|
|
4191
|
+
var replacedTemplates = template;
|
|
4167
4192
|
var match;
|
|
4168
4193
|
var loopLimit = LOOP_LIMIT;
|
|
4169
4194
|
var _loop_1 = function () {
|
|
@@ -4179,11 +4204,11 @@ function replaceParameters(template, parameters) {
|
|
|
4179
4204
|
throw new PipelineExecutionError('Parameter is already opened or not closed');
|
|
4180
4205
|
}
|
|
4181
4206
|
if (parameters[parameterName] === undefined) {
|
|
4182
|
-
throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
|
|
4207
|
+
throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
|
|
4183
4208
|
}
|
|
4184
4209
|
var parameterValue = parameters[parameterName];
|
|
4185
4210
|
if (parameterValue === undefined) {
|
|
4186
|
-
throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
|
|
4211
|
+
throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
|
|
4187
4212
|
}
|
|
4188
4213
|
parameterValue = parameterValue.toString();
|
|
4189
4214
|
if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
|
|
@@ -4192,24 +4217,24 @@ function replaceParameters(template, parameters) {
|
|
|
4192
4217
|
.map(function (line, index) { return (index === 0 ? line : "".concat(precol).concat(line)); })
|
|
4193
4218
|
.join('\n');
|
|
4194
4219
|
}
|
|
4195
|
-
|
|
4196
|
-
|
|
4220
|
+
replacedTemplates =
|
|
4221
|
+
replacedTemplates.substring(0, match.index + precol.length) +
|
|
4197
4222
|
parameterValue +
|
|
4198
|
-
|
|
4223
|
+
replacedTemplates.substring(match.index + precol.length + parameterName.length + 2);
|
|
4199
4224
|
};
|
|
4200
4225
|
while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
|
|
4201
|
-
.exec(
|
|
4226
|
+
.exec(replacedTemplates))) {
|
|
4202
4227
|
_loop_1();
|
|
4203
4228
|
}
|
|
4204
4229
|
// [💫] Check if there are parameters that are not closed properly
|
|
4205
|
-
if (/{\w+$/.test(
|
|
4230
|
+
if (/{\w+$/.test(replacedTemplates)) {
|
|
4206
4231
|
throw new PipelineExecutionError('Parameter is not closed');
|
|
4207
4232
|
}
|
|
4208
4233
|
// [💫] Check if there are parameters that are not opened properly
|
|
4209
|
-
if (/^\w+}/.test(
|
|
4234
|
+
if (/^\w+}/.test(replacedTemplates)) {
|
|
4210
4235
|
throw new PipelineExecutionError('Parameter is not opened');
|
|
4211
4236
|
}
|
|
4212
|
-
return
|
|
4237
|
+
return replacedTemplates;
|
|
4213
4238
|
}
|
|
4214
4239
|
|
|
4215
4240
|
/**
|
|
@@ -4239,6 +4264,10 @@ var CHARACTERS_PER_STANDARD_LINE = 63;
|
|
|
4239
4264
|
* @public exported from `@promptbook/utils`
|
|
4240
4265
|
*/
|
|
4241
4266
|
var LINES_PER_STANDARD_PAGE = 44;
|
|
4267
|
+
/**
|
|
4268
|
+
* TODO: [🧠] Should be this `constants.ts` or `config.ts`?
|
|
4269
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
4270
|
+
*/
|
|
4242
4271
|
|
|
4243
4272
|
/**
|
|
4244
4273
|
* Counts number of lines in the text
|
|
@@ -4317,6 +4346,7 @@ var CountUtils = {
|
|
|
4317
4346
|
};
|
|
4318
4347
|
/**
|
|
4319
4348
|
* TODO: [🧠][🤠] This should be probbably as part of `TextFormatDefinition`
|
|
4349
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
4320
4350
|
*/
|
|
4321
4351
|
|
|
4322
4352
|
/**
|
|
@@ -4365,12 +4395,12 @@ function checkExpectations(expectations, value) {
|
|
|
4365
4395
|
*/
|
|
4366
4396
|
function executeAttempts(options) {
|
|
4367
4397
|
return __awaiter(this, void 0, void 0, function () {
|
|
4368
|
-
var jokerParameterNames, priority, maxAttempts, preparedContent, parameters,
|
|
4398
|
+
var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTaskResult, _llms, llmTools, _loop_1, attempt, state_1;
|
|
4369
4399
|
return __generator(this, function (_a) {
|
|
4370
4400
|
switch (_a.label) {
|
|
4371
4401
|
case 0:
|
|
4372
|
-
jokerParameterNames = options.jokerParameterNames, priority = options.priority, maxAttempts = options.maxAttempts, preparedContent = options.preparedContent, parameters = options.parameters,
|
|
4373
|
-
$
|
|
4402
|
+
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;
|
|
4403
|
+
$ongoingTaskResult = {
|
|
4374
4404
|
$result: null,
|
|
4375
4405
|
$resultString: null,
|
|
4376
4406
|
$expectError: null,
|
|
@@ -4390,52 +4420,51 @@ function executeAttempts(options) {
|
|
|
4390
4420
|
if (isJokerAttempt && !jokerParameterName) {
|
|
4391
4421
|
throw new UnexpectedError(spaceTrim(function (block) { return "\n Joker not found in attempt ".concat(attempt, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
4392
4422
|
}
|
|
4393
|
-
$
|
|
4394
|
-
$
|
|
4395
|
-
$
|
|
4423
|
+
$ongoingTaskResult.$result = null;
|
|
4424
|
+
$ongoingTaskResult.$resultString = null;
|
|
4425
|
+
$ongoingTaskResult.$expectError = null;
|
|
4396
4426
|
if (isJokerAttempt) {
|
|
4397
4427
|
if (parameters[jokerParameterName] === undefined) {
|
|
4398
4428
|
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Joker parameter {".concat(jokerParameterName, "} not defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
4399
4429
|
// <- TODO: This is maybe `PipelineLogicError` which should be detected in `validatePipeline` and here just thrown as `UnexpectedError`
|
|
4400
4430
|
}
|
|
4401
4431
|
else {
|
|
4402
|
-
$
|
|
4432
|
+
$ongoingTaskResult.$resultString = parameters[jokerParameterName];
|
|
4403
4433
|
}
|
|
4404
4434
|
}
|
|
4405
4435
|
_t.label = 1;
|
|
4406
4436
|
case 1:
|
|
4407
4437
|
_t.trys.push([1, 43, 44, 45]);
|
|
4408
4438
|
if (!!isJokerAttempt) return [3 /*break*/, 25];
|
|
4409
|
-
_b =
|
|
4439
|
+
_b = task.taskType;
|
|
4410
4440
|
switch (_b) {
|
|
4411
|
-
case '
|
|
4412
|
-
case '
|
|
4413
|
-
case '
|
|
4414
|
-
case '
|
|
4441
|
+
case 'SIMPLE_TASK': return [3 /*break*/, 2];
|
|
4442
|
+
case 'PROMPT_TASK': return [3 /*break*/, 3];
|
|
4443
|
+
case 'SCRIPT_TASK': return [3 /*break*/, 11];
|
|
4444
|
+
case 'DIALOG_TASK': return [3 /*break*/, 22];
|
|
4415
4445
|
}
|
|
4416
4446
|
return [3 /*break*/, 24];
|
|
4417
4447
|
case 2:
|
|
4418
|
-
$
|
|
4448
|
+
$ongoingTaskResult.$resultString = replaceParameters(preparedContent, parameters);
|
|
4419
4449
|
return [3 /*break*/, 25];
|
|
4420
4450
|
case 3:
|
|
4421
|
-
modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (
|
|
4422
|
-
$
|
|
4423
|
-
title:
|
|
4451
|
+
modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (task.modelRequirements || {}));
|
|
4452
|
+
$ongoingTaskResult.$prompt = {
|
|
4453
|
+
title: task.title,
|
|
4424
4454
|
pipelineUrl: "".concat(preparedPipeline.pipelineUrl
|
|
4425
4455
|
? preparedPipeline.pipelineUrl
|
|
4426
|
-
: 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(
|
|
4427
|
-
// <- TODO: Here should be maybe also subformat index to distinguish between same
|
|
4456
|
+
: 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(task.name
|
|
4457
|
+
// <- TODO: Here should be maybe also subformat index to distinguish between same task with different subformat values
|
|
4428
4458
|
),
|
|
4429
4459
|
parameters: parameters,
|
|
4430
4460
|
content: preparedContent,
|
|
4431
4461
|
modelRequirements: modelRequirements,
|
|
4432
4462
|
expectations: __assign(__assign({}, (preparedPipeline.personas.find(function (_a) {
|
|
4433
4463
|
var name = _a.name;
|
|
4434
|
-
return name ===
|
|
4435
|
-
}) ||
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
postprocessingFunctionNames: template.postprocessingFunctionNames,
|
|
4464
|
+
return name === task.personaName;
|
|
4465
|
+
}) || {})), task.expectations),
|
|
4466
|
+
format: task.format,
|
|
4467
|
+
postprocessingFunctionNames: task.postprocessingFunctionNames,
|
|
4439
4468
|
}; // <- TODO: Not very good type guard
|
|
4440
4469
|
_c = modelRequirements.modelVariant;
|
|
4441
4470
|
switch (_c) {
|
|
@@ -4445,36 +4474,35 @@ function executeAttempts(options) {
|
|
|
4445
4474
|
}
|
|
4446
4475
|
return [3 /*break*/, 9];
|
|
4447
4476
|
case 4:
|
|
4448
|
-
_d = $
|
|
4477
|
+
_d = $ongoingTaskResult;
|
|
4449
4478
|
return [4 /*yield*/, llmTools.callChatModel(
|
|
4450
4479
|
// <- TODO: [🧁] Check that `callChatModel` is defined
|
|
4451
|
-
$deepFreeze($
|
|
4480
|
+
$deepFreeze($ongoingTaskResult.$prompt))];
|
|
4452
4481
|
case 5:
|
|
4453
4482
|
_d.$chatResult = _t.sent();
|
|
4454
4483
|
// TODO: [🍬] Destroy chatThread
|
|
4455
|
-
$
|
|
4456
|
-
$
|
|
4484
|
+
$ongoingTaskResult.$result = $ongoingTaskResult.$chatResult;
|
|
4485
|
+
$ongoingTaskResult.$resultString = $ongoingTaskResult.$chatResult.content;
|
|
4457
4486
|
return [3 /*break*/, 10];
|
|
4458
4487
|
case 6:
|
|
4459
|
-
_e = $
|
|
4488
|
+
_e = $ongoingTaskResult;
|
|
4460
4489
|
return [4 /*yield*/, llmTools.callCompletionModel(
|
|
4461
4490
|
// <- TODO: [🧁] Check that `callCompletionModel` is defined
|
|
4462
|
-
$deepFreeze($
|
|
4491
|
+
$deepFreeze($ongoingTaskResult.$prompt))];
|
|
4463
4492
|
case 7:
|
|
4464
4493
|
_e.$completionResult = _t.sent();
|
|
4465
|
-
$
|
|
4466
|
-
$
|
|
4467
|
-
$ongoingTemplateResult.$completionResult.content;
|
|
4494
|
+
$ongoingTaskResult.$result = $ongoingTaskResult.$completionResult;
|
|
4495
|
+
$ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
|
|
4468
4496
|
return [3 /*break*/, 10];
|
|
4469
4497
|
case 8: throw new PipelineExecutionError(spaceTrim(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 "); }));
|
|
4470
|
-
case 9: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown model variant \"".concat(
|
|
4498
|
+
case 9: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown model variant \"".concat(task.modelRequirements.modelVariant, "\"\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
|
|
4471
4499
|
case 10: return [3 /*break*/, 25];
|
|
4472
4500
|
case 11:
|
|
4473
4501
|
if (arrayableToArray(tools.script).length === 0) {
|
|
4474
4502
|
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n No script execution tools are available\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
4475
4503
|
}
|
|
4476
|
-
if (!
|
|
4477
|
-
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Script language is not defined for SCRIPT
|
|
4504
|
+
if (!task.contentLanguage) {
|
|
4505
|
+
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Script language is not defined for SCRIPT TASK \"".concat(task.name, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
4478
4506
|
}
|
|
4479
4507
|
_t.label = 12;
|
|
4480
4508
|
case 12:
|
|
@@ -4487,9 +4515,9 @@ function executeAttempts(options) {
|
|
|
4487
4515
|
_t.label = 14;
|
|
4488
4516
|
case 14:
|
|
4489
4517
|
_t.trys.push([14, 16, , 17]);
|
|
4490
|
-
_h = $
|
|
4518
|
+
_h = $ongoingTaskResult;
|
|
4491
4519
|
return [4 /*yield*/, scriptTools.execute($deepFreeze({
|
|
4492
|
-
scriptLanguage:
|
|
4520
|
+
scriptLanguage: task.contentLanguage,
|
|
4493
4521
|
script: preparedContent,
|
|
4494
4522
|
parameters: parameters,
|
|
4495
4523
|
}))];
|
|
@@ -4504,7 +4532,7 @@ function executeAttempts(options) {
|
|
|
4504
4532
|
if (error_1 instanceof UnexpectedError) {
|
|
4505
4533
|
throw error_1;
|
|
4506
4534
|
}
|
|
4507
|
-
$
|
|
4535
|
+
$ongoingTaskResult.$scriptPipelineExecutionErrors.push(error_1);
|
|
4508
4536
|
return [3 /*break*/, 17];
|
|
4509
4537
|
case 17:
|
|
4510
4538
|
_g = _f.next();
|
|
@@ -4521,14 +4549,14 @@ function executeAttempts(options) {
|
|
|
4521
4549
|
finally { if (e_1) throw e_1.error; }
|
|
4522
4550
|
return [7 /*endfinally*/];
|
|
4523
4551
|
case 21:
|
|
4524
|
-
if ($
|
|
4552
|
+
if ($ongoingTaskResult.$resultString !== null) {
|
|
4525
4553
|
return [3 /*break*/, 25];
|
|
4526
4554
|
}
|
|
4527
|
-
if ($
|
|
4528
|
-
throw $
|
|
4555
|
+
if ($ongoingTaskResult.$scriptPipelineExecutionErrors.length === 1) {
|
|
4556
|
+
throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
|
|
4529
4557
|
}
|
|
4530
4558
|
else {
|
|
4531
|
-
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Script execution failed ".concat($
|
|
4559
|
+
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Script execution failed ".concat($ongoingTaskResult.$scriptPipelineExecutionErrors.length, "x\n\n ").concat(block(pipelineIdentification), "\n\n ").concat(block($ongoingTaskResult.$scriptPipelineExecutionErrors
|
|
4532
4560
|
.map(function (error) { return '- ' + error.message; })
|
|
4533
4561
|
.join('\n\n')), "\n "); }));
|
|
4534
4562
|
}
|
|
@@ -4536,27 +4564,27 @@ function executeAttempts(options) {
|
|
|
4536
4564
|
if (tools.userInterface === undefined) {
|
|
4537
4565
|
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n User interface tools are not available\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
4538
4566
|
}
|
|
4539
|
-
// TODO: [🌹] When making next attempt for `DIALOG
|
|
4540
|
-
_j = $
|
|
4567
|
+
// TODO: [🌹] When making next attempt for `DIALOG TASK`, preserve the previous user input
|
|
4568
|
+
_j = $ongoingTaskResult;
|
|
4541
4569
|
return [4 /*yield*/, tools.userInterface.promptDialog($deepFreeze({
|
|
4542
|
-
promptTitle:
|
|
4543
|
-
promptMessage: replaceParameters(
|
|
4570
|
+
promptTitle: task.title,
|
|
4571
|
+
promptMessage: replaceParameters(task.description || '', parameters),
|
|
4544
4572
|
defaultValue: replaceParameters(preparedContent, parameters),
|
|
4545
4573
|
// TODO: [🧠] !! Figure out how to define placeholder in .book.md file
|
|
4546
4574
|
placeholder: undefined,
|
|
4547
4575
|
priority: priority,
|
|
4548
4576
|
}))];
|
|
4549
4577
|
case 23:
|
|
4550
|
-
// TODO: [🌹] When making next attempt for `DIALOG
|
|
4578
|
+
// TODO: [🌹] When making next attempt for `DIALOG TASK`, preserve the previous user input
|
|
4551
4579
|
_j.$resultString = _t.sent();
|
|
4552
4580
|
return [3 /*break*/, 25];
|
|
4553
|
-
case 24: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown execution type \"".concat(
|
|
4581
|
+
case 24: throw new PipelineExecutionError(spaceTrim(function (block) { return "\n Unknown execution type \"".concat(task.taskType, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
4554
4582
|
case 25:
|
|
4555
|
-
if (!(!isJokerAttempt &&
|
|
4583
|
+
if (!(!isJokerAttempt && task.postprocessingFunctionNames)) return [3 /*break*/, 42];
|
|
4556
4584
|
_t.label = 26;
|
|
4557
4585
|
case 26:
|
|
4558
4586
|
_t.trys.push([26, 40, 41, 42]);
|
|
4559
|
-
_k = (e_3 = void 0, __values(
|
|
4587
|
+
_k = (e_3 = void 0, __values(task.postprocessingFunctionNames)), _l = _k.next();
|
|
4560
4588
|
_t.label = 27;
|
|
4561
4589
|
case 27:
|
|
4562
4590
|
if (!!_l.done) return [3 /*break*/, 39];
|
|
@@ -4573,13 +4601,13 @@ function executeAttempts(options) {
|
|
|
4573
4601
|
_t.label = 30;
|
|
4574
4602
|
case 30:
|
|
4575
4603
|
_t.trys.push([30, 32, , 33]);
|
|
4576
|
-
_p = $
|
|
4604
|
+
_p = $ongoingTaskResult;
|
|
4577
4605
|
return [4 /*yield*/, scriptTools.execute({
|
|
4578
4606
|
scriptLanguage: "javascript" /* <- TODO: Try it in each languages; In future allow postprocessing with arbitrary combination of languages to combine */,
|
|
4579
4607
|
script: "".concat(functionName, "(resultString)"),
|
|
4580
4608
|
parameters: {
|
|
4581
|
-
resultString: $
|
|
4582
|
-
// Note: No ...
|
|
4609
|
+
resultString: $ongoingTaskResult.$resultString || '',
|
|
4610
|
+
// Note: No ...parametersForTask, because working with result only
|
|
4583
4611
|
},
|
|
4584
4612
|
})];
|
|
4585
4613
|
case 31:
|
|
@@ -4595,7 +4623,7 @@ function executeAttempts(options) {
|
|
|
4595
4623
|
throw error_2;
|
|
4596
4624
|
}
|
|
4597
4625
|
postprocessingError = error_2;
|
|
4598
|
-
$
|
|
4626
|
+
$ongoingTaskResult.$scriptPipelineExecutionErrors.push(error_2);
|
|
4599
4627
|
return [3 /*break*/, 33];
|
|
4600
4628
|
case 33:
|
|
4601
4629
|
_o = _m.next();
|
|
@@ -4632,12 +4660,12 @@ function executeAttempts(options) {
|
|
|
4632
4660
|
return [7 /*endfinally*/];
|
|
4633
4661
|
case 42:
|
|
4634
4662
|
// TODO: [💝] Unite object for expecting amount and format
|
|
4635
|
-
if (
|
|
4636
|
-
if (
|
|
4637
|
-
if (!isValidJsonString($
|
|
4663
|
+
if (task.format) {
|
|
4664
|
+
if (task.format === 'JSON') {
|
|
4665
|
+
if (!isValidJsonString($ongoingTaskResult.$resultString || '')) {
|
|
4638
4666
|
// TODO: [🏢] Do more universally via `FormatDefinition`
|
|
4639
4667
|
try {
|
|
4640
|
-
$
|
|
4668
|
+
$ongoingTaskResult.$resultString = extractJsonBlock($ongoingTaskResult.$resultString || '');
|
|
4641
4669
|
}
|
|
4642
4670
|
catch (error) {
|
|
4643
4671
|
throw new ExpectError(spaceTrim(function (block) { return "\n Expected valid JSON string\n\n ".concat(block(
|
|
@@ -4646,12 +4674,12 @@ function executeAttempts(options) {
|
|
|
4646
4674
|
}
|
|
4647
4675
|
}
|
|
4648
4676
|
else {
|
|
4649
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n Unknown format \"".concat(
|
|
4677
|
+
throw new UnexpectedError(spaceTrim(function (block) { return "\n Unknown format \"".concat(task.format, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
4650
4678
|
}
|
|
4651
4679
|
}
|
|
4652
4680
|
// TODO: [💝] Unite object for expecting amount and format
|
|
4653
|
-
if (
|
|
4654
|
-
checkExpectations(
|
|
4681
|
+
if (task.expectations) {
|
|
4682
|
+
checkExpectations(task.expectations, $ongoingTaskResult.$resultString || '');
|
|
4655
4683
|
}
|
|
4656
4684
|
return [2 /*return*/, "break-attempts"];
|
|
4657
4685
|
case 43:
|
|
@@ -4659,38 +4687,38 @@ function executeAttempts(options) {
|
|
|
4659
4687
|
if (!(error_3 instanceof ExpectError)) {
|
|
4660
4688
|
throw error_3;
|
|
4661
4689
|
}
|
|
4662
|
-
$
|
|
4690
|
+
$ongoingTaskResult.$expectError = error_3;
|
|
4663
4691
|
return [3 /*break*/, 45];
|
|
4664
4692
|
case 44:
|
|
4665
4693
|
if (!isJokerAttempt &&
|
|
4666
|
-
|
|
4667
|
-
$
|
|
4694
|
+
task.taskType === 'PROMPT_TASK' &&
|
|
4695
|
+
$ongoingTaskResult.$prompt
|
|
4668
4696
|
// <- Note: [2] When some expected parameter is not defined, error will occur in replaceParameters
|
|
4669
4697
|
// In that case we don’t want to make a report about it because it’s not a llm execution error
|
|
4670
4698
|
) {
|
|
4671
|
-
// TODO: [🧠] Maybe put other
|
|
4699
|
+
// TODO: [🧠] Maybe put other taskTypes into report
|
|
4672
4700
|
$executionReport.promptExecutions.push({
|
|
4673
|
-
prompt: __assign({}, $
|
|
4674
|
-
result: $
|
|
4675
|
-
error: $
|
|
4701
|
+
prompt: __assign({}, $ongoingTaskResult.$prompt),
|
|
4702
|
+
result: $ongoingTaskResult.$result || undefined,
|
|
4703
|
+
error: $ongoingTaskResult.$expectError === null
|
|
4676
4704
|
? undefined
|
|
4677
|
-
: serializeError($
|
|
4705
|
+
: serializeError($ongoingTaskResult.$expectError),
|
|
4678
4706
|
});
|
|
4679
4707
|
}
|
|
4680
4708
|
return [7 /*endfinally*/];
|
|
4681
4709
|
case 45:
|
|
4682
|
-
if ($
|
|
4710
|
+
if ($ongoingTaskResult.$expectError !== null && attempt === maxAttempts - 1) {
|
|
4683
4711
|
throw new PipelineExecutionError(spaceTrim(function (block) {
|
|
4684
4712
|
var _a, _b, _c;
|
|
4685
|
-
return "\n LLM execution failed ".concat(maxExecutionAttempts, "x\n\n ").concat(block(pipelineIdentification), "\n\n ---\n The Prompt:\n ").concat(block((((_a = $
|
|
4713
|
+
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) || '')
|
|
4686
4714
|
.split('\n')
|
|
4687
4715
|
.map(function (line) { return "> ".concat(line); })
|
|
4688
|
-
.join('\n')), "\n\n Last error ").concat(((_b = $
|
|
4716
|
+
.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) || '')
|
|
4689
4717
|
.split('\n')
|
|
4690
4718
|
.map(function (line) { return "> ".concat(line); })
|
|
4691
|
-
.join('\n')), "\n\n Last result:\n ").concat(block($
|
|
4719
|
+
.join('\n')), "\n\n Last result:\n ").concat(block($ongoingTaskResult.$resultString === null
|
|
4692
4720
|
? 'null'
|
|
4693
|
-
: $
|
|
4721
|
+
: $ongoingTaskResult.$resultString
|
|
4694
4722
|
.split('\n')
|
|
4695
4723
|
.map(function (line) { return "> ".concat(line); })
|
|
4696
4724
|
.join('\n')), "\n ---\n ");
|
|
@@ -4715,10 +4743,10 @@ function executeAttempts(options) {
|
|
|
4715
4743
|
attempt++;
|
|
4716
4744
|
return [3 /*break*/, 1];
|
|
4717
4745
|
case 4:
|
|
4718
|
-
if ($
|
|
4746
|
+
if ($ongoingTaskResult.$resultString === null) {
|
|
4719
4747
|
throw new UnexpectedError(spaceTrim(function (block) { return "\n Something went wrong and prompt result is null\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
4720
4748
|
}
|
|
4721
|
-
return [2 /*return*/, $
|
|
4749
|
+
return [2 /*return*/, $ongoingTaskResult.$resultString];
|
|
4722
4750
|
}
|
|
4723
4751
|
});
|
|
4724
4752
|
});
|
|
@@ -4734,36 +4762,36 @@ function executeAttempts(options) {
|
|
|
4734
4762
|
*/
|
|
4735
4763
|
function executeFormatSubvalues(options) {
|
|
4736
4764
|
return __awaiter(this, void 0, void 0, function () {
|
|
4737
|
-
var
|
|
4765
|
+
var task, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
|
|
4738
4766
|
var _this = this;
|
|
4739
4767
|
return __generator(this, function (_a) {
|
|
4740
4768
|
switch (_a.label) {
|
|
4741
4769
|
case 0:
|
|
4742
|
-
|
|
4743
|
-
if (
|
|
4770
|
+
task = options.task, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, csvSettings = options.csvSettings, pipelineIdentification = options.pipelineIdentification;
|
|
4771
|
+
if (task.foreach === undefined) {
|
|
4744
4772
|
return [2 /*return*/, /* not await */ executeAttempts(options)];
|
|
4745
4773
|
}
|
|
4746
4774
|
if (jokerParameterNames.length !== 0) {
|
|
4747
4775
|
throw new UnexpectedError(spaceTrim$1(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 "); }));
|
|
4748
4776
|
}
|
|
4749
|
-
parameterValue = parameters[
|
|
4777
|
+
parameterValue = parameters[task.foreach.parameterName] || '';
|
|
4750
4778
|
formatDefinition = FORMAT_DEFINITIONS.find(function (formatDefinition) {
|
|
4751
|
-
return __spreadArray([formatDefinition.formatName], __read((formatDefinition.aliases || [])), false).includes(
|
|
4779
|
+
return __spreadArray([formatDefinition.formatName], __read((formatDefinition.aliases || [])), false).includes(task.foreach.formatName);
|
|
4752
4780
|
});
|
|
4753
4781
|
if (formatDefinition === undefined) {
|
|
4754
4782
|
throw new UnexpectedError(
|
|
4755
4783
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
4756
|
-
spaceTrim$1(function (block) { return "\n Unsupported format \"".concat(
|
|
4784
|
+
spaceTrim$1(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; })
|
|
4757
4785
|
.map(function (formatName) { return "- ".concat(formatName); })
|
|
4758
4786
|
.join('\n')), "\n\n [\u26F7] This should never happen because format name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
4759
4787
|
}
|
|
4760
4788
|
subvalueDefinition = formatDefinition.subvalueDefinitions.find(function (subvalueDefinition) {
|
|
4761
|
-
return __spreadArray([subvalueDefinition.subvalueName], __read((subvalueDefinition.aliases || [])), false).includes(
|
|
4789
|
+
return __spreadArray([subvalueDefinition.subvalueName], __read((subvalueDefinition.aliases || [])), false).includes(task.foreach.subformatName);
|
|
4762
4790
|
});
|
|
4763
4791
|
if (subvalueDefinition === undefined) {
|
|
4764
4792
|
throw new UnexpectedError(
|
|
4765
4793
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
4766
|
-
spaceTrim$1(function (block) { return "\n Unsupported subformat name \"".concat(
|
|
4794
|
+
spaceTrim$1(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
|
|
4767
4795
|
.map(function (subvalueDefinition) { return subvalueDefinition.subvalueName; })
|
|
4768
4796
|
.map(function (subvalueName) { return "- ".concat(subvalueName); })
|
|
4769
4797
|
.join('\n')), "\n\n [\u26F7] This should never happen because subformat name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
@@ -4772,7 +4800,7 @@ function executeFormatSubvalues(options) {
|
|
|
4772
4800
|
formatSettings = csvSettings;
|
|
4773
4801
|
// <- TODO: [🤹♂️] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
|
|
4774
4802
|
}
|
|
4775
|
-
return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue,
|
|
4803
|
+
return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, task.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
4776
4804
|
var mappedParameters, allSubparameters, subresultString;
|
|
4777
4805
|
return __generator(this, function (_a) {
|
|
4778
4806
|
switch (_a.label) {
|
|
@@ -4781,7 +4809,7 @@ function executeFormatSubvalues(options) {
|
|
|
4781
4809
|
// TODO: When done [🐚] Report progress also for each subvalue here
|
|
4782
4810
|
try {
|
|
4783
4811
|
mappedParameters = mapAvailableToExpectedParameters({
|
|
4784
|
-
expectedParameters: Object.fromEntries(
|
|
4812
|
+
expectedParameters: Object.fromEntries(task.foreach.inputSubparameterNames.map(function (subparameterName) { return [subparameterName, null]; })),
|
|
4785
4813
|
availableParameters: subparameters,
|
|
4786
4814
|
});
|
|
4787
4815
|
}
|
|
@@ -4814,7 +4842,7 @@ function executeFormatSubvalues(options) {
|
|
|
4814
4842
|
*
|
|
4815
4843
|
* @private internal utility of `createPipelineExecutor`
|
|
4816
4844
|
*/
|
|
4817
|
-
function
|
|
4845
|
+
function getContextForTask(task) {
|
|
4818
4846
|
return __awaiter(this, void 0, void 0, function () {
|
|
4819
4847
|
return __generator(this, function (_a) {
|
|
4820
4848
|
return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [🏍] Implement */];
|
|
@@ -4827,15 +4855,10 @@ function getContextForTemplate(template) {
|
|
|
4827
4855
|
*
|
|
4828
4856
|
* @private internal utility of `createPipelineExecutor`
|
|
4829
4857
|
*/
|
|
4830
|
-
function
|
|
4858
|
+
function getExamplesForTask(task) {
|
|
4831
4859
|
return __awaiter(this, void 0, void 0, function () {
|
|
4832
|
-
var preparedPipeline;
|
|
4833
4860
|
return __generator(this, function (_a) {
|
|
4834
|
-
|
|
4835
|
-
return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
|
|
4836
|
-
var content = _a.content;
|
|
4837
|
-
return "- ".concat(content);
|
|
4838
|
-
}).join('\n')];
|
|
4861
|
+
return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [♨] Implement */];
|
|
4839
4862
|
});
|
|
4840
4863
|
});
|
|
4841
4864
|
}
|
|
@@ -4845,10 +4868,15 @@ function getKnowledgeForTemplate(options) {
|
|
|
4845
4868
|
*
|
|
4846
4869
|
* @private internal utility of `createPipelineExecutor`
|
|
4847
4870
|
*/
|
|
4848
|
-
function
|
|
4871
|
+
function getKnowledgeForTask(options) {
|
|
4849
4872
|
return __awaiter(this, void 0, void 0, function () {
|
|
4873
|
+
var preparedPipeline;
|
|
4850
4874
|
return __generator(this, function (_a) {
|
|
4851
|
-
|
|
4875
|
+
preparedPipeline = options.preparedPipeline, options.task;
|
|
4876
|
+
return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
|
|
4877
|
+
var content = _a.content;
|
|
4878
|
+
return "- ".concat(content);
|
|
4879
|
+
}).join('\n')];
|
|
4852
4880
|
});
|
|
4853
4881
|
});
|
|
4854
4882
|
}
|
|
@@ -4858,21 +4886,21 @@ function getExamplesForTemplate(template) {
|
|
|
4858
4886
|
*
|
|
4859
4887
|
* @private internal utility of `createPipelineExecutor`
|
|
4860
4888
|
*/
|
|
4861
|
-
function
|
|
4889
|
+
function getReservedParametersForTask(options) {
|
|
4862
4890
|
return __awaiter(this, void 0, void 0, function () {
|
|
4863
|
-
var preparedPipeline,
|
|
4891
|
+
var preparedPipeline, task, pipelineIdentification, context, knowledge, examples, currentDate, modelName, reservedParameters, _loop_1, RESERVED_PARAMETER_NAMES_1, RESERVED_PARAMETER_NAMES_1_1, parameterName;
|
|
4864
4892
|
var e_1, _a;
|
|
4865
4893
|
return __generator(this, function (_b) {
|
|
4866
4894
|
switch (_b.label) {
|
|
4867
4895
|
case 0:
|
|
4868
|
-
preparedPipeline = options.preparedPipeline,
|
|
4869
|
-
return [4 /*yield*/,
|
|
4896
|
+
preparedPipeline = options.preparedPipeline, task = options.task, pipelineIdentification = options.pipelineIdentification;
|
|
4897
|
+
return [4 /*yield*/, getContextForTask()];
|
|
4870
4898
|
case 1:
|
|
4871
4899
|
context = _b.sent();
|
|
4872
|
-
return [4 /*yield*/,
|
|
4900
|
+
return [4 /*yield*/, getKnowledgeForTask({ preparedPipeline: preparedPipeline, task: task })];
|
|
4873
4901
|
case 2:
|
|
4874
4902
|
knowledge = _b.sent();
|
|
4875
|
-
return [4 /*yield*/,
|
|
4903
|
+
return [4 /*yield*/, getExamplesForTask()];
|
|
4876
4904
|
case 3:
|
|
4877
4905
|
examples = _b.sent();
|
|
4878
4906
|
currentDate = new Date().toISOString();
|
|
@@ -4915,31 +4943,31 @@ function getReservedParametersForTemplate(options) {
|
|
|
4915
4943
|
*
|
|
4916
4944
|
* @private internal utility of `createPipelineExecutor`
|
|
4917
4945
|
*/
|
|
4918
|
-
function
|
|
4946
|
+
function executeTask(options) {
|
|
4919
4947
|
return __awaiter(this, void 0, void 0, function () {
|
|
4920
|
-
var
|
|
4948
|
+
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;
|
|
4921
4949
|
var e_1, _g, _h;
|
|
4922
4950
|
return __generator(this, function (_j) {
|
|
4923
4951
|
switch (_j.label) {
|
|
4924
4952
|
case 0:
|
|
4925
|
-
|
|
4926
|
-
name = "pipeline-executor-frame-".concat(
|
|
4927
|
-
title =
|
|
4928
|
-
priority = preparedPipeline.
|
|
4953
|
+
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;
|
|
4954
|
+
name = "pipeline-executor-frame-".concat(currentTask.name);
|
|
4955
|
+
title = currentTask.title;
|
|
4956
|
+
priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
|
|
4929
4957
|
return [4 /*yield*/, onProgress({
|
|
4930
4958
|
name: name,
|
|
4931
4959
|
title: title,
|
|
4932
4960
|
isStarted: false,
|
|
4933
4961
|
isDone: false,
|
|
4934
|
-
|
|
4935
|
-
parameterName:
|
|
4962
|
+
taskType: currentTask.taskType,
|
|
4963
|
+
parameterName: currentTask.resultingParameterName,
|
|
4936
4964
|
parameterValue: null,
|
|
4937
4965
|
// <- [🍸]
|
|
4938
4966
|
})];
|
|
4939
4967
|
case 1:
|
|
4940
4968
|
_j.sent();
|
|
4941
|
-
usedParameterNames =
|
|
4942
|
-
dependentParameterNames = new Set(
|
|
4969
|
+
usedParameterNames = extractParameterNamesFromTask(currentTask);
|
|
4970
|
+
dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
4943
4971
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
4944
4972
|
if (union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)).size !== 0) {
|
|
4945
4973
|
throw new UnexpectedError(spaceTrim(function (block) { return "\n Dependent parameters are not consistent with used parameters:\n\n Dependent parameters:\n ".concat(Array.from(dependentParameterNames)
|
|
@@ -4950,9 +4978,9 @@ function executeTemplate(options) {
|
|
|
4950
4978
|
}
|
|
4951
4979
|
_c = (_b = Object).freeze;
|
|
4952
4980
|
_d = [{}];
|
|
4953
|
-
return [4 /*yield*/,
|
|
4981
|
+
return [4 /*yield*/, getReservedParametersForTask({
|
|
4954
4982
|
preparedPipeline: preparedPipeline,
|
|
4955
|
-
|
|
4983
|
+
task: currentTask,
|
|
4956
4984
|
pipelineIdentification: pipelineIdentification,
|
|
4957
4985
|
})];
|
|
4958
4986
|
case 2:
|
|
@@ -4970,11 +4998,11 @@ function executeTemplate(options) {
|
|
|
4970
4998
|
else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
|
|
4971
4999
|
// Houston, we have a problem
|
|
4972
5000
|
// Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
|
|
4973
|
-
throw new UnexpectedError(spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is NOT defined\n BUT used in
|
|
5001
|
+
throw new UnexpectedError(spaceTrim(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 "); }));
|
|
4974
5002
|
}
|
|
4975
5003
|
};
|
|
4976
5004
|
try {
|
|
4977
|
-
// Note: [2] Check that all used parameters are defined and removing unused parameters for this
|
|
5005
|
+
// Note: [2] Check that all used parameters are defined and removing unused parameters for this task
|
|
4978
5006
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
4979
5007
|
for (_e = __values(Array.from(union(definedParameterNames, usedParameterNames, dependentParameterNames))), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
4980
5008
|
parameterName = _f.value;
|
|
@@ -4990,18 +5018,16 @@ function executeTemplate(options) {
|
|
|
4990
5018
|
}
|
|
4991
5019
|
// 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
|
|
4992
5020
|
Object.freeze(parameters);
|
|
4993
|
-
maxAttempts =
|
|
4994
|
-
jokerParameterNames =
|
|
4995
|
-
preparedContent = (
|
|
4996
|
-
.split('{content}')
|
|
4997
|
-
.join(currentTemplate.content);
|
|
5021
|
+
maxAttempts = currentTask.taskType === 'DIALOG_TASK' ? Infinity : maxExecutionAttempts;
|
|
5022
|
+
jokerParameterNames = currentTask.jokerParameterNames || [];
|
|
5023
|
+
preparedContent = (currentTask.preparedContent || '{content}').split('{content}').join(currentTask.content);
|
|
4998
5024
|
return [4 /*yield*/, executeFormatSubvalues({
|
|
4999
5025
|
jokerParameterNames: jokerParameterNames,
|
|
5000
5026
|
priority: priority,
|
|
5001
5027
|
maxAttempts: maxAttempts,
|
|
5002
5028
|
preparedContent: preparedContent,
|
|
5003
5029
|
parameters: parameters,
|
|
5004
|
-
|
|
5030
|
+
task: currentTask,
|
|
5005
5031
|
preparedPipeline: preparedPipeline,
|
|
5006
5032
|
tools: tools,
|
|
5007
5033
|
$executionReport: $executionReport,
|
|
@@ -5014,15 +5040,15 @@ function executeTemplate(options) {
|
|
|
5014
5040
|
title: title,
|
|
5015
5041
|
isStarted: true,
|
|
5016
5042
|
isDone: true,
|
|
5017
|
-
|
|
5018
|
-
parameterName:
|
|
5043
|
+
taskType: currentTask.taskType,
|
|
5044
|
+
parameterName: currentTask.resultingParameterName,
|
|
5019
5045
|
parameterValue: resultString,
|
|
5020
5046
|
// <- [🍸]
|
|
5021
5047
|
})];
|
|
5022
5048
|
case 4:
|
|
5023
5049
|
_j.sent();
|
|
5024
5050
|
return [2 /*return*/, Object.freeze((_h = {},
|
|
5025
|
-
_h[
|
|
5051
|
+
_h[currentTask.resultingParameterName] =
|
|
5026
5052
|
// <- Note: [👩👩👧] No need to detect parameter collision here because pipeline checks logic consistency during construction
|
|
5027
5053
|
resultString,
|
|
5028
5054
|
_h))];
|
|
@@ -5049,7 +5075,7 @@ function filterJustOutputParameters(options) {
|
|
|
5049
5075
|
var _loop_1 = function (parameter) {
|
|
5050
5076
|
if (parametersToPass[parameter.name] === undefined) {
|
|
5051
5077
|
// [4]
|
|
5052
|
-
$warnings.push(new PipelineExecutionError(spaceTrim(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 "); })));
|
|
5078
|
+
$warnings.push(new PipelineExecutionError(spaceTrim(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 "); })));
|
|
5053
5079
|
return "continue";
|
|
5054
5080
|
}
|
|
5055
5081
|
outputParameters[parameter.name] = parametersToPass[parameter.name] || '';
|
|
@@ -5084,7 +5110,7 @@ function filterJustOutputParameters(options) {
|
|
|
5084
5110
|
*/
|
|
5085
5111
|
function executePipeline(options) {
|
|
5086
5112
|
return __awaiter(this, void 0, void 0, function () {
|
|
5087
|
-
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,
|
|
5113
|
+
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;
|
|
5088
5114
|
var e_1, _f, e_2, _g;
|
|
5089
5115
|
return __generator(this, function (_h) {
|
|
5090
5116
|
switch (_h.label) {
|
|
@@ -5136,7 +5162,7 @@ function executePipeline(options) {
|
|
|
5136
5162
|
case 6: return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
|
|
5137
5163
|
isSuccessful: false,
|
|
5138
5164
|
errors: __spreadArray([
|
|
5139
|
-
new PipelineExecutionError("Parameter {".concat(parameter.name, "} is required as an input parameter"))
|
|
5165
|
+
new PipelineExecutionError("Parameter `{".concat(parameter.name, "}` is required as an input parameter"))
|
|
5140
5166
|
], __read(errors), false).map(serializeError),
|
|
5141
5167
|
warnings: [],
|
|
5142
5168
|
executionReport: executionReport,
|
|
@@ -5184,7 +5210,7 @@ function executePipeline(options) {
|
|
|
5184
5210
|
case 3: return [2 /*return*/, { value: $asDeeplyFrozenSerializableJson(spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
|
|
5185
5211
|
isSuccessful: false,
|
|
5186
5212
|
errors: __spreadArray([
|
|
5187
|
-
new PipelineExecutionError(spaceTrim(function (block) { return "\n Parameter {".concat(parameter.name, "} is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
|
|
5213
|
+
new PipelineExecutionError(spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
|
|
5188
5214
|
], __read(errors), false).map(serializeError),
|
|
5189
5215
|
warnings: warnings.map(serializeError),
|
|
5190
5216
|
executionReport: executionReport,
|
|
@@ -5238,11 +5264,11 @@ function executePipeline(options) {
|
|
|
5238
5264
|
var name = _a.name;
|
|
5239
5265
|
return name;
|
|
5240
5266
|
});
|
|
5241
|
-
|
|
5267
|
+
unresovedTasks_1 = __spreadArray([], __read(preparedPipeline.tasks), false);
|
|
5242
5268
|
resolving_1 = [];
|
|
5243
5269
|
loopLimit = LOOP_LIMIT;
|
|
5244
5270
|
_loop_2 = function () {
|
|
5245
|
-
var
|
|
5271
|
+
var currentTask, work_1;
|
|
5246
5272
|
return __generator(this, function (_k) {
|
|
5247
5273
|
switch (_k.label) {
|
|
5248
5274
|
case 0:
|
|
@@ -5250,31 +5276,41 @@ function executePipeline(options) {
|
|
|
5250
5276
|
// Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
|
|
5251
5277
|
throw new UnexpectedError(spaceTrim(function (block) { return "\n Loop limit reached during resolving parameters pipeline execution\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
5252
5278
|
}
|
|
5253
|
-
|
|
5254
|
-
return
|
|
5279
|
+
currentTask = unresovedTasks_1.find(function (task) {
|
|
5280
|
+
return task.dependentParameterNames.every(function (name) {
|
|
5255
5281
|
return __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), __read(RESERVED_PARAMETER_NAMES), false).includes(name);
|
|
5256
5282
|
});
|
|
5257
5283
|
});
|
|
5258
|
-
if (!(!
|
|
5284
|
+
if (!(!currentTask && resolving_1.length === 0)) return [3 /*break*/, 1];
|
|
5259
5285
|
throw new UnexpectedError(
|
|
5260
5286
|
// TODO: [🐎] DRY
|
|
5261
|
-
spaceTrim(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n Can not resolve
|
|
5287
|
+
spaceTrim(function (block) { return "\n Can not resolve some parameters:\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTasks_1
|
|
5262
5288
|
.map(function (_a) {
|
|
5263
5289
|
var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
|
|
5264
|
-
return "- Parameter {".concat(resultingParameterName, "} which depends on ").concat(dependentParameterNames
|
|
5265
|
-
.map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
|
|
5290
|
+
return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
|
|
5291
|
+
.map(function (dependentParameterName) { return "`{".concat(dependentParameterName, "}`"); })
|
|
5266
5292
|
.join(' and '));
|
|
5267
5293
|
})
|
|
5268
|
-
.join('\n')), "\n\n Resolved
|
|
5294
|
+
.join('\n')), "\n\n **Resolved:**\n ").concat(block(resovedParameterNames_1
|
|
5295
|
+
.filter(function (name) {
|
|
5296
|
+
return !RESERVED_PARAMETER_NAMES.includes(name);
|
|
5297
|
+
})
|
|
5298
|
+
.map(function (name) { return "- Parameter `{".concat(name, "}`"); })
|
|
5299
|
+
.join('\n')), "\n\n **Reserved (which are available):**\n ").concat(block(resovedParameterNames_1
|
|
5300
|
+
.filter(function (name) {
|
|
5301
|
+
return RESERVED_PARAMETER_NAMES.includes(name);
|
|
5302
|
+
})
|
|
5303
|
+
.map(function (name) { return "- Parameter `{".concat(name, "}`"); })
|
|
5304
|
+
.join('\n')), "\n\n *Note: This should be catched in `validatePipeline`*\n "); }));
|
|
5269
5305
|
case 1:
|
|
5270
|
-
if (!!
|
|
5306
|
+
if (!!currentTask) return [3 /*break*/, 3];
|
|
5271
5307
|
/* [🤹♂️] */ return [4 /*yield*/, Promise.race(resolving_1)];
|
|
5272
5308
|
case 2:
|
|
5273
5309
|
/* [🤹♂️] */ _k.sent();
|
|
5274
5310
|
return [3 /*break*/, 4];
|
|
5275
5311
|
case 3:
|
|
5276
|
-
|
|
5277
|
-
work_1 =
|
|
5312
|
+
unresovedTasks_1 = unresovedTasks_1.filter(function (task) { return task !== currentTask; });
|
|
5313
|
+
work_1 = executeTask(__assign(__assign({}, options), { currentTask: currentTask, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (progress) {
|
|
5278
5314
|
if (isReturned) {
|
|
5279
5315
|
throw new UnexpectedError(spaceTrim(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)
|
|
5280
5316
|
.split('\n')
|
|
@@ -5284,16 +5320,16 @@ function executePipeline(options) {
|
|
|
5284
5320
|
if (onProgress) {
|
|
5285
5321
|
onProgress(progress);
|
|
5286
5322
|
}
|
|
5287
|
-
}, $executionReport: executionReport, pipelineIdentification: spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n
|
|
5323
|
+
}, $executionReport: executionReport, pipelineIdentification: spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Task name: ").concat(currentTask.name, "\n Task title: ").concat(currentTask.title, "\n "); }) }))
|
|
5288
5324
|
.then(function (newParametersToPass) {
|
|
5289
5325
|
parametersToPass = __assign(__assign({}, newParametersToPass), parametersToPass);
|
|
5290
|
-
resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [
|
|
5326
|
+
resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [currentTask.resultingParameterName], false);
|
|
5291
5327
|
})
|
|
5292
5328
|
.then(function () {
|
|
5293
5329
|
resolving_1 = resolving_1.filter(function (w) { return w !== work_1; });
|
|
5294
5330
|
});
|
|
5295
5331
|
// <- Note: Errors are catched here [3]
|
|
5296
|
-
// TODO: BUT if in multiple
|
|
5332
|
+
// 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
|
|
5297
5333
|
resolving_1.push(work_1);
|
|
5298
5334
|
_k.label = 4;
|
|
5299
5335
|
case 4: return [2 /*return*/];
|
|
@@ -5302,7 +5338,7 @@ function executePipeline(options) {
|
|
|
5302
5338
|
};
|
|
5303
5339
|
_h.label = 21;
|
|
5304
5340
|
case 21:
|
|
5305
|
-
if (!(
|
|
5341
|
+
if (!(unresovedTasks_1.length > 0)) return [3 /*break*/, 23];
|
|
5306
5342
|
return [5 /*yield**/, _loop_2()];
|
|
5307
5343
|
case 22:
|
|
5308
5344
|
_h.sent();
|
|
@@ -5460,6 +5496,9 @@ var markdownScraperMetadata = $deepFreeze({
|
|
|
5460
5496
|
* @public exported from `@promptbook/cli`
|
|
5461
5497
|
*/
|
|
5462
5498
|
$scrapersMetadataRegister.register(markdownScraperMetadata);
|
|
5499
|
+
/**
|
|
5500
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
5501
|
+
*/
|
|
5463
5502
|
|
|
5464
5503
|
/**
|
|
5465
5504
|
* Scraper for markdown files
|
|
@@ -5654,6 +5693,9 @@ var pdfScraperMetadata = $deepFreeze({
|
|
|
5654
5693
|
* @public exported from `@promptbook/cli`
|
|
5655
5694
|
*/
|
|
5656
5695
|
$scrapersMetadataRegister.register(pdfScraperMetadata);
|
|
5696
|
+
/**
|
|
5697
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
5698
|
+
*/
|
|
5657
5699
|
|
|
5658
5700
|
/**
|
|
5659
5701
|
* Scraper for .pdf files
|
|
@@ -5737,6 +5779,7 @@ var createPdfScraper = Object.assign(function (tools, options) {
|
|
|
5737
5779
|
var _PdfScraperRegistration = $scrapersRegister.register(createPdfScraper);
|
|
5738
5780
|
/**
|
|
5739
5781
|
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
5782
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
5740
5783
|
*/
|
|
5741
5784
|
|
|
5742
5785
|
export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION, PdfScraper, _PdfScraperRegistration, createPdfScraper };
|