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