@promptbook/pdf 0.71.0-18 → 0.71.0-20
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 +0 -6
- package/esm/index.es.js +58 -70
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +22 -18
- package/esm/typings/src/_packages/types.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/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/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/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 +3 -3
- 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 +1 -1
- package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +4 -4
- 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/$provideScrapersForBrowser.d.ts +1 -1
- package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +1 -1
- 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/_common/utils/makeKnowledgeSourceHandler.d.ts +1 -1
- package/esm/typings/src/scrapers/document/DocumentScraper.d.ts +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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/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/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/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/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/package.json +2 -2
- package/umd/index.umd.js +58 -70
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorSettings.d.ts +0 -29
package/README.md
CHANGED
|
@@ -20,12 +20,6 @@ Build responsible, controlled and transparent applications on top of LLM models!
|
|
|
20
20
|
|
|
21
21
|
- ✨ **Support of [OpenAI o1 model](https://openai.com/o1/)**
|
|
22
22
|
|
|
23
|
-
<blockquote style="color: #ff8811">
|
|
24
|
-
<b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
|
|
25
|
-
</blockquote>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
23
|
<blockquote style="color: #ff8811">
|
|
30
24
|
<b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
|
|
31
25
|
</blockquote>
|
package/esm/index.es.js
CHANGED
|
@@ -12,7 +12,7 @@ import { unparse, parse } from 'papaparse';
|
|
|
12
12
|
/**
|
|
13
13
|
* The version of the Promptbook library
|
|
14
14
|
*/
|
|
15
|
-
var PROMPTBOOK_VERSION = '0.71.0-
|
|
15
|
+
var PROMPTBOOK_VERSION = '0.71.0-19';
|
|
16
16
|
// TODO: [main] !!!! List here all the versions and annotate + put into script
|
|
17
17
|
|
|
18
18
|
/*! *****************************************************************************
|
|
@@ -227,7 +227,6 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
227
227
|
pipelineString += '\n\n';
|
|
228
228
|
pipelineString += description;
|
|
229
229
|
}
|
|
230
|
-
// TODO:> const commands: Array<Command>
|
|
231
230
|
var commands = [];
|
|
232
231
|
if (pipelineUrl) {
|
|
233
232
|
commands.push("PIPELINE URL ".concat(pipelineUrl));
|
|
@@ -283,7 +282,6 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
283
282
|
pipelineString += '\n\n';
|
|
284
283
|
pipelineString += description_1;
|
|
285
284
|
}
|
|
286
|
-
// TODO:> const commands: Array<Command>
|
|
287
285
|
var commands_1 = [];
|
|
288
286
|
var contentLanguage = 'text';
|
|
289
287
|
if (templateType === 'PROMPT_TEMPLATE') {
|
|
@@ -643,18 +641,19 @@ var LOOP_LIMIT = 1000;
|
|
|
643
641
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
644
642
|
*/
|
|
645
643
|
var IMMEDIATE_TIME = 10;
|
|
644
|
+
// <- TODO: [😡] Change to 'VISIBLE'
|
|
646
645
|
/**
|
|
647
646
|
* The maximum number of (LLM) tasks running in parallel
|
|
648
647
|
*
|
|
649
648
|
* @public exported from `@promptbook/core`
|
|
650
649
|
*/
|
|
651
|
-
var
|
|
650
|
+
var DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [🤹♂️]
|
|
652
651
|
/**
|
|
653
652
|
* The maximum number of attempts to execute LLM task before giving up
|
|
654
653
|
*
|
|
655
654
|
* @public exported from `@promptbook/core`
|
|
656
655
|
*/
|
|
657
|
-
var
|
|
656
|
+
var DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [🤹♂️]
|
|
658
657
|
/**
|
|
659
658
|
* Nonce which is used for replacing things in strings
|
|
660
659
|
*
|
|
@@ -706,7 +705,7 @@ var DEFAULT_CSV_SETTINGS = Object.freeze({
|
|
|
706
705
|
*
|
|
707
706
|
* @public exported from `@promptbook/core`
|
|
708
707
|
*/
|
|
709
|
-
var
|
|
708
|
+
var DEFAULT_IS_VERBOSE = false;
|
|
710
709
|
/**
|
|
711
710
|
* @@@
|
|
712
711
|
*
|
|
@@ -1902,6 +1901,7 @@ function assertsExecutionSuccessful(executionResult) {
|
|
|
1902
1901
|
}
|
|
1903
1902
|
}
|
|
1904
1903
|
/**
|
|
1904
|
+
* TODO: [🐚] This function should be removed OR changed OR be completely rewritten
|
|
1905
1905
|
* TODO: [🧠] Can this return type be better typed than void
|
|
1906
1906
|
*/
|
|
1907
1907
|
|
|
@@ -2562,7 +2562,7 @@ function preparePersona(personaDescription, tools, options) {
|
|
|
2562
2562
|
return __generator(this, function (_d) {
|
|
2563
2563
|
switch (_d.label) {
|
|
2564
2564
|
case 0:
|
|
2565
|
-
_a = options.isVerbose, isVerbose = _a === void 0 ?
|
|
2565
|
+
_a = options.isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
|
|
2566
2566
|
if (tools === undefined || tools.llm === undefined) {
|
|
2567
2567
|
throw new MissingToolsError('LLM tools are required for preparing persona');
|
|
2568
2568
|
}
|
|
@@ -2744,7 +2744,7 @@ var $Register = /** @class */ (function () {
|
|
|
2744
2744
|
this.storage = globalScope[storageName];
|
|
2745
2745
|
}
|
|
2746
2746
|
$Register.prototype.list = function () {
|
|
2747
|
-
// <- TODO: ReadonlyDeep<
|
|
2747
|
+
// <- TODO: ReadonlyDeep<ReadonlyArray<TRegistered>>
|
|
2748
2748
|
return this.storage;
|
|
2749
2749
|
};
|
|
2750
2750
|
$Register.prototype.register = function (registered) {
|
|
@@ -2977,7 +2977,7 @@ function isFileExisting(filename, fs) {
|
|
|
2977
2977
|
/**
|
|
2978
2978
|
* @@@
|
|
2979
2979
|
*
|
|
2980
|
-
* @
|
|
2980
|
+
* @public exported from `@promptbook/core`
|
|
2981
2981
|
*/
|
|
2982
2982
|
function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
2983
2983
|
var _a;
|
|
@@ -2990,7 +2990,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
2990
2990
|
case 0:
|
|
2991
2991
|
sourceContent = knowledgeSource.sourceContent;
|
|
2992
2992
|
name = knowledgeSource.name;
|
|
2993
|
-
_b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _d = _b.isVerbose, isVerbose = _d === void 0 ?
|
|
2993
|
+
_b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _d = _b.isVerbose, isVerbose = _d === void 0 ? DEFAULT_IS_VERBOSE : _d;
|
|
2994
2994
|
TODO_USE(isVerbose);
|
|
2995
2995
|
if (!name) {
|
|
2996
2996
|
name = sourceContentToName(sourceContent);
|
|
@@ -3143,7 +3143,7 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
3143
3143
|
return __generator(this, function (_c) {
|
|
3144
3144
|
switch (_c.label) {
|
|
3145
3145
|
case 0:
|
|
3146
|
-
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ?
|
|
3146
|
+
_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;
|
|
3147
3147
|
knowledgePreparedUnflatten = new Array(knowledgeSources.length);
|
|
3148
3148
|
return [4 /*yield*/, forEachAsync(knowledgeSources, { maxParallelCount: maxParallelCount }, function (knowledgeSource, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
3149
3149
|
var partialPieces, sourceHandler, _a, _b, scraper, partialPiecesUnchecked, e_1_1, pieces;
|
|
@@ -3172,7 +3172,8 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
3172
3172
|
case 4:
|
|
3173
3173
|
partialPiecesUnchecked = _d.sent();
|
|
3174
3174
|
if (partialPiecesUnchecked !== null) {
|
|
3175
|
-
partialPieces = partialPiecesUnchecked;
|
|
3175
|
+
partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
|
|
3176
|
+
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
3176
3177
|
return [3 /*break*/, 6];
|
|
3177
3178
|
}
|
|
3178
3179
|
_d.label = 5;
|
|
@@ -3220,7 +3221,7 @@ TODO: [🧊] This is how it can look in future
|
|
|
3220
3221
|
> /**
|
|
3221
3222
|
> * Unprepared knowledge
|
|
3222
3223
|
> * /
|
|
3223
|
-
> readonly knowledgeSources:
|
|
3224
|
+
> readonly knowledgeSources: ReadonlyArray<KnowledgeSourceJson>;
|
|
3224
3225
|
> };
|
|
3225
3226
|
>
|
|
3226
3227
|
> export async function prepareKnowledgePieces(
|
|
@@ -3278,7 +3279,7 @@ function prepareTemplates(pipeline, tools, options) {
|
|
|
3278
3279
|
return __generator(this, function (_b) {
|
|
3279
3280
|
switch (_b.label) {
|
|
3280
3281
|
case 0:
|
|
3281
|
-
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ?
|
|
3282
|
+
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
|
|
3282
3283
|
templates = pipeline.templates, parameters = pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
|
|
3283
3284
|
// TODO: [main] !!!!! Apply samples to each template (if missing and is for the template defined)
|
|
3284
3285
|
TODO_USE(parameters);
|
|
@@ -3340,7 +3341,7 @@ function preparePipeline(pipeline, tools, options) {
|
|
|
3340
3341
|
if (isPipelinePrepared(pipeline)) {
|
|
3341
3342
|
return [2 /*return*/, pipeline];
|
|
3342
3343
|
}
|
|
3343
|
-
rootDirname = options.rootDirname, _a = options.maxParallelCount, maxParallelCount = _a === void 0 ?
|
|
3344
|
+
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;
|
|
3344
3345
|
parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
|
|
3345
3346
|
if (tools === undefined || tools.llm === undefined) {
|
|
3346
3347
|
throw new MissingToolsError('LLM tools are required for preparing the pipeline');
|
|
@@ -3398,7 +3399,9 @@ function preparePipeline(pipeline, tools, options) {
|
|
|
3398
3399
|
// ----- /Templates preparation -----
|
|
3399
3400
|
// Note: Count total usage
|
|
3400
3401
|
currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
|
|
3401
|
-
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { templates:
|
|
3402
|
+
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { templates: __spreadArray([], __read(templatesPrepared), false),
|
|
3403
|
+
// <- TODO: [🪓] Here should be no need for spreading new array, just ` templates: templatesPrepared`
|
|
3404
|
+
knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }))];
|
|
3402
3405
|
}
|
|
3403
3406
|
});
|
|
3404
3407
|
});
|
|
@@ -4369,12 +4372,11 @@ function checkExpectations(expectations, value) {
|
|
|
4369
4372
|
*/
|
|
4370
4373
|
function executeAttempts(options) {
|
|
4371
4374
|
return __awaiter(this, void 0, void 0, function () {
|
|
4372
|
-
var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, template, preparedPipeline, tools,
|
|
4375
|
+
var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, template, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTemplateResult, _llms, llmTools, _loop_1, attempt, state_1;
|
|
4373
4376
|
return __generator(this, function (_a) {
|
|
4374
4377
|
switch (_a.label) {
|
|
4375
4378
|
case 0:
|
|
4376
|
-
jokerParameterNames = options.jokerParameterNames, priority = options.priority, maxAttempts = options.maxAttempts, preparedContent = options.preparedContent, parameters = options.parameters, template = options.template, preparedPipeline = options.preparedPipeline, tools = options.tools,
|
|
4377
|
-
maxExecutionAttempts = settings.maxExecutionAttempts;
|
|
4379
|
+
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;
|
|
4378
4380
|
$ongoingTemplateResult = {
|
|
4379
4381
|
$result: null,
|
|
4380
4382
|
$resultString: null,
|
|
@@ -4740,12 +4742,12 @@ function executeAttempts(options) {
|
|
|
4740
4742
|
*/
|
|
4741
4743
|
function executeFormatSubvalues(options) {
|
|
4742
4744
|
return __awaiter(this, void 0, void 0, function () {
|
|
4743
|
-
var template, jokerParameterNames, parameters, priority,
|
|
4745
|
+
var template, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
|
|
4744
4746
|
var _this = this;
|
|
4745
4747
|
return __generator(this, function (_a) {
|
|
4746
4748
|
switch (_a.label) {
|
|
4747
4749
|
case 0:
|
|
4748
|
-
template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority,
|
|
4750
|
+
template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, csvSettings = options.csvSettings, pipelineIdentification = options.pipelineIdentification;
|
|
4749
4751
|
if (template.foreach === undefined) {
|
|
4750
4752
|
return [2 /*return*/, /* not await */ executeAttempts(options)];
|
|
4751
4753
|
}
|
|
@@ -4775,7 +4777,7 @@ function executeFormatSubvalues(options) {
|
|
|
4775
4777
|
.join('\n')), "\n\n [\u26F7] This should never happen because subformat name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
4776
4778
|
}
|
|
4777
4779
|
if (formatDefinition.formatName === 'CSV') {
|
|
4778
|
-
formatSettings =
|
|
4780
|
+
formatSettings = csvSettings;
|
|
4779
4781
|
// <- TODO: [🤹♂️] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
|
|
4780
4782
|
}
|
|
4781
4783
|
return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, template.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -4928,13 +4930,12 @@ function getReservedParametersForTemplate(options) {
|
|
|
4928
4930
|
*/
|
|
4929
4931
|
function executeTemplate(options) {
|
|
4930
4932
|
return __awaiter(this, void 0, void 0, function () {
|
|
4931
|
-
var currentTemplate, preparedPipeline, parametersToPass, tools, onProgress,
|
|
4932
|
-
var e_1,
|
|
4933
|
-
return __generator(this, function (
|
|
4934
|
-
switch (
|
|
4933
|
+
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;
|
|
4934
|
+
var e_1, _g, _h;
|
|
4935
|
+
return __generator(this, function (_j) {
|
|
4936
|
+
switch (_j.label) {
|
|
4935
4937
|
case 0:
|
|
4936
|
-
currentTemplate = options.currentTemplate, preparedPipeline = options.preparedPipeline, parametersToPass = options.parametersToPass, tools = options.tools, onProgress = options.onProgress,
|
|
4937
|
-
maxExecutionAttempts = settings.maxExecutionAttempts;
|
|
4938
|
+
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;
|
|
4938
4939
|
name = "pipeline-executor-frame-".concat(currentTemplate.name);
|
|
4939
4940
|
title = currentTemplate.title;
|
|
4940
4941
|
priority = preparedPipeline.templates.length - preparedPipeline.templates.indexOf(currentTemplate);
|
|
@@ -4949,7 +4950,7 @@ function executeTemplate(options) {
|
|
|
4949
4950
|
// <- [🍸]
|
|
4950
4951
|
})];
|
|
4951
4952
|
case 1:
|
|
4952
|
-
|
|
4953
|
+
_j.sent();
|
|
4953
4954
|
usedParameterNames = extractParameterNamesFromTemplate(currentTemplate);
|
|
4954
4955
|
dependentParameterNames = new Set(currentTemplate.dependentParameterNames);
|
|
4955
4956
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
@@ -4960,15 +4961,15 @@ function executeTemplate(options) {
|
|
|
4960
4961
|
.map(function (name) { return "{".concat(name, "}"); })
|
|
4961
4962
|
.join(', '), "\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
|
|
4962
4963
|
}
|
|
4963
|
-
|
|
4964
|
-
|
|
4964
|
+
_c = (_b = Object).freeze;
|
|
4965
|
+
_d = [{}];
|
|
4965
4966
|
return [4 /*yield*/, getReservedParametersForTemplate({
|
|
4966
4967
|
preparedPipeline: preparedPipeline,
|
|
4967
4968
|
template: currentTemplate,
|
|
4968
4969
|
pipelineIdentification: pipelineIdentification,
|
|
4969
4970
|
})];
|
|
4970
4971
|
case 2:
|
|
4971
|
-
definedParameters =
|
|
4972
|
+
definedParameters = _c.apply(_b, [__assign.apply(void 0, [__assign.apply(void 0, _d.concat([(_j.sent())])), parametersToPass])]);
|
|
4972
4973
|
definedParameterNames = new Set(Object.keys(definedParameters));
|
|
4973
4974
|
parameters = {};
|
|
4974
4975
|
_loop_1 = function (parameterName) {
|
|
@@ -4988,15 +4989,15 @@ function executeTemplate(options) {
|
|
|
4988
4989
|
try {
|
|
4989
4990
|
// Note: [2] Check that all used parameters are defined and removing unused parameters for this template
|
|
4990
4991
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
4991
|
-
for (
|
|
4992
|
-
parameterName =
|
|
4992
|
+
for (_e = __values(Array.from(union(definedParameterNames, usedParameterNames, dependentParameterNames))), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
4993
|
+
parameterName = _f.value;
|
|
4993
4994
|
_loop_1(parameterName);
|
|
4994
4995
|
}
|
|
4995
4996
|
}
|
|
4996
4997
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
4997
4998
|
finally {
|
|
4998
4999
|
try {
|
|
4999
|
-
if (
|
|
5000
|
+
if (_f && !_f.done && (_g = _e.return)) _g.call(_e);
|
|
5000
5001
|
}
|
|
5001
5002
|
finally { if (e_1) throw e_1.error; }
|
|
5002
5003
|
}
|
|
@@ -5016,12 +5017,11 @@ function executeTemplate(options) {
|
|
|
5016
5017
|
template: currentTemplate,
|
|
5017
5018
|
preparedPipeline: preparedPipeline,
|
|
5018
5019
|
tools: tools,
|
|
5019
|
-
settings: settings,
|
|
5020
5020
|
$executionReport: $executionReport,
|
|
5021
5021
|
pipelineIdentification: pipelineIdentification,
|
|
5022
5022
|
})];
|
|
5023
5023
|
case 3:
|
|
5024
|
-
resultString =
|
|
5024
|
+
resultString = _j.sent();
|
|
5025
5025
|
return [4 /*yield*/, onProgress({
|
|
5026
5026
|
name: name,
|
|
5027
5027
|
title: title,
|
|
@@ -5033,12 +5033,12 @@ function executeTemplate(options) {
|
|
|
5033
5033
|
// <- [🍸]
|
|
5034
5034
|
})];
|
|
5035
5035
|
case 4:
|
|
5036
|
-
|
|
5037
|
-
return [2 /*return*/, Object.freeze((
|
|
5038
|
-
|
|
5036
|
+
_j.sent();
|
|
5037
|
+
return [2 /*return*/, Object.freeze((_h = {},
|
|
5038
|
+
_h[currentTemplate.resultingParameterName] =
|
|
5039
5039
|
// <- Note: [👩👩👧] No need to detect parameter collision here because pipeline checks logic consistency during construction
|
|
5040
5040
|
resultString,
|
|
5041
|
-
|
|
5041
|
+
_h))];
|
|
5042
5042
|
}
|
|
5043
5043
|
});
|
|
5044
5044
|
});
|
|
@@ -5097,13 +5097,12 @@ function filterJustOutputParameters(options) {
|
|
|
5097
5097
|
*/
|
|
5098
5098
|
function executePipeline(options) {
|
|
5099
5099
|
return __awaiter(this, void 0, void 0, function () {
|
|
5100
|
-
var inputParameters, tools, onProgress, pipeline, setPreparedPipeline, pipelineIdentification,
|
|
5100
|
+
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;
|
|
5101
5101
|
var e_1, _f, e_2, _g;
|
|
5102
5102
|
return __generator(this, function (_h) {
|
|
5103
5103
|
switch (_h.label) {
|
|
5104
5104
|
case 0:
|
|
5105
|
-
inputParameters = options.inputParameters, tools = options.tools, onProgress = options.onProgress, pipeline = options.pipeline, setPreparedPipeline = options.setPreparedPipeline, pipelineIdentification = options.pipelineIdentification,
|
|
5106
|
-
maxParallelCount = settings.maxParallelCount, rootDirname = settings.rootDirname, _a = settings.isVerbose, isVerbose = _a === void 0 ? IS_VERBOSE : _a;
|
|
5105
|
+
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;
|
|
5107
5106
|
preparedPipeline = options.preparedPipeline;
|
|
5108
5107
|
if (!(preparedPipeline === undefined)) return [3 /*break*/, 2];
|
|
5109
5108
|
return [4 /*yield*/, preparePipeline(pipeline, tools, {
|
|
@@ -5288,12 +5287,7 @@ function executePipeline(options) {
|
|
|
5288
5287
|
return [3 /*break*/, 4];
|
|
5289
5288
|
case 3:
|
|
5290
5289
|
unresovedTemplates_1 = unresovedTemplates_1.filter(function (template) { return template !== currentTemplate; });
|
|
5291
|
-
work_1 = executeTemplate({
|
|
5292
|
-
currentTemplate: currentTemplate,
|
|
5293
|
-
preparedPipeline: preparedPipeline,
|
|
5294
|
-
parametersToPass: parametersToPass,
|
|
5295
|
-
tools: tools,
|
|
5296
|
-
onProgress: function (progress) {
|
|
5290
|
+
work_1 = executeTemplate(__assign(__assign({}, options), { currentTemplate: currentTemplate, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (progress) {
|
|
5297
5291
|
if (isReturned) {
|
|
5298
5292
|
throw new UnexpectedError(spaceTrim(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(progress, null, 4)
|
|
5299
5293
|
.split('\n')
|
|
@@ -5303,11 +5297,7 @@ function executePipeline(options) {
|
|
|
5303
5297
|
if (onProgress) {
|
|
5304
5298
|
onProgress(progress);
|
|
5305
5299
|
}
|
|
5306
|
-
},
|
|
5307
|
-
settings: settings,
|
|
5308
|
-
$executionReport: executionReport,
|
|
5309
|
-
pipelineIdentification: spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Template name: ").concat(currentTemplate.name, "\n Template title: ").concat(currentTemplate.title, "\n "); }),
|
|
5310
|
-
})
|
|
5300
|
+
}, $executionReport: executionReport, pipelineIdentification: spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Template name: ").concat(currentTemplate.name, "\n Template title: ").concat(currentTemplate.title, "\n "); }) }))
|
|
5311
5301
|
.then(function (newParametersToPass) {
|
|
5312
5302
|
parametersToPass = __assign(__assign({}, newParametersToPass), parametersToPass);
|
|
5313
5303
|
resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [currentTemplate.resultingParameterName], false);
|
|
@@ -5411,8 +5401,7 @@ function executePipeline(options) {
|
|
|
5411
5401
|
*/
|
|
5412
5402
|
function createPipelineExecutor(options) {
|
|
5413
5403
|
var _this = this;
|
|
5414
|
-
var pipeline = options.pipeline, tools = options.tools, _a = options.
|
|
5415
|
-
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;
|
|
5404
|
+
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;
|
|
5416
5405
|
validatePipeline(pipeline);
|
|
5417
5406
|
var pipelineIdentification = (function () {
|
|
5418
5407
|
// Note: This is a 😐 implementation of [🚞]
|
|
@@ -5446,14 +5435,12 @@ function createPipelineExecutor(options) {
|
|
|
5446
5435
|
tools: tools,
|
|
5447
5436
|
onProgress: onProgress,
|
|
5448
5437
|
pipelineIdentification: spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n ").concat(runCount === 1 ? '' : "Run #".concat(runCount), "\n "); }),
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
rootDirname: rootDirname,
|
|
5456
|
-
},
|
|
5438
|
+
maxExecutionAttempts: maxExecutionAttempts,
|
|
5439
|
+
maxParallelCount: maxParallelCount,
|
|
5440
|
+
csvSettings: csvSettings,
|
|
5441
|
+
isVerbose: isVerbose,
|
|
5442
|
+
isNotPreparedWarningSupressed: isNotPreparedWarningSupressed,
|
|
5443
|
+
rootDirname: rootDirname,
|
|
5457
5444
|
})];
|
|
5458
5445
|
});
|
|
5459
5446
|
}); };
|
|
@@ -5475,7 +5462,7 @@ var markdownScraperMetadata = $deepFreeze({
|
|
|
5475
5462
|
mimeTypes: ['text/markdown', 'text/plain'],
|
|
5476
5463
|
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
|
|
5477
5464
|
isAvilableInBrowser: true,
|
|
5478
|
-
requiredExecutables: [
|
|
5465
|
+
requiredExecutables: [],
|
|
5479
5466
|
}); /* <- TODO: [🤛] */
|
|
5480
5467
|
/**
|
|
5481
5468
|
* Registration of known scraper metadata
|
|
@@ -5519,7 +5506,7 @@ var MarkdownScraper = /** @class */ (function () {
|
|
|
5519
5506
|
return __generator(this, function (_k) {
|
|
5520
5507
|
switch (_k.label) {
|
|
5521
5508
|
case 0:
|
|
5522
|
-
_a = this.options, _b = _a.maxParallelCount, maxParallelCount = _b === void 0 ?
|
|
5509
|
+
_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;
|
|
5523
5510
|
llm = this.tools.llm;
|
|
5524
5511
|
if (llm === undefined) {
|
|
5525
5512
|
throw new MissingToolsError('LLM tools are required for scraping external files');
|
|
@@ -5618,7 +5605,8 @@ var MarkdownScraper = /** @class */ (function () {
|
|
|
5618
5605
|
embeddingResult = _c.sent();
|
|
5619
5606
|
index.push({
|
|
5620
5607
|
modelName: embeddingResult.modelName,
|
|
5621
|
-
position: embeddingResult.content,
|
|
5608
|
+
position: __spreadArray([], __read(embeddingResult.content), false),
|
|
5609
|
+
// <- TODO: [🪓] Here should be no need for spreading new array, just `position: embeddingResult.content`
|
|
5622
5610
|
});
|
|
5623
5611
|
_c.label = 6;
|
|
5624
5612
|
case 6: return [3 /*break*/, 8];
|
|
@@ -5669,7 +5657,7 @@ var pdfScraperMetadata = $deepFreeze({
|
|
|
5669
5657
|
mimeTypes: ['application/pdf'],
|
|
5670
5658
|
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
|
|
5671
5659
|
isAvilableInBrowser: true,
|
|
5672
|
-
requiredExecutables: [
|
|
5660
|
+
requiredExecutables: [],
|
|
5673
5661
|
}); /* <- TODO: [🤛] */
|
|
5674
5662
|
/**
|
|
5675
5663
|
* Registration of known scraper metadata
|
|
@@ -5726,7 +5714,7 @@ var PdfScraper = /** @class */ (function () {
|
|
|
5726
5714
|
/*
|
|
5727
5715
|
const {
|
|
5728
5716
|
cacheDirname = SCRAPE_CACHE_DIRNAME,
|
|
5729
|
-
|
|
5717
|
+
intermediateFilesStrategy = DEFAULT_INTERMEDIATE_FILES_STRATEGY,
|
|
5730
5718
|
isVerbose = IS_VERBOSE,
|
|
5731
5719
|
} = options;
|
|
5732
5720
|
*/
|