@promptbook/website-crawler 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
|
@@ -29,7 +29,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
29
29
|
* @generated
|
|
30
30
|
* @see https://github.com/webgptorg/promptbook
|
|
31
31
|
*/
|
|
32
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-
|
|
32
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-2';
|
|
33
33
|
/**
|
|
34
34
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
35
35
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2425,6 +2425,7 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
2425
2425
|
const { isSuccessful, errors, warnings } = executionResult;
|
|
2426
2426
|
for (const warning of warnings) {
|
|
2427
2427
|
console.warn(warning.message);
|
|
2428
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
2428
2429
|
}
|
|
2429
2430
|
if (isSuccessful === true) {
|
|
2430
2431
|
return;
|
|
@@ -2603,30 +2604,42 @@ async function forEachAsync(array, options, callbackfunction) {
|
|
|
2603
2604
|
await Promise.all(tasks);
|
|
2604
2605
|
}
|
|
2605
2606
|
|
|
2607
|
+
/**
|
|
2608
|
+
* Represents the uncertain value
|
|
2609
|
+
*
|
|
2610
|
+
* @public exported from `@promptbook/core`
|
|
2611
|
+
*/
|
|
2612
|
+
const ZERO_VALUE = $deepFreeze({ value: 0 });
|
|
2613
|
+
/**
|
|
2614
|
+
* Represents the uncertain value
|
|
2615
|
+
*
|
|
2616
|
+
* @public exported from `@promptbook/core`
|
|
2617
|
+
*/
|
|
2618
|
+
const UNCERTAIN_ZERO_VALUE = $deepFreeze({ value: 0, isUncertain: true });
|
|
2606
2619
|
/**
|
|
2607
2620
|
* Represents the usage with no resources consumed
|
|
2608
2621
|
*
|
|
2609
2622
|
* @public exported from `@promptbook/core`
|
|
2610
2623
|
*/
|
|
2611
2624
|
const ZERO_USAGE = $deepFreeze({
|
|
2612
|
-
price:
|
|
2625
|
+
price: ZERO_VALUE,
|
|
2613
2626
|
input: {
|
|
2614
|
-
tokensCount:
|
|
2615
|
-
charactersCount:
|
|
2616
|
-
wordsCount:
|
|
2617
|
-
sentencesCount:
|
|
2618
|
-
linesCount:
|
|
2619
|
-
paragraphsCount:
|
|
2620
|
-
pagesCount:
|
|
2627
|
+
tokensCount: ZERO_VALUE,
|
|
2628
|
+
charactersCount: ZERO_VALUE,
|
|
2629
|
+
wordsCount: ZERO_VALUE,
|
|
2630
|
+
sentencesCount: ZERO_VALUE,
|
|
2631
|
+
linesCount: ZERO_VALUE,
|
|
2632
|
+
paragraphsCount: ZERO_VALUE,
|
|
2633
|
+
pagesCount: ZERO_VALUE,
|
|
2621
2634
|
},
|
|
2622
2635
|
output: {
|
|
2623
|
-
tokensCount:
|
|
2624
|
-
charactersCount:
|
|
2625
|
-
wordsCount:
|
|
2626
|
-
sentencesCount:
|
|
2627
|
-
linesCount:
|
|
2628
|
-
paragraphsCount:
|
|
2629
|
-
pagesCount:
|
|
2636
|
+
tokensCount: ZERO_VALUE,
|
|
2637
|
+
charactersCount: ZERO_VALUE,
|
|
2638
|
+
wordsCount: ZERO_VALUE,
|
|
2639
|
+
sentencesCount: ZERO_VALUE,
|
|
2640
|
+
linesCount: ZERO_VALUE,
|
|
2641
|
+
paragraphsCount: ZERO_VALUE,
|
|
2642
|
+
pagesCount: ZERO_VALUE,
|
|
2630
2643
|
},
|
|
2631
2644
|
});
|
|
2632
2645
|
/**
|
|
@@ -2635,24 +2648,24 @@ const ZERO_USAGE = $deepFreeze({
|
|
|
2635
2648
|
* @public exported from `@promptbook/core`
|
|
2636
2649
|
*/
|
|
2637
2650
|
$deepFreeze({
|
|
2638
|
-
price:
|
|
2651
|
+
price: UNCERTAIN_ZERO_VALUE,
|
|
2639
2652
|
input: {
|
|
2640
|
-
tokensCount:
|
|
2641
|
-
charactersCount:
|
|
2642
|
-
wordsCount:
|
|
2643
|
-
sentencesCount:
|
|
2644
|
-
linesCount:
|
|
2645
|
-
paragraphsCount:
|
|
2646
|
-
pagesCount:
|
|
2653
|
+
tokensCount: UNCERTAIN_ZERO_VALUE,
|
|
2654
|
+
charactersCount: UNCERTAIN_ZERO_VALUE,
|
|
2655
|
+
wordsCount: UNCERTAIN_ZERO_VALUE,
|
|
2656
|
+
sentencesCount: UNCERTAIN_ZERO_VALUE,
|
|
2657
|
+
linesCount: UNCERTAIN_ZERO_VALUE,
|
|
2658
|
+
paragraphsCount: UNCERTAIN_ZERO_VALUE,
|
|
2659
|
+
pagesCount: UNCERTAIN_ZERO_VALUE,
|
|
2647
2660
|
},
|
|
2648
2661
|
output: {
|
|
2649
|
-
tokensCount:
|
|
2650
|
-
charactersCount:
|
|
2651
|
-
wordsCount:
|
|
2652
|
-
sentencesCount:
|
|
2653
|
-
linesCount:
|
|
2654
|
-
paragraphsCount:
|
|
2655
|
-
pagesCount:
|
|
2662
|
+
tokensCount: UNCERTAIN_ZERO_VALUE,
|
|
2663
|
+
charactersCount: UNCERTAIN_ZERO_VALUE,
|
|
2664
|
+
wordsCount: UNCERTAIN_ZERO_VALUE,
|
|
2665
|
+
sentencesCount: UNCERTAIN_ZERO_VALUE,
|
|
2666
|
+
linesCount: UNCERTAIN_ZERO_VALUE,
|
|
2667
|
+
paragraphsCount: UNCERTAIN_ZERO_VALUE,
|
|
2668
|
+
pagesCount: UNCERTAIN_ZERO_VALUE,
|
|
2656
2669
|
},
|
|
2657
2670
|
});
|
|
2658
2671
|
/**
|
|
@@ -2940,6 +2953,7 @@ function joinLlmExecutionTools(...llmExecutionTools) {
|
|
|
2940
2953
|
`);
|
|
2941
2954
|
// TODO: [🟥] Detect browser / node and make it colorfull
|
|
2942
2955
|
console.warn(warningMessage);
|
|
2956
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
2943
2957
|
/*
|
|
2944
2958
|
return {
|
|
2945
2959
|
async listModels() {
|
|
@@ -3383,63 +3397,73 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
3383
3397
|
const { maxParallelCount = DEFAULT_MAX_PARALLEL_COUNT, rootDirname, isVerbose = DEFAULT_IS_VERBOSE } = options;
|
|
3384
3398
|
const knowledgePreparedUnflatten = new Array(knowledgeSources.length);
|
|
3385
3399
|
await forEachAsync(knowledgeSources, { maxParallelCount }, async (knowledgeSource, index) => {
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3400
|
+
try {
|
|
3401
|
+
let partialPieces = null;
|
|
3402
|
+
const sourceHandler = await makeKnowledgeSourceHandler(knowledgeSource, tools, { rootDirname, isVerbose });
|
|
3403
|
+
const scrapers = arrayableToArray(tools.scrapers);
|
|
3404
|
+
for (const scraper of scrapers) {
|
|
3405
|
+
if (!scraper.metadata.mimeTypes.includes(sourceHandler.mimeType)
|
|
3406
|
+
// <- TODO: [🦔] Implement mime-type wildcards
|
|
3407
|
+
) {
|
|
3408
|
+
continue;
|
|
3409
|
+
}
|
|
3410
|
+
const partialPiecesUnchecked = await scraper.scrape(sourceHandler);
|
|
3411
|
+
if (partialPiecesUnchecked !== null) {
|
|
3412
|
+
partialPieces = [...partialPiecesUnchecked];
|
|
3413
|
+
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
3414
|
+
break;
|
|
3415
|
+
}
|
|
3416
|
+
console.warn(spaceTrim$1((block) => `
|
|
3417
|
+
Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
|
|
3403
3418
|
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3419
|
+
The source:
|
|
3420
|
+
${block(knowledgeSource.knowledgeSourceContent
|
|
3421
|
+
.split('\n')
|
|
3422
|
+
.map((line) => `> ${line}`)
|
|
3423
|
+
.join('\n'))}
|
|
3409
3424
|
|
|
3410
|
-
|
|
3425
|
+
${block($registeredScrapersMessage(scrapers))}
|
|
3411
3426
|
|
|
3412
3427
|
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3428
|
+
`));
|
|
3429
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
3430
|
+
}
|
|
3431
|
+
if (partialPieces === null) {
|
|
3432
|
+
throw new KnowledgeScrapeError(spaceTrim$1((block) => `
|
|
3433
|
+
Cannot scrape knowledge
|
|
3418
3434
|
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3435
|
+
The source:
|
|
3436
|
+
> ${block(knowledgeSource.knowledgeSourceContent
|
|
3437
|
+
.split('\n')
|
|
3438
|
+
.map((line) => `> ${line}`)
|
|
3439
|
+
.join('\n'))}
|
|
3424
3440
|
|
|
3425
|
-
|
|
3441
|
+
No scraper found for the mime type "${sourceHandler.mimeType}"
|
|
3426
3442
|
|
|
3427
|
-
|
|
3443
|
+
${block($registeredScrapersMessage(scrapers))}
|
|
3428
3444
|
|
|
3429
3445
|
|
|
3430
|
-
|
|
3446
|
+
`));
|
|
3447
|
+
}
|
|
3448
|
+
const pieces = partialPieces.map((partialPiece) => ({
|
|
3449
|
+
...partialPiece,
|
|
3450
|
+
sources: [
|
|
3451
|
+
{
|
|
3452
|
+
name: knowledgeSource.name,
|
|
3453
|
+
// line, column <- TODO: [☀]
|
|
3454
|
+
// <- TODO: [❎]
|
|
3455
|
+
},
|
|
3456
|
+
],
|
|
3457
|
+
}));
|
|
3458
|
+
knowledgePreparedUnflatten[index] = pieces;
|
|
3459
|
+
}
|
|
3460
|
+
catch (error) {
|
|
3461
|
+
if (!(error instanceof Error)) {
|
|
3462
|
+
throw error;
|
|
3463
|
+
}
|
|
3464
|
+
console.warn(error);
|
|
3465
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
3431
3466
|
}
|
|
3432
|
-
const pieces = partialPieces.map((partialPiece) => ({
|
|
3433
|
-
...partialPiece,
|
|
3434
|
-
sources: [
|
|
3435
|
-
{
|
|
3436
|
-
name: knowledgeSource.name,
|
|
3437
|
-
// line, column <- TODO: [☀]
|
|
3438
|
-
// <- TODO: [❎]
|
|
3439
|
-
},
|
|
3440
|
-
],
|
|
3441
|
-
}));
|
|
3442
|
-
knowledgePreparedUnflatten[index] = pieces;
|
|
3443
3467
|
});
|
|
3444
3468
|
const knowledgePrepared = knowledgePreparedUnflatten.flat();
|
|
3445
3469
|
return knowledgePrepared;
|
|
@@ -3857,7 +3881,7 @@ function extractParameterNamesFromTask(task) {
|
|
|
3857
3881
|
if (parameterNames.has(subparameterName)) {
|
|
3858
3882
|
parameterNames.delete(subparameterName);
|
|
3859
3883
|
parameterNames.add(foreach.parameterName);
|
|
3860
|
-
// <- TODO: [
|
|
3884
|
+
// <- TODO: [🏮] Warn/logic error when `subparameterName` not used
|
|
3861
3885
|
}
|
|
3862
3886
|
}
|
|
3863
3887
|
}
|
|
@@ -5453,6 +5477,7 @@ function createPipelineExecutor(options) {
|
|
|
5453
5477
|
|
|
5454
5478
|
@see more at https://ptbk.io/prepare-pipeline
|
|
5455
5479
|
`));
|
|
5480
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
5456
5481
|
}
|
|
5457
5482
|
let runCount = 0;
|
|
5458
5483
|
const pipelineExecutorWithCallback = async (inputParameters, onProgress) => {
|