@promptbook/pdf 0.89.0-1 → 0.89.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/esm/index.es.js +104 -79
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +4 -0
- package/esm/typings/src/_packages/types.index.d.ts +6 -4
- package/esm/typings/src/cli/cli-commands/login.d.ts +15 -0
- package/esm/typings/src/execution/PipelineExecutorResult.d.ts +2 -2
- package/esm/typings/src/execution/PromptResult.d.ts +2 -2
- package/esm/typings/src/execution/{PromptResultUsage.d.ts → Usage.d.ts} +5 -5
- package/esm/typings/src/execution/utils/addUsage.d.ts +2 -2
- package/esm/typings/src/execution/utils/computeUsageCounts.d.ts +3 -3
- package/esm/typings/src/execution/utils/usage-constants.d.ts +77 -60
- package/esm/typings/src/execution/utils/usageToHuman.d.ts +5 -5
- package/esm/typings/src/execution/utils/usageToWorktime.d.ts +5 -5
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts +3 -3
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +2 -2
- package/esm/typings/src/llm-providers/anthropic-claude/computeAnthropicClaudeUsage.d.ts +2 -2
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +0 -9
- package/esm/typings/src/llm-providers/openai/computeOpenAiUsage.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineJson/PreparationJson.d.ts +2 -2
- package/esm/typings/src/playground/BrjappConnector.d.ts +3 -0
- package/esm/typings/src/types/typeAliases.d.ts +6 -0
- package/package.json +2 -2
- package/umd/index.umd.js +105 -80
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -26,7 +26,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
26
26
|
* @generated
|
|
27
27
|
* @see https://github.com/webgptorg/promptbook
|
|
28
28
|
*/
|
|
29
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-
|
|
29
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-2';
|
|
30
30
|
/**
|
|
31
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
32
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2310,6 +2310,7 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
2310
2310
|
const { isSuccessful, errors, warnings } = executionResult;
|
|
2311
2311
|
for (const warning of warnings) {
|
|
2312
2312
|
console.warn(warning.message);
|
|
2313
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
2313
2314
|
}
|
|
2314
2315
|
if (isSuccessful === true) {
|
|
2315
2316
|
return;
|
|
@@ -2488,30 +2489,42 @@ async function forEachAsync(array, options, callbackfunction) {
|
|
|
2488
2489
|
await Promise.all(tasks);
|
|
2489
2490
|
}
|
|
2490
2491
|
|
|
2492
|
+
/**
|
|
2493
|
+
* Represents the uncertain value
|
|
2494
|
+
*
|
|
2495
|
+
* @public exported from `@promptbook/core`
|
|
2496
|
+
*/
|
|
2497
|
+
const ZERO_VALUE = $deepFreeze({ value: 0 });
|
|
2498
|
+
/**
|
|
2499
|
+
* Represents the uncertain value
|
|
2500
|
+
*
|
|
2501
|
+
* @public exported from `@promptbook/core`
|
|
2502
|
+
*/
|
|
2503
|
+
const UNCERTAIN_ZERO_VALUE = $deepFreeze({ value: 0, isUncertain: true });
|
|
2491
2504
|
/**
|
|
2492
2505
|
* Represents the usage with no resources consumed
|
|
2493
2506
|
*
|
|
2494
2507
|
* @public exported from `@promptbook/core`
|
|
2495
2508
|
*/
|
|
2496
2509
|
const ZERO_USAGE = $deepFreeze({
|
|
2497
|
-
price:
|
|
2510
|
+
price: ZERO_VALUE,
|
|
2498
2511
|
input: {
|
|
2499
|
-
tokensCount:
|
|
2500
|
-
charactersCount:
|
|
2501
|
-
wordsCount:
|
|
2502
|
-
sentencesCount:
|
|
2503
|
-
linesCount:
|
|
2504
|
-
paragraphsCount:
|
|
2505
|
-
pagesCount:
|
|
2512
|
+
tokensCount: ZERO_VALUE,
|
|
2513
|
+
charactersCount: ZERO_VALUE,
|
|
2514
|
+
wordsCount: ZERO_VALUE,
|
|
2515
|
+
sentencesCount: ZERO_VALUE,
|
|
2516
|
+
linesCount: ZERO_VALUE,
|
|
2517
|
+
paragraphsCount: ZERO_VALUE,
|
|
2518
|
+
pagesCount: ZERO_VALUE,
|
|
2506
2519
|
},
|
|
2507
2520
|
output: {
|
|
2508
|
-
tokensCount:
|
|
2509
|
-
charactersCount:
|
|
2510
|
-
wordsCount:
|
|
2511
|
-
sentencesCount:
|
|
2512
|
-
linesCount:
|
|
2513
|
-
paragraphsCount:
|
|
2514
|
-
pagesCount:
|
|
2521
|
+
tokensCount: ZERO_VALUE,
|
|
2522
|
+
charactersCount: ZERO_VALUE,
|
|
2523
|
+
wordsCount: ZERO_VALUE,
|
|
2524
|
+
sentencesCount: ZERO_VALUE,
|
|
2525
|
+
linesCount: ZERO_VALUE,
|
|
2526
|
+
paragraphsCount: ZERO_VALUE,
|
|
2527
|
+
pagesCount: ZERO_VALUE,
|
|
2515
2528
|
},
|
|
2516
2529
|
});
|
|
2517
2530
|
/**
|
|
@@ -2520,24 +2533,24 @@ const ZERO_USAGE = $deepFreeze({
|
|
|
2520
2533
|
* @public exported from `@promptbook/core`
|
|
2521
2534
|
*/
|
|
2522
2535
|
$deepFreeze({
|
|
2523
|
-
price:
|
|
2536
|
+
price: UNCERTAIN_ZERO_VALUE,
|
|
2524
2537
|
input: {
|
|
2525
|
-
tokensCount:
|
|
2526
|
-
charactersCount:
|
|
2527
|
-
wordsCount:
|
|
2528
|
-
sentencesCount:
|
|
2529
|
-
linesCount:
|
|
2530
|
-
paragraphsCount:
|
|
2531
|
-
pagesCount:
|
|
2538
|
+
tokensCount: UNCERTAIN_ZERO_VALUE,
|
|
2539
|
+
charactersCount: UNCERTAIN_ZERO_VALUE,
|
|
2540
|
+
wordsCount: UNCERTAIN_ZERO_VALUE,
|
|
2541
|
+
sentencesCount: UNCERTAIN_ZERO_VALUE,
|
|
2542
|
+
linesCount: UNCERTAIN_ZERO_VALUE,
|
|
2543
|
+
paragraphsCount: UNCERTAIN_ZERO_VALUE,
|
|
2544
|
+
pagesCount: UNCERTAIN_ZERO_VALUE,
|
|
2532
2545
|
},
|
|
2533
2546
|
output: {
|
|
2534
|
-
tokensCount:
|
|
2535
|
-
charactersCount:
|
|
2536
|
-
wordsCount:
|
|
2537
|
-
sentencesCount:
|
|
2538
|
-
linesCount:
|
|
2539
|
-
paragraphsCount:
|
|
2540
|
-
pagesCount:
|
|
2547
|
+
tokensCount: UNCERTAIN_ZERO_VALUE,
|
|
2548
|
+
charactersCount: UNCERTAIN_ZERO_VALUE,
|
|
2549
|
+
wordsCount: UNCERTAIN_ZERO_VALUE,
|
|
2550
|
+
sentencesCount: UNCERTAIN_ZERO_VALUE,
|
|
2551
|
+
linesCount: UNCERTAIN_ZERO_VALUE,
|
|
2552
|
+
paragraphsCount: UNCERTAIN_ZERO_VALUE,
|
|
2553
|
+
pagesCount: UNCERTAIN_ZERO_VALUE,
|
|
2541
2554
|
},
|
|
2542
2555
|
});
|
|
2543
2556
|
/**
|
|
@@ -2825,6 +2838,7 @@ function joinLlmExecutionTools(...llmExecutionTools) {
|
|
|
2825
2838
|
`);
|
|
2826
2839
|
// TODO: [🟥] Detect browser / node and make it colorfull
|
|
2827
2840
|
console.warn(warningMessage);
|
|
2841
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
2828
2842
|
/*
|
|
2829
2843
|
return {
|
|
2830
2844
|
async listModels() {
|
|
@@ -3382,63 +3396,73 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
3382
3396
|
const { maxParallelCount = DEFAULT_MAX_PARALLEL_COUNT, rootDirname, isVerbose = DEFAULT_IS_VERBOSE } = options;
|
|
3383
3397
|
const knowledgePreparedUnflatten = new Array(knowledgeSources.length);
|
|
3384
3398
|
await forEachAsync(knowledgeSources, { maxParallelCount }, async (knowledgeSource, index) => {
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3399
|
+
try {
|
|
3400
|
+
let partialPieces = null;
|
|
3401
|
+
const sourceHandler = await makeKnowledgeSourceHandler(knowledgeSource, tools, { rootDirname, isVerbose });
|
|
3402
|
+
const scrapers = arrayableToArray(tools.scrapers);
|
|
3403
|
+
for (const scraper of scrapers) {
|
|
3404
|
+
if (!scraper.metadata.mimeTypes.includes(sourceHandler.mimeType)
|
|
3405
|
+
// <- TODO: [🦔] Implement mime-type wildcards
|
|
3406
|
+
) {
|
|
3407
|
+
continue;
|
|
3408
|
+
}
|
|
3409
|
+
const partialPiecesUnchecked = await scraper.scrape(sourceHandler);
|
|
3410
|
+
if (partialPiecesUnchecked !== null) {
|
|
3411
|
+
partialPieces = [...partialPiecesUnchecked];
|
|
3412
|
+
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
3413
|
+
break;
|
|
3414
|
+
}
|
|
3415
|
+
console.warn(spaceTrim((block) => `
|
|
3416
|
+
Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
|
|
3402
3417
|
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3418
|
+
The source:
|
|
3419
|
+
${block(knowledgeSource.knowledgeSourceContent
|
|
3420
|
+
.split('\n')
|
|
3421
|
+
.map((line) => `> ${line}`)
|
|
3422
|
+
.join('\n'))}
|
|
3408
3423
|
|
|
3409
|
-
|
|
3424
|
+
${block($registeredScrapersMessage(scrapers))}
|
|
3410
3425
|
|
|
3411
3426
|
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3427
|
+
`));
|
|
3428
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
3429
|
+
}
|
|
3430
|
+
if (partialPieces === null) {
|
|
3431
|
+
throw new KnowledgeScrapeError(spaceTrim((block) => `
|
|
3432
|
+
Cannot scrape knowledge
|
|
3417
3433
|
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3434
|
+
The source:
|
|
3435
|
+
> ${block(knowledgeSource.knowledgeSourceContent
|
|
3436
|
+
.split('\n')
|
|
3437
|
+
.map((line) => `> ${line}`)
|
|
3438
|
+
.join('\n'))}
|
|
3423
3439
|
|
|
3424
|
-
|
|
3440
|
+
No scraper found for the mime type "${sourceHandler.mimeType}"
|
|
3425
3441
|
|
|
3426
|
-
|
|
3442
|
+
${block($registeredScrapersMessage(scrapers))}
|
|
3427
3443
|
|
|
3428
3444
|
|
|
3429
|
-
|
|
3445
|
+
`));
|
|
3446
|
+
}
|
|
3447
|
+
const pieces = partialPieces.map((partialPiece) => ({
|
|
3448
|
+
...partialPiece,
|
|
3449
|
+
sources: [
|
|
3450
|
+
{
|
|
3451
|
+
name: knowledgeSource.name,
|
|
3452
|
+
// line, column <- TODO: [☀]
|
|
3453
|
+
// <- TODO: [❎]
|
|
3454
|
+
},
|
|
3455
|
+
],
|
|
3456
|
+
}));
|
|
3457
|
+
knowledgePreparedUnflatten[index] = pieces;
|
|
3458
|
+
}
|
|
3459
|
+
catch (error) {
|
|
3460
|
+
if (!(error instanceof Error)) {
|
|
3461
|
+
throw error;
|
|
3462
|
+
}
|
|
3463
|
+
console.warn(error);
|
|
3464
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
3430
3465
|
}
|
|
3431
|
-
const pieces = partialPieces.map((partialPiece) => ({
|
|
3432
|
-
...partialPiece,
|
|
3433
|
-
sources: [
|
|
3434
|
-
{
|
|
3435
|
-
name: knowledgeSource.name,
|
|
3436
|
-
// line, column <- TODO: [☀]
|
|
3437
|
-
// <- TODO: [❎]
|
|
3438
|
-
},
|
|
3439
|
-
],
|
|
3440
|
-
}));
|
|
3441
|
-
knowledgePreparedUnflatten[index] = pieces;
|
|
3442
3466
|
});
|
|
3443
3467
|
const knowledgePrepared = knowledgePreparedUnflatten.flat();
|
|
3444
3468
|
return knowledgePrepared;
|
|
@@ -3856,7 +3880,7 @@ function extractParameterNamesFromTask(task) {
|
|
|
3856
3880
|
if (parameterNames.has(subparameterName)) {
|
|
3857
3881
|
parameterNames.delete(subparameterName);
|
|
3858
3882
|
parameterNames.add(foreach.parameterName);
|
|
3859
|
-
// <- TODO: [
|
|
3883
|
+
// <- TODO: [🏮] Warn/logic error when `subparameterName` not used
|
|
3860
3884
|
}
|
|
3861
3885
|
}
|
|
3862
3886
|
}
|
|
@@ -5452,6 +5476,7 @@ function createPipelineExecutor(options) {
|
|
|
5452
5476
|
|
|
5453
5477
|
@see more at https://ptbk.io/prepare-pipeline
|
|
5454
5478
|
`));
|
|
5479
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
5455
5480
|
}
|
|
5456
5481
|
let runCount = 0;
|
|
5457
5482
|
const pipelineExecutorWithCallback = async (inputParameters, onProgress) => {
|