@promptbook/markdown-utils 0.72.0-13 → 0.72.0-15
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 -1
- package/esm/index.es.js +58 -72
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +22 -18
- package/esm/typings/src/_packages/node.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +10 -10
- package/esm/typings/src/_packages/utils.index.d.ts +2 -2
- package/esm/typings/src/collection/PipelineCollection.d.ts +1 -1
- package/esm/typings/src/collection/SimplePipelineCollection.d.ts +2 -2
- 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/_common/types/CommandParser.d.ts +5 -5
- package/esm/typings/src/config.d.ts +21 -14
- package/esm/typings/src/execution/EmbeddingVector.d.ts +1 -1
- package/esm/typings/src/execution/Executables.d.ts +18 -0
- package/esm/typings/src/execution/ExecutionTools.d.ts +9 -3
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/execution/PipelineExecutorResult.d.ts +2 -2
- package/esm/typings/src/execution/assertsExecutionSuccessful.d.ts +1 -0
- package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorOptions.d.ts +29 -6
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +2 -11
- package/esm/typings/src/execution/createPipelineExecutor/20-executeTemplate.d.ts +4 -13
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +9 -14
- package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +11 -3
- package/esm/typings/src/execution/utils/addUsage.d.ts +1 -1
- package/esm/typings/src/execution/utils/forEachAsync.d.ts +1 -1
- package/esm/typings/src/formats/_common/FormatDefinition.d.ts +2 -2
- package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +2 -2
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForCli.d.ts +2 -2
- package/esm/typings/src/llm-providers/_common/register/LlmToolsConfiguration.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/createLlmToolsFromConfiguration.d.ts +7 -0
- package/esm/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +4 -1
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/mocked/$fakeTextToExpectations.d.ts +1 -1
- package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +4 -5
- package/esm/typings/src/llm-providers/multiple/joinLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_ListModels_Response.d.ts +3 -3
- package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_Prompt_Response.d.ts +2 -2
- package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +4 -23
- package/esm/typings/src/prepare/prepareTemplates.d.ts +1 -1
- package/esm/typings/src/scrapers/_common/Scraper.d.ts +1 -5
- package/esm/typings/src/scrapers/_common/prepareKnowledgePieces.d.ts +1 -1
- package/esm/typings/src/scrapers/_common/register/$provideExecutablesForNode.d.ts +12 -0
- package/esm/typings/src/scrapers/_common/register/$provideScrapersForBrowser.d.ts +2 -2
- package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +2 -2
- package/esm/typings/src/scrapers/_common/register/ScraperAndConverterMetadata.d.ts +2 -2
- package/esm/typings/src/scrapers/_common/utils/getScraperIntermediateSource.d.ts +2 -2
- package/esm/typings/src/scrapers/document/DocumentScraper.d.ts +2 -2
- package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -1
- package/esm/typings/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +3 -3
- package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -1
- package/esm/typings/src/scrapers/markdown/MarkdownScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -1
- package/esm/typings/src/scrapers/pdf/PdfScraper.d.ts +2 -2
- package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +1 -1
- package/esm/typings/src/scrapers/website/WebsiteScraper.d.ts +6 -3
- package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -1
- package/esm/typings/src/scrapers/website/utils/createShowdownConverter.d.ts +7 -0
- package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
- package/esm/typings/src/storage/file-cache-storage/utils/nameToSubfolderPath.d.ts +1 -1
- package/esm/typings/src/types/Arrayable.d.ts +1 -1
- package/esm/typings/src/types/IntermediateFilesStrategy.d.ts +7 -0
- package/esm/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +4 -4
- package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/TemplateJsonCommon.d.ts +2 -2
- package/esm/typings/src/types/Prompt.d.ts +1 -1
- package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +1 -1
- package/esm/typings/src/utils/$Register.d.ts +1 -1
- package/esm/typings/src/utils/FromtoItems.d.ts +1 -1
- package/esm/typings/src/utils/arrayableToArray.d.ts +1 -1
- package/esm/typings/src/utils/emojis.d.ts +1 -1
- package/esm/typings/src/utils/execCommand/$execCommand.d.ts +2 -2
- package/esm/typings/src/utils/execCommand/{IExecCommandOptions.d.ts → ExecCommandOptions.d.ts} +2 -6
- package/esm/typings/src/utils/execCommand/execCommandNormalizeOptions.d.ts +3 -3
- package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +1 -1
- package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +1 -1
- package/esm/typings/src/utils/markdown/splitMarkdownIntoSections.d.ts +1 -1
- package/esm/typings/src/utils/normalization/IKeywords.d.ts +2 -2
- package/esm/typings/src/utils/normalization/parseKeywords.d.ts +2 -2
- package/esm/typings/src/utils/normalization/parseKeywordsFromString.d.ts +2 -2
- package/esm/typings/src/utils/normalization/searchKeywords.d.ts +2 -2
- package/esm/typings/src/utils/organization/TODO_USE.d.ts +1 -1
- package/esm/typings/src/utils/organization/keepUnused.d.ts +1 -1
- package/esm/typings/src/utils/random/$randomSeed.d.ts +1 -1
- package/esm/typings/src/utils/sets/intersection.d.ts +1 -1
- package/esm/typings/src/utils/sets/union.d.ts +1 -1
- package/esm/typings/src/utils/unwrapResult.d.ts +4 -4
- package/package.json +3 -2
- package/umd/index.umd.js +58 -72
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorSettings.d.ts +0 -29
- package/esm/typings/src/scrapers/website/utils/markdownConverter.d.ts +0 -12
- /package/esm/typings/src/scrapers/website/utils/{markdownConverter.test.d.ts → createShowdownConverter.test.d.ts} +0 -0
package/umd/index.umd.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
/**
|
|
15
15
|
* The version of the Promptbook library
|
|
16
16
|
*/
|
|
17
|
-
var PROMPTBOOK_VERSION = '0.72.0-
|
|
17
|
+
var PROMPTBOOK_VERSION = '0.72.0-14';
|
|
18
18
|
// TODO: [main] !!!! List here all the versions and annotate + put into script
|
|
19
19
|
|
|
20
20
|
/*! *****************************************************************************
|
|
@@ -415,7 +415,6 @@
|
|
|
415
415
|
pipelineString += '\n\n';
|
|
416
416
|
pipelineString += description;
|
|
417
417
|
}
|
|
418
|
-
// TODO:> const commands: Array<Command>
|
|
419
418
|
var commands = [];
|
|
420
419
|
if (pipelineUrl) {
|
|
421
420
|
commands.push("PIPELINE URL ".concat(pipelineUrl));
|
|
@@ -471,7 +470,6 @@
|
|
|
471
470
|
pipelineString += '\n\n';
|
|
472
471
|
pipelineString += description_1;
|
|
473
472
|
}
|
|
474
|
-
// TODO:> const commands: Array<Command>
|
|
475
473
|
var commands_1 = [];
|
|
476
474
|
var contentLanguage = 'text';
|
|
477
475
|
if (templateType === 'PROMPT_TEMPLATE') {
|
|
@@ -837,18 +835,19 @@
|
|
|
837
835
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
838
836
|
*/
|
|
839
837
|
var IMMEDIATE_TIME = 10;
|
|
838
|
+
// <- TODO: [😡] Change to 'VISIBLE'
|
|
840
839
|
/**
|
|
841
840
|
* The maximum number of (LLM) tasks running in parallel
|
|
842
841
|
*
|
|
843
842
|
* @public exported from `@promptbook/core`
|
|
844
843
|
*/
|
|
845
|
-
var
|
|
844
|
+
var DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [🤹♂️]
|
|
846
845
|
/**
|
|
847
846
|
* The maximum number of attempts to execute LLM task before giving up
|
|
848
847
|
*
|
|
849
848
|
* @public exported from `@promptbook/core`
|
|
850
849
|
*/
|
|
851
|
-
var
|
|
850
|
+
var DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [🤹♂️]
|
|
852
851
|
/**
|
|
853
852
|
* Nonce which is used for replacing things in strings
|
|
854
853
|
*
|
|
@@ -900,7 +899,7 @@
|
|
|
900
899
|
*
|
|
901
900
|
* @public exported from `@promptbook/core`
|
|
902
901
|
*/
|
|
903
|
-
var
|
|
902
|
+
var DEFAULT_IS_VERBOSE = false;
|
|
904
903
|
/**
|
|
905
904
|
* @@@
|
|
906
905
|
*
|
|
@@ -2093,6 +2092,7 @@
|
|
|
2093
2092
|
}
|
|
2094
2093
|
}
|
|
2095
2094
|
/**
|
|
2095
|
+
* TODO: [🐚] This function should be removed OR changed OR be completely rewritten
|
|
2096
2096
|
* TODO: [🧠] Can this return type be better typed than void
|
|
2097
2097
|
*/
|
|
2098
2098
|
|
|
@@ -2278,8 +2278,7 @@
|
|
|
2278
2278
|
* Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
|
|
2279
2279
|
*
|
|
2280
2280
|
* Note: Internal utility of `joinLlmExecutionTools` but exposed type
|
|
2281
|
-
* @public exported from `@promptbook/
|
|
2282
|
-
* TODO: !!!!!! Export as runtime class not just type
|
|
2281
|
+
* @public exported from `@promptbook/core`
|
|
2283
2282
|
*/
|
|
2284
2283
|
var MultipleLlmExecutionTools = /** @class */ (function () {
|
|
2285
2284
|
/**
|
|
@@ -2781,7 +2780,7 @@
|
|
|
2781
2780
|
return __generator(this, function (_d) {
|
|
2782
2781
|
switch (_d.label) {
|
|
2783
2782
|
case 0:
|
|
2784
|
-
_a = options.isVerbose, isVerbose = _a === void 0 ?
|
|
2783
|
+
_a = options.isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
|
|
2785
2784
|
if (tools === undefined || tools.llm === undefined) {
|
|
2786
2785
|
throw new MissingToolsError('LLM tools are required for preparing persona');
|
|
2787
2786
|
}
|
|
@@ -2963,7 +2962,7 @@
|
|
|
2963
2962
|
this.storage = globalScope[storageName];
|
|
2964
2963
|
}
|
|
2965
2964
|
$Register.prototype.list = function () {
|
|
2966
|
-
// <- TODO: ReadonlyDeep<
|
|
2965
|
+
// <- TODO: ReadonlyDeep<ReadonlyArray<TRegistered>>
|
|
2967
2966
|
return this.storage;
|
|
2968
2967
|
};
|
|
2969
2968
|
$Register.prototype.register = function (registered) {
|
|
@@ -3015,7 +3014,7 @@
|
|
|
3015
3014
|
* TODO: [®] DRY Register logic
|
|
3016
3015
|
*/
|
|
3017
3016
|
|
|
3018
|
-
// TODO: !!!!!! Maybe delete this function
|
|
3017
|
+
// TODO: !!!!!!last - Maybe delete this function
|
|
3019
3018
|
/**
|
|
3020
3019
|
* Creates a message with all registered scrapers
|
|
3021
3020
|
*
|
|
@@ -3123,7 +3122,6 @@
|
|
|
3123
3122
|
* @private within the repository
|
|
3124
3123
|
*/
|
|
3125
3124
|
function sourceContentToName(sourceContent) {
|
|
3126
|
-
// TODO: !!!!!! Better name for source than gibberish hash
|
|
3127
3125
|
var hash = cryptoJs.SHA256(hexEncoder__default["default"].parse(JSON.stringify(sourceContent)))
|
|
3128
3126
|
// <- TODO: [🥬] Encapsulate sha256 to some private utility function
|
|
3129
3127
|
.toString( /* hex */)
|
|
@@ -3210,7 +3208,7 @@
|
|
|
3210
3208
|
case 0:
|
|
3211
3209
|
sourceContent = knowledgeSource.sourceContent;
|
|
3212
3210
|
name = knowledgeSource.name;
|
|
3213
|
-
_b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _d = _b.isVerbose, isVerbose = _d === void 0 ?
|
|
3211
|
+
_b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _d = _b.isVerbose, isVerbose = _d === void 0 ? DEFAULT_IS_VERBOSE : _d;
|
|
3214
3212
|
TODO_USE(isVerbose);
|
|
3215
3213
|
if (!name) {
|
|
3216
3214
|
name = sourceContentToName(sourceContent);
|
|
@@ -3300,7 +3298,7 @@
|
|
|
3300
3298
|
content = _a.sent();
|
|
3301
3299
|
return [2 /*return*/, new Blob([
|
|
3302
3300
|
content,
|
|
3303
|
-
// <- TODO: !!!!!!
|
|
3301
|
+
// <- TODO: !!!!!! Test that this is working
|
|
3304
3302
|
], { type: mimeType_1 })];
|
|
3305
3303
|
}
|
|
3306
3304
|
});
|
|
@@ -3363,7 +3361,7 @@
|
|
|
3363
3361
|
return __generator(this, function (_c) {
|
|
3364
3362
|
switch (_c.label) {
|
|
3365
3363
|
case 0:
|
|
3366
|
-
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ?
|
|
3364
|
+
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a, rootDirname = options.rootDirname, _b = options.isVerbose, isVerbose = _b === void 0 ? DEFAULT_IS_VERBOSE : _b;
|
|
3367
3365
|
knowledgePreparedUnflatten = new Array(knowledgeSources.length);
|
|
3368
3366
|
return [4 /*yield*/, forEachAsync(knowledgeSources, { maxParallelCount: maxParallelCount }, function (knowledgeSource, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
3369
3367
|
var partialPieces, sourceHandler, _a, _b, scraper, partialPiecesUnchecked, e_1_1, pieces;
|
|
@@ -3392,7 +3390,8 @@
|
|
|
3392
3390
|
case 4:
|
|
3393
3391
|
partialPiecesUnchecked = _d.sent();
|
|
3394
3392
|
if (partialPiecesUnchecked !== null) {
|
|
3395
|
-
partialPieces = partialPiecesUnchecked;
|
|
3393
|
+
partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
|
|
3394
|
+
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
3396
3395
|
return [3 /*break*/, 6];
|
|
3397
3396
|
}
|
|
3398
3397
|
_d.label = 5;
|
|
@@ -3440,7 +3439,7 @@
|
|
|
3440
3439
|
> /**
|
|
3441
3440
|
> * Unprepared knowledge
|
|
3442
3441
|
> * /
|
|
3443
|
-
> readonly knowledgeSources:
|
|
3442
|
+
> readonly knowledgeSources: ReadonlyArray<KnowledgeSourceJson>;
|
|
3444
3443
|
> };
|
|
3445
3444
|
>
|
|
3446
3445
|
> export async function prepareKnowledgePieces(
|
|
@@ -3498,7 +3497,7 @@
|
|
|
3498
3497
|
return __generator(this, function (_b) {
|
|
3499
3498
|
switch (_b.label) {
|
|
3500
3499
|
case 0:
|
|
3501
|
-
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ?
|
|
3500
|
+
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
|
|
3502
3501
|
templates = pipeline.templates, parameters = pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
|
|
3503
3502
|
// TODO: [main] !!!!! Apply samples to each template (if missing and is for the template defined)
|
|
3504
3503
|
TODO_USE(parameters);
|
|
@@ -3560,7 +3559,7 @@
|
|
|
3560
3559
|
if (isPipelinePrepared(pipeline)) {
|
|
3561
3560
|
return [2 /*return*/, pipeline];
|
|
3562
3561
|
}
|
|
3563
|
-
rootDirname = options.rootDirname, _a = options.maxParallelCount, maxParallelCount = _a === void 0 ?
|
|
3562
|
+
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;
|
|
3564
3563
|
parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
|
|
3565
3564
|
if (tools === undefined || tools.llm === undefined) {
|
|
3566
3565
|
throw new MissingToolsError('LLM tools are required for preparing the pipeline');
|
|
@@ -3618,7 +3617,9 @@
|
|
|
3618
3617
|
// ----- /Templates preparation -----
|
|
3619
3618
|
// Note: Count total usage
|
|
3620
3619
|
currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
|
|
3621
|
-
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { templates:
|
|
3620
|
+
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { templates: __spreadArray([], __read(templatesPrepared), false),
|
|
3621
|
+
// <- TODO: [🪓] Here should be no need for spreading new array, just ` templates: templatesPrepared`
|
|
3622
|
+
knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }))];
|
|
3622
3623
|
}
|
|
3623
3624
|
});
|
|
3624
3625
|
});
|
|
@@ -4452,12 +4453,11 @@
|
|
|
4452
4453
|
*/
|
|
4453
4454
|
function executeAttempts(options) {
|
|
4454
4455
|
return __awaiter(this, void 0, void 0, function () {
|
|
4455
|
-
var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, template, preparedPipeline, tools,
|
|
4456
|
+
var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, template, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTemplateResult, _llms, llmTools, _loop_1, attempt, state_1;
|
|
4456
4457
|
return __generator(this, function (_a) {
|
|
4457
4458
|
switch (_a.label) {
|
|
4458
4459
|
case 0:
|
|
4459
|
-
jokerParameterNames = options.jokerParameterNames, priority = options.priority, maxAttempts = options.maxAttempts, preparedContent = options.preparedContent, parameters = options.parameters, template = options.template, preparedPipeline = options.preparedPipeline, tools = options.tools,
|
|
4460
|
-
maxExecutionAttempts = settings.maxExecutionAttempts;
|
|
4460
|
+
jokerParameterNames = options.jokerParameterNames, priority = options.priority, maxAttempts = options.maxAttempts, preparedContent = options.preparedContent, parameters = options.parameters, template = options.template, preparedPipeline = options.preparedPipeline, tools = options.tools, $executionReport = options.$executionReport, pipelineIdentification = options.pipelineIdentification, maxExecutionAttempts = options.maxExecutionAttempts;
|
|
4461
4461
|
$ongoingTemplateResult = {
|
|
4462
4462
|
$result: null,
|
|
4463
4463
|
$resultString: null,
|
|
@@ -4823,12 +4823,12 @@
|
|
|
4823
4823
|
*/
|
|
4824
4824
|
function executeFormatSubvalues(options) {
|
|
4825
4825
|
return __awaiter(this, void 0, void 0, function () {
|
|
4826
|
-
var template, jokerParameterNames, parameters, priority,
|
|
4826
|
+
var template, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
|
|
4827
4827
|
var _this = this;
|
|
4828
4828
|
return __generator(this, function (_a) {
|
|
4829
4829
|
switch (_a.label) {
|
|
4830
4830
|
case 0:
|
|
4831
|
-
template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority,
|
|
4831
|
+
template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, csvSettings = options.csvSettings, pipelineIdentification = options.pipelineIdentification;
|
|
4832
4832
|
if (template.foreach === undefined) {
|
|
4833
4833
|
return [2 /*return*/, /* not await */ executeAttempts(options)];
|
|
4834
4834
|
}
|
|
@@ -4858,7 +4858,7 @@
|
|
|
4858
4858
|
.join('\n')), "\n\n [\u26F7] This should never happen because subformat name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
4859
4859
|
}
|
|
4860
4860
|
if (formatDefinition.formatName === 'CSV') {
|
|
4861
|
-
formatSettings =
|
|
4861
|
+
formatSettings = csvSettings;
|
|
4862
4862
|
// <- TODO: [🤹♂️] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
|
|
4863
4863
|
}
|
|
4864
4864
|
return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, template.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -5011,13 +5011,12 @@
|
|
|
5011
5011
|
*/
|
|
5012
5012
|
function executeTemplate(options) {
|
|
5013
5013
|
return __awaiter(this, void 0, void 0, function () {
|
|
5014
|
-
var currentTemplate, preparedPipeline, parametersToPass, tools, onProgress,
|
|
5015
|
-
var e_1,
|
|
5016
|
-
return __generator(this, function (
|
|
5017
|
-
switch (
|
|
5014
|
+
var currentTemplate, 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;
|
|
5015
|
+
var e_1, _g, _h;
|
|
5016
|
+
return __generator(this, function (_j) {
|
|
5017
|
+
switch (_j.label) {
|
|
5018
5018
|
case 0:
|
|
5019
|
-
currentTemplate = options.currentTemplate, preparedPipeline = options.preparedPipeline, parametersToPass = options.parametersToPass, tools = options.tools, onProgress = options.onProgress,
|
|
5020
|
-
maxExecutionAttempts = settings.maxExecutionAttempts;
|
|
5019
|
+
currentTemplate = options.currentTemplate, 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;
|
|
5021
5020
|
name = "pipeline-executor-frame-".concat(currentTemplate.name);
|
|
5022
5021
|
title = currentTemplate.title;
|
|
5023
5022
|
priority = preparedPipeline.templates.length - preparedPipeline.templates.indexOf(currentTemplate);
|
|
@@ -5032,7 +5031,7 @@
|
|
|
5032
5031
|
// <- [🍸]
|
|
5033
5032
|
})];
|
|
5034
5033
|
case 1:
|
|
5035
|
-
|
|
5034
|
+
_j.sent();
|
|
5036
5035
|
usedParameterNames = extractParameterNamesFromTemplate(currentTemplate);
|
|
5037
5036
|
dependentParameterNames = new Set(currentTemplate.dependentParameterNames);
|
|
5038
5037
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
@@ -5043,15 +5042,15 @@
|
|
|
5043
5042
|
.map(function (name) { return "{".concat(name, "}"); })
|
|
5044
5043
|
.join(', '), "\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
|
|
5045
5044
|
}
|
|
5046
|
-
|
|
5047
|
-
|
|
5045
|
+
_c = (_b = Object).freeze;
|
|
5046
|
+
_d = [{}];
|
|
5048
5047
|
return [4 /*yield*/, getReservedParametersForTemplate({
|
|
5049
5048
|
preparedPipeline: preparedPipeline,
|
|
5050
5049
|
template: currentTemplate,
|
|
5051
5050
|
pipelineIdentification: pipelineIdentification,
|
|
5052
5051
|
})];
|
|
5053
5052
|
case 2:
|
|
5054
|
-
definedParameters =
|
|
5053
|
+
definedParameters = _c.apply(_b, [__assign.apply(void 0, [__assign.apply(void 0, _d.concat([(_j.sent())])), parametersToPass])]);
|
|
5055
5054
|
definedParameterNames = new Set(Object.keys(definedParameters));
|
|
5056
5055
|
parameters = {};
|
|
5057
5056
|
_loop_1 = function (parameterName) {
|
|
@@ -5071,15 +5070,15 @@
|
|
|
5071
5070
|
try {
|
|
5072
5071
|
// Note: [2] Check that all used parameters are defined and removing unused parameters for this template
|
|
5073
5072
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
5074
|
-
for (
|
|
5075
|
-
parameterName =
|
|
5073
|
+
for (_e = __values(Array.from(union(definedParameterNames, usedParameterNames, dependentParameterNames))), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
5074
|
+
parameterName = _f.value;
|
|
5076
5075
|
_loop_1(parameterName);
|
|
5077
5076
|
}
|
|
5078
5077
|
}
|
|
5079
5078
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
5080
5079
|
finally {
|
|
5081
5080
|
try {
|
|
5082
|
-
if (
|
|
5081
|
+
if (_f && !_f.done && (_g = _e.return)) _g.call(_e);
|
|
5083
5082
|
}
|
|
5084
5083
|
finally { if (e_1) throw e_1.error; }
|
|
5085
5084
|
}
|
|
@@ -5099,12 +5098,11 @@
|
|
|
5099
5098
|
template: currentTemplate,
|
|
5100
5099
|
preparedPipeline: preparedPipeline,
|
|
5101
5100
|
tools: tools,
|
|
5102
|
-
settings: settings,
|
|
5103
5101
|
$executionReport: $executionReport,
|
|
5104
5102
|
pipelineIdentification: pipelineIdentification,
|
|
5105
5103
|
})];
|
|
5106
5104
|
case 3:
|
|
5107
|
-
resultString =
|
|
5105
|
+
resultString = _j.sent();
|
|
5108
5106
|
return [4 /*yield*/, onProgress({
|
|
5109
5107
|
name: name,
|
|
5110
5108
|
title: title,
|
|
@@ -5116,12 +5114,12 @@
|
|
|
5116
5114
|
// <- [🍸]
|
|
5117
5115
|
})];
|
|
5118
5116
|
case 4:
|
|
5119
|
-
|
|
5120
|
-
return [2 /*return*/, Object.freeze((
|
|
5121
|
-
|
|
5117
|
+
_j.sent();
|
|
5118
|
+
return [2 /*return*/, Object.freeze((_h = {},
|
|
5119
|
+
_h[currentTemplate.resultingParameterName] =
|
|
5122
5120
|
// <- Note: [👩👩👧] No need to detect parameter collision here because pipeline checks logic consistency during construction
|
|
5123
5121
|
resultString,
|
|
5124
|
-
|
|
5122
|
+
_h))];
|
|
5125
5123
|
}
|
|
5126
5124
|
});
|
|
5127
5125
|
});
|
|
@@ -5180,13 +5178,12 @@
|
|
|
5180
5178
|
*/
|
|
5181
5179
|
function executePipeline(options) {
|
|
5182
5180
|
return __awaiter(this, void 0, void 0, function () {
|
|
5183
|
-
var inputParameters, tools, onProgress, pipeline, setPreparedPipeline, pipelineIdentification,
|
|
5181
|
+
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, unresovedTemplates_1, resolving_1, loopLimit, _loop_2, error_1, usage_1, outputParameters_1, usage, outputParameters;
|
|
5184
5182
|
var e_1, _f, e_2, _g;
|
|
5185
5183
|
return __generator(this, function (_h) {
|
|
5186
5184
|
switch (_h.label) {
|
|
5187
5185
|
case 0:
|
|
5188
|
-
inputParameters = options.inputParameters, tools = options.tools, onProgress = options.onProgress, pipeline = options.pipeline, setPreparedPipeline = options.setPreparedPipeline, pipelineIdentification = options.pipelineIdentification,
|
|
5189
|
-
maxParallelCount = settings.maxParallelCount, rootDirname = settings.rootDirname, _a = settings.isVerbose, isVerbose = _a === void 0 ? IS_VERBOSE : _a;
|
|
5186
|
+
inputParameters = options.inputParameters, tools = options.tools, onProgress = options.onProgress, pipeline = options.pipeline, setPreparedPipeline = options.setPreparedPipeline, pipelineIdentification = options.pipelineIdentification, maxParallelCount = options.maxParallelCount, rootDirname = options.rootDirname, _a = options.isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
|
|
5190
5187
|
preparedPipeline = options.preparedPipeline;
|
|
5191
5188
|
if (!(preparedPipeline === undefined)) return [3 /*break*/, 2];
|
|
5192
5189
|
return [4 /*yield*/, preparePipeline(pipeline, tools, {
|
|
@@ -5371,12 +5368,7 @@
|
|
|
5371
5368
|
return [3 /*break*/, 4];
|
|
5372
5369
|
case 3:
|
|
5373
5370
|
unresovedTemplates_1 = unresovedTemplates_1.filter(function (template) { return template !== currentTemplate; });
|
|
5374
|
-
work_1 = executeTemplate({
|
|
5375
|
-
currentTemplate: currentTemplate,
|
|
5376
|
-
preparedPipeline: preparedPipeline,
|
|
5377
|
-
parametersToPass: parametersToPass,
|
|
5378
|
-
tools: tools,
|
|
5379
|
-
onProgress: function (progress) {
|
|
5371
|
+
work_1 = executeTemplate(__assign(__assign({}, options), { currentTemplate: currentTemplate, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (progress) {
|
|
5380
5372
|
if (isReturned) {
|
|
5381
5373
|
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)
|
|
5382
5374
|
.split('\n')
|
|
@@ -5386,11 +5378,7 @@
|
|
|
5386
5378
|
if (onProgress) {
|
|
5387
5379
|
onProgress(progress);
|
|
5388
5380
|
}
|
|
5389
|
-
},
|
|
5390
|
-
settings: settings,
|
|
5391
|
-
$executionReport: executionReport,
|
|
5392
|
-
pipelineIdentification: spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Template name: ").concat(currentTemplate.name, "\n Template title: ").concat(currentTemplate.title, "\n "); }),
|
|
5393
|
-
})
|
|
5381
|
+
}, $executionReport: executionReport, pipelineIdentification: spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Template name: ").concat(currentTemplate.name, "\n Template title: ").concat(currentTemplate.title, "\n "); }) }))
|
|
5394
5382
|
.then(function (newParametersToPass) {
|
|
5395
5383
|
parametersToPass = __assign(__assign({}, newParametersToPass), parametersToPass);
|
|
5396
5384
|
resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [currentTemplate.resultingParameterName], false);
|
|
@@ -5494,8 +5482,7 @@
|
|
|
5494
5482
|
*/
|
|
5495
5483
|
function createPipelineExecutor(options) {
|
|
5496
5484
|
var _this = this;
|
|
5497
|
-
var pipeline = options.pipeline, tools = options.tools, _a = options.
|
|
5498
|
-
var _b = settings.maxExecutionAttempts, maxExecutionAttempts = _b === void 0 ? MAX_EXECUTION_ATTEMPTS : _b, _c = settings.maxParallelCount, maxParallelCount = _c === void 0 ? MAX_PARALLEL_COUNT : _c, _d = settings.csvSettings, csvSettings = _d === void 0 ? DEFAULT_CSV_SETTINGS : _d, _e = settings.isVerbose, isVerbose = _e === void 0 ? IS_VERBOSE : _e, _f = settings.isNotPreparedWarningSupressed, isNotPreparedWarningSupressed = _f === void 0 ? false : _f, _g = settings.rootDirname, rootDirname = _g === void 0 ? null : _g;
|
|
5485
|
+
var pipeline = options.pipeline, tools = options.tools, _a = options.maxExecutionAttempts, maxExecutionAttempts = _a === void 0 ? DEFAULT_MAX_EXECUTION_ATTEMPTS : _a, _b = options.maxParallelCount, maxParallelCount = _b === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _b, _c = options.csvSettings, csvSettings = _c === void 0 ? DEFAULT_CSV_SETTINGS : _c, _d = options.isVerbose, isVerbose = _d === void 0 ? DEFAULT_IS_VERBOSE : _d, _e = options.isNotPreparedWarningSupressed, isNotPreparedWarningSupressed = _e === void 0 ? false : _e, _f = options.rootDirname, rootDirname = _f === void 0 ? null : _f;
|
|
5499
5486
|
validatePipeline(pipeline);
|
|
5500
5487
|
var pipelineIdentification = (function () {
|
|
5501
5488
|
// Note: This is a 😐 implementation of [🚞]
|
|
@@ -5529,14 +5516,12 @@
|
|
|
5529
5516
|
tools: tools,
|
|
5530
5517
|
onProgress: onProgress,
|
|
5531
5518
|
pipelineIdentification: spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n ").concat(runCount === 1 ? '' : "Run #".concat(runCount), "\n "); }),
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
rootDirname: rootDirname,
|
|
5539
|
-
},
|
|
5519
|
+
maxExecutionAttempts: maxExecutionAttempts,
|
|
5520
|
+
maxParallelCount: maxParallelCount,
|
|
5521
|
+
csvSettings: csvSettings,
|
|
5522
|
+
isVerbose: isVerbose,
|
|
5523
|
+
isNotPreparedWarningSupressed: isNotPreparedWarningSupressed,
|
|
5524
|
+
rootDirname: rootDirname,
|
|
5540
5525
|
})];
|
|
5541
5526
|
});
|
|
5542
5527
|
}); };
|
|
@@ -5558,7 +5543,7 @@
|
|
|
5558
5543
|
mimeTypes: ['text/markdown', 'text/plain'],
|
|
5559
5544
|
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
|
|
5560
5545
|
isAvilableInBrowser: true,
|
|
5561
|
-
requiredExecutables: [
|
|
5546
|
+
requiredExecutables: [],
|
|
5562
5547
|
}); /* <- TODO: [🤛] */
|
|
5563
5548
|
/**
|
|
5564
5549
|
* Registration of known scraper metadata
|
|
@@ -5602,7 +5587,7 @@
|
|
|
5602
5587
|
return __generator(this, function (_k) {
|
|
5603
5588
|
switch (_k.label) {
|
|
5604
5589
|
case 0:
|
|
5605
|
-
_a = this.options, _b = _a.maxParallelCount, maxParallelCount = _b === void 0 ?
|
|
5590
|
+
_a = this.options, _b = _a.maxParallelCount, maxParallelCount = _b === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _b, _c = _a.isVerbose, isVerbose = _c === void 0 ? DEFAULT_IS_VERBOSE : _c;
|
|
5606
5591
|
llm = this.tools.llm;
|
|
5607
5592
|
if (llm === undefined) {
|
|
5608
5593
|
throw new MissingToolsError('LLM tools are required for scraping external files');
|
|
@@ -5701,7 +5686,8 @@
|
|
|
5701
5686
|
embeddingResult = _c.sent();
|
|
5702
5687
|
index.push({
|
|
5703
5688
|
modelName: embeddingResult.modelName,
|
|
5704
|
-
position: embeddingResult.content,
|
|
5689
|
+
position: __spreadArray([], __read(embeddingResult.content), false),
|
|
5690
|
+
// <- TODO: [🪓] Here should be no need for spreading new array, just `position: embeddingResult.content`
|
|
5705
5691
|
});
|
|
5706
5692
|
_c.label = 6;
|
|
5707
5693
|
case 6: return [3 /*break*/, 8];
|