@promptbook/pdf 0.92.0-24 → 0.92.0-26
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 +47 -42
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +0 -2
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +36 -28
- package/esm/typings/src/constants.d.ts +8 -2
- package/esm/typings/src/errors/0-BoilerplateError.d.ts +2 -2
- package/esm/typings/src/execution/CommonToolsOptions.d.ts +3 -3
- package/esm/typings/src/llm-providers/_common/register/$llmToolsMetadataRegister.d.ts +3 -3
- package/esm/typings/src/llm-providers/_common/register/$llmToolsRegister.d.ts +3 -3
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +4 -4
- package/esm/typings/src/llm-providers/_common/utils/cache/CacheItem.d.ts +5 -5
- package/esm/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +5 -3
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +5 -5
- package/esm/typings/src/other/templates/getBookTemplates.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineInterface/PipelineInterface.d.ts +3 -3
- package/esm/typings/src/pipeline/PipelineInterface/constants.d.ts +1 -1
- package/esm/typings/src/pipeline/PipelineInterface/getPipelineInterface.d.ts +1 -1
- package/esm/typings/src/pipeline/PipelineInterface/isPipelineImplementingInterface.d.ts +5 -4
- package/esm/typings/src/pipeline/PipelineInterface/isPipelineInterfacesEqual.d.ts +1 -1
- package/esm/typings/src/pipeline/PipelineJson/CommonTaskJson.d.ts +9 -6
- package/esm/typings/src/pipeline/PipelineJson/PipelineJson.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineString.d.ts +3 -1
- package/esm/typings/src/pipeline/book-notation.d.ts +2 -2
- package/esm/typings/src/prepare/prepareTasks.d.ts +7 -4
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +2 -1
- package/esm/typings/src/scrapers/_boilerplate/BoilerplateScraper.d.ts +3 -3
- package/esm/typings/src/scrapers/_boilerplate/createBoilerplateScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/_boilerplate/register-metadata.d.ts +1 -1
- package/esm/typings/src/scrapers/_common/Converter.d.ts +3 -1
- package/esm/typings/src/scrapers/_common/Scraper.d.ts +4 -3
- package/esm/typings/src/scrapers/_common/ScraperIntermediateSource.d.ts +4 -2
- package/esm/typings/src/scrapers/_common/register/$provideFilesystemForNode.d.ts +2 -1
- package/esm/typings/src/scrapers/_common/register/$provideScrapersForBrowser.d.ts +6 -3
- package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +3 -5
- package/esm/typings/src/scrapers/_common/register/$scrapersRegister.d.ts +3 -2
- package/esm/typings/src/scrapers/_common/register/ScraperAndConverterMetadata.d.ts +8 -5
- package/esm/typings/src/scrapers/_common/register/ScraperConstructor.d.ts +2 -1
- package/esm/typings/src/scrapers/_common/utils/getScraperIntermediateSource.d.ts +6 -5
- package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +3 -1
- package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +2 -1
- package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +4 -1
- package/esm/typings/src/scrapers/markitdown/MarkitdownScraper.d.ts +1 -1
- package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +2 -1
- package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +3 -4
- package/esm/typings/src/scripting/javascript/postprocessing-functions.d.ts +5 -1
- package/esm/typings/src/storage/file-cache-storage/FileCacheStorage.d.ts +12 -5
- package/esm/typings/src/storage/file-cache-storage/FileCacheStorageOptions.d.ts +4 -2
- package/esm/typings/src/storage/file-cache-storage/utils/nameToSubfolderPath.d.ts +2 -1
- package/esm/typings/src/storage/local-storage/utils/makePromptbookStorageFromWebStorage.d.ts +2 -1
- package/esm/typings/src/types/IntermediateFilesStrategy.d.ts +2 -1
- package/esm/typings/src/types/ModelVariant.d.ts +5 -5
- package/esm/typings/src/types/typeAliases.d.ts +8 -6
- package/esm/typings/src/utils/editable/edit-pipeline-string/addPipelineCommand.d.ts +2 -2
- package/esm/typings/src/utils/editable/edit-pipeline-string/deflatePipeline.d.ts +4 -1
- package/esm/typings/src/utils/editable/utils/isFlatPipeline.d.ts +2 -1
- package/esm/typings/src/utils/markdown/extractAllListItemsFromMarkdown.d.ts +1 -1
- package/esm/typings/src/utils/normalization/nameToUriPart.d.ts +4 -4
- package/esm/typings/src/utils/normalization/nameToUriParts.d.ts +4 -4
- package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +3 -3
- package/esm/typings/src/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +3 -3
- package/esm/typings/src/utils/normalization/normalizeTo_camelCase.d.ts +4 -4
- package/esm/typings/src/utils/normalization/normalizeTo_snake_case.d.ts +3 -3
- package/esm/typings/src/utils/normalization/removeDiacritics.d.ts +3 -3
- package/esm/typings/src/utils/normalization/searchKeywords.d.ts +4 -1
- package/esm/typings/src/utils/normalization/titleToName.d.ts +4 -4
- package/esm/typings/src/utils/organization/empty_object.d.ts +2 -2
- package/esm/typings/src/utils/organization/just_empty_object.d.ts +4 -4
- package/esm/typings/src/version.d.ts +2 -1
- package/package.json +2 -2
- package/umd/index.umd.js +47 -42
- 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.92.0-
|
|
29
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-26';
|
|
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
|
|
@@ -370,7 +370,8 @@ async function isFileExisting(filename, fs) {
|
|
|
370
370
|
*/
|
|
371
371
|
|
|
372
372
|
/**
|
|
373
|
-
*
|
|
373
|
+
* Converts a name to a properly formatted subfolder path for cache storage.
|
|
374
|
+
* Handles normalization and path formatting to create consistent cache directory structures.
|
|
374
375
|
*
|
|
375
376
|
* @private for `FileCacheStorage`
|
|
376
377
|
*/
|
|
@@ -623,10 +624,10 @@ for (let i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
|
|
|
623
624
|
*/
|
|
624
625
|
|
|
625
626
|
/**
|
|
626
|
-
*
|
|
627
|
+
* Removes diacritic marks (accents) from characters in a string.
|
|
627
628
|
*
|
|
628
|
-
* @param input
|
|
629
|
-
* @returns
|
|
629
|
+
* @param input The string containing diacritics to be normalized.
|
|
630
|
+
* @returns The string with diacritics removed or normalized.
|
|
630
631
|
* @public exported from `@promptbook/utils`
|
|
631
632
|
*/
|
|
632
633
|
function removeDiacritics(input) {
|
|
@@ -640,10 +641,10 @@ function removeDiacritics(input) {
|
|
|
640
641
|
*/
|
|
641
642
|
|
|
642
643
|
/**
|
|
643
|
-
*
|
|
644
|
+
* Converts a given text to kebab-case format.
|
|
644
645
|
*
|
|
645
|
-
* @param text
|
|
646
|
-
* @returns
|
|
646
|
+
* @param text The text to be converted.
|
|
647
|
+
* @returns The kebab-case formatted string.
|
|
647
648
|
* @example 'hello-world'
|
|
648
649
|
* @example 'i-love-promptbook'
|
|
649
650
|
* @public exported from `@promptbook/utils`
|
|
@@ -785,11 +786,11 @@ function isValidUrl(url) {
|
|
|
785
786
|
}
|
|
786
787
|
|
|
787
788
|
/**
|
|
788
|
-
*
|
|
789
|
+
* Converts a title string into a normalized name.
|
|
789
790
|
*
|
|
790
|
-
* @param value
|
|
791
|
-
* @returns
|
|
792
|
-
* @example
|
|
791
|
+
* @param value The title string to be converted to a name.
|
|
792
|
+
* @returns A normalized name derived from the input title.
|
|
793
|
+
* @example 'Hello World!' -> 'hello-world'
|
|
793
794
|
* @public exported from `@promptbook/utils`
|
|
794
795
|
*/
|
|
795
796
|
function titleToName(value) {
|
|
@@ -822,9 +823,8 @@ function TODO_USE(...value) {
|
|
|
822
823
|
}
|
|
823
824
|
|
|
824
825
|
/**
|
|
825
|
-
*
|
|
826
|
-
*
|
|
827
|
-
* Note: It also checks if directory exists and creates it if not
|
|
826
|
+
* Retrieves an intermediate source for a scraper based on the knowledge source.
|
|
827
|
+
* Manages the caching and retrieval of intermediate scraper results for optimized performance.
|
|
828
828
|
*
|
|
829
829
|
* @private as internal utility for scrapers
|
|
830
830
|
*/
|
|
@@ -1458,13 +1458,13 @@ const ORDER_OF_PIPELINE_JSON = [
|
|
|
1458
1458
|
*/
|
|
1459
1459
|
const REPLACING_NONCE = 'ptbkauk42kV2dzao34faw7FudQUHYPtW';
|
|
1460
1460
|
/**
|
|
1461
|
-
*
|
|
1461
|
+
* Placeholder value indicating a parameter is missing its value.
|
|
1462
1462
|
*
|
|
1463
1463
|
* @private within the repository
|
|
1464
1464
|
*/
|
|
1465
1465
|
const RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
|
|
1466
1466
|
/**
|
|
1467
|
-
*
|
|
1467
|
+
* Placeholder value indicating a parameter is restricted and cannot be used directly.
|
|
1468
1468
|
*
|
|
1469
1469
|
* @private within the repository
|
|
1470
1470
|
*/
|
|
@@ -2127,8 +2127,8 @@ class PipelineExecutionError extends Error {
|
|
|
2127
2127
|
* @public exported from `@promptbook/core`
|
|
2128
2128
|
*/
|
|
2129
2129
|
function isPipelinePrepared(pipeline) {
|
|
2130
|
-
// Note: Ignoring `pipeline.preparations`
|
|
2131
|
-
// Note: Ignoring `pipeline.knowledgePieces`
|
|
2130
|
+
// Note: Ignoring `pipeline.preparations`
|
|
2131
|
+
// Note: Ignoring `pipeline.knowledgePieces`
|
|
2132
2132
|
if (pipeline.title === undefined || pipeline.title === '' || pipeline.title === DEFAULT_BOOK_TITLE) {
|
|
2133
2133
|
// TODO: !!! Comment this out
|
|
2134
2134
|
console.log('Pipeline is not prepared because title is undefined or empty', pipeline);
|
|
@@ -3112,10 +3112,10 @@ function $getGlobalScope() {
|
|
|
3112
3112
|
}
|
|
3113
3113
|
|
|
3114
3114
|
/**
|
|
3115
|
-
*
|
|
3115
|
+
* Normalizes a text string to SCREAMING_CASE (all uppercase with underscores).
|
|
3116
3116
|
*
|
|
3117
|
-
* @param text
|
|
3118
|
-
* @returns
|
|
3117
|
+
* @param text The text string to be converted to SCREAMING_CASE format.
|
|
3118
|
+
* @returns The normalized text in SCREAMING_CASE format.
|
|
3119
3119
|
* @example 'HELLO_WORLD'
|
|
3120
3120
|
* @example 'I_LOVE_PROMPTBOOK'
|
|
3121
3121
|
* @public exported from `@promptbook/utils`
|
|
@@ -3167,10 +3167,10 @@ function normalizeTo_SCREAMING_CASE(text) {
|
|
|
3167
3167
|
*/
|
|
3168
3168
|
|
|
3169
3169
|
/**
|
|
3170
|
-
*
|
|
3170
|
+
* Normalizes a text string to snake_case format.
|
|
3171
3171
|
*
|
|
3172
|
-
* @param text
|
|
3173
|
-
* @returns
|
|
3172
|
+
* @param text The text string to be converted to snake_case format.
|
|
3173
|
+
* @returns The normalized text in snake_case format.
|
|
3174
3174
|
* @example 'hello_world'
|
|
3175
3175
|
* @example 'i_love_promptbook'
|
|
3176
3176
|
* @public exported from `@promptbook/utils`
|
|
@@ -3240,10 +3240,11 @@ const $scrapersMetadataRegister = new $Register('scrapers_metadata');
|
|
|
3240
3240
|
*/
|
|
3241
3241
|
|
|
3242
3242
|
/**
|
|
3243
|
-
*
|
|
3243
|
+
* Registry for all available scrapers in the system.
|
|
3244
|
+
* Central point for registering and accessing different types of content scrapers.
|
|
3244
3245
|
*
|
|
3245
3246
|
* Note: `$` is used to indicate that this interacts with the global scope
|
|
3246
|
-
* @singleton Only one instance of each register is created per build, but
|
|
3247
|
+
* @singleton Only one instance of each register is created per build, but there can be more than one in different build modules
|
|
3247
3248
|
* @public exported from `@promptbook/core`
|
|
3248
3249
|
*/
|
|
3249
3250
|
const $scrapersRegister = new $Register('scraper_constructors');
|
|
@@ -3421,7 +3422,9 @@ const promptbookFetch = async (urlOrRequest, init) => {
|
|
|
3421
3422
|
*/
|
|
3422
3423
|
|
|
3423
3424
|
/**
|
|
3424
|
-
*
|
|
3425
|
+
* Factory function that creates a handler for processing knowledge sources.
|
|
3426
|
+
* Provides standardized processing of different types of knowledge sources
|
|
3427
|
+
* across various scraper implementations.
|
|
3425
3428
|
*
|
|
3426
3429
|
* @public exported from `@promptbook/core`
|
|
3427
3430
|
*/
|
|
@@ -3662,9 +3665,12 @@ TODO: [🧊] This is how it can look in future
|
|
|
3662
3665
|
*/
|
|
3663
3666
|
|
|
3664
3667
|
/**
|
|
3665
|
-
*
|
|
3668
|
+
* Prepares tasks by adding knowledge to the prompt and ensuring all necessary parameters are included.
|
|
3666
3669
|
*
|
|
3667
|
-
* @
|
|
3670
|
+
* @param tasks Sequence of tasks that are chained together to form a pipeline
|
|
3671
|
+
* @returns A promise that resolves to the prepared tasks.
|
|
3672
|
+
*
|
|
3673
|
+
* @private internal utility of `preparePipeline`
|
|
3668
3674
|
*/
|
|
3669
3675
|
async function prepareTasks(pipeline, tools, options) {
|
|
3670
3676
|
const { maxParallelCount = DEFAULT_MAX_PARALLEL_COUNT } = options;
|
|
@@ -4427,7 +4433,7 @@ function mapAvailableToExpectedParameters(options) {
|
|
|
4427
4433
|
else if (!availableParametersNames.has(parameterName) && expectedParameterNames.has(parameterName)) ;
|
|
4428
4434
|
}
|
|
4429
4435
|
if (expectedParameterNames.size === 0) {
|
|
4430
|
-
// Note: [👨👨👧] Now we can freeze `mappedParameters` to prevent
|
|
4436
|
+
// Note: [👨👨👧] Now we can freeze `mappedParameters` to prevent accidental modifications after mapping
|
|
4431
4437
|
Object.freeze(mappedParameters);
|
|
4432
4438
|
return mappedParameters;
|
|
4433
4439
|
}
|
|
@@ -4458,7 +4464,7 @@ function mapAvailableToExpectedParameters(options) {
|
|
|
4458
4464
|
for (let i = 0; i < expectedParameterNames.size; i++) {
|
|
4459
4465
|
mappedParameters[expectedParameterNamesArray[i]] = availableParameters[availableParametersNamesArray[i]];
|
|
4460
4466
|
}
|
|
4461
|
-
// Note: [👨👨👧] Now we can freeze `mappedParameters` to prevent
|
|
4467
|
+
// Note: [👨👨👧] Now we can freeze `mappedParameters` to prevent accidental modifications after mapping
|
|
4462
4468
|
Object.freeze(mappedParameters);
|
|
4463
4469
|
return mappedParameters;
|
|
4464
4470
|
}
|
|
@@ -5211,11 +5217,10 @@ async function executeFormatSubvalues(options) {
|
|
|
5211
5217
|
const highLevelError = new PipelineExecutionError(spaceTrim((block) => `
|
|
5212
5218
|
${error.message}
|
|
5213
5219
|
|
|
5214
|
-
This is error in FOREACH command when mapping data
|
|
5220
|
+
This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
5215
5221
|
You have probbably passed wrong data to pipeline or wrong data was generated which are processed by FOREACH command
|
|
5216
5222
|
|
|
5217
5223
|
${block(pipelineIdentification)}
|
|
5218
|
-
Subparameter index: ${index}
|
|
5219
5224
|
`));
|
|
5220
5225
|
if (length > BIG_DATASET_TRESHOLD) {
|
|
5221
5226
|
console.error(highLevelError);
|
|
@@ -5243,12 +5248,11 @@ async function executeFormatSubvalues(options) {
|
|
|
5243
5248
|
catch (error) {
|
|
5244
5249
|
if (length > BIG_DATASET_TRESHOLD) {
|
|
5245
5250
|
console.error(spaceTrim((block) => `
|
|
5246
|
-
|
|
5251
|
+
${error.message}
|
|
5247
5252
|
|
|
5248
|
-
${
|
|
5253
|
+
This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
5249
5254
|
|
|
5250
5255
|
${block(pipelineIdentification)}
|
|
5251
|
-
Subparameter index: ${index}
|
|
5252
5256
|
`));
|
|
5253
5257
|
return FAILED_VALUE_PLACEHOLDER;
|
|
5254
5258
|
}
|
|
@@ -6166,8 +6170,8 @@ class MarkitdownScraper {
|
|
|
6166
6170
|
extension: 'md',
|
|
6167
6171
|
isVerbose,
|
|
6168
6172
|
});
|
|
6169
|
-
// TODO:
|
|
6170
|
-
// Note: Running
|
|
6173
|
+
// TODO: Determine if Markitdown conversion should run only if the cache file doesn't exist, or always.
|
|
6174
|
+
// Note: Running Markitdown conversion ONLY if the file in the cache does not exist
|
|
6171
6175
|
if (!(await isFileExisting(cacheFilehandler.filename, this.tools.fs))) {
|
|
6172
6176
|
const src = source.filename || source.url || null;
|
|
6173
6177
|
// console.log('!!', { src, source, cacheFilehandler });
|
|
@@ -6189,11 +6193,11 @@ class MarkitdownScraper {
|
|
|
6189
6193
|
return cacheFilehandler;
|
|
6190
6194
|
}
|
|
6191
6195
|
/**
|
|
6192
|
-
* Scrapes the
|
|
6196
|
+
* Scrapes the source document (PDF, DOCX, etc.) and returns the knowledge pieces or `null` if it can't scrape it.
|
|
6193
6197
|
*/
|
|
6194
6198
|
async scrape(source) {
|
|
6195
6199
|
const cacheFilehandler = await this.$convert(source);
|
|
6196
|
-
// TODO:
|
|
6200
|
+
// TODO: Ensure this correctly creates the source object for the internal MarkdownScraper using the converted file.
|
|
6197
6201
|
const markdownSource = {
|
|
6198
6202
|
source: source.source,
|
|
6199
6203
|
filename: cacheFilehandler.filename,
|
|
@@ -6337,7 +6341,8 @@ class PdfScraper {
|
|
|
6337
6341
|
*/
|
|
6338
6342
|
|
|
6339
6343
|
/**
|
|
6340
|
-
*
|
|
6344
|
+
* Factory function to create an instance of PdfScraper.
|
|
6345
|
+
* It bundles the scraper class with its metadata.
|
|
6341
6346
|
*
|
|
6342
6347
|
* @public exported from `@promptbook/pdf`
|
|
6343
6348
|
*/
|