@promptbook/markitdown 0.88.0-10 โ 0.88.0-12
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 +6 -1
- package/esm/index.es.js +51 -22
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/config.d.ts +1 -1
- package/esm/typings/src/errors/PipelineExecutionError.d.ts +5 -0
- package/esm/typings/src/errors/utils/ErrorJson.d.ts +5 -0
- package/esm/typings/src/utils/expectation-counters/countCharacters.d.ts +3 -0
- package/esm/typings/src/utils/expectation-counters/countLines.d.ts +3 -0
- package/esm/typings/src/utils/expectation-counters/countPages.d.ts +3 -0
- package/esm/typings/src/utils/expectation-counters/countParagraphs.d.ts +3 -0
- package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +3 -0
- package/esm/typings/src/utils/expectation-counters/countWords.d.ts +3 -0
- package/package.json +2 -2
- package/umd/index.umd.js +54 -25
- package/umd/index.umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -68,6 +68,9 @@ This shift is going to happen, whether we are ready for it or not. Our mission i
|
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
71
74
|
## ๐ Get started
|
|
72
75
|
|
|
73
76
|
Take a look at the simple starter kit with books integrated into the **Hello World** sample applications:
|
|
@@ -79,6 +82,8 @@ Take a look at the simple starter kit with books integrated into the **Hello Wor
|
|
|
79
82
|
|
|
80
83
|
|
|
81
84
|
|
|
85
|
+
|
|
86
|
+
|
|
82
87
|
## ๐ The Promptbook Project
|
|
83
88
|
|
|
84
89
|
Promptbook project is ecosystem of multiple projects and tools, following is a list of most important pieces of the project:
|
|
@@ -396,7 +401,7 @@ See [TODO.md](./TODO.md)
|
|
|
396
401
|
<a href="https://technologickainkubace.org/en/about-technology-incubation/about-the-project/">
|
|
397
402
|
<img src="./other/partners/CI-Technology-Incubation.png" alt="Technology Incubation" height="70">
|
|
398
403
|
</a>
|
|
399
|
-
|
|
404
|
+
|
|
400
405
|
</div>
|
|
401
406
|
|
|
402
407
|
## ๐๏ธ Contributing
|
package/esm/index.es.js
CHANGED
|
@@ -5,8 +5,8 @@ import hexEncoder from 'crypto-js/enc-hex';
|
|
|
5
5
|
import { basename, join, dirname } from 'path';
|
|
6
6
|
import { format } from 'prettier';
|
|
7
7
|
import parserHtml from 'prettier/parser-html';
|
|
8
|
-
import { Subject } from 'rxjs';
|
|
9
8
|
import { randomBytes } from 'crypto';
|
|
9
|
+
import { Subject } from 'rxjs';
|
|
10
10
|
import { forTime } from 'waitasecond';
|
|
11
11
|
import sha256 from 'crypto-js/sha256';
|
|
12
12
|
import { lookup, extension } from 'mime-types';
|
|
@@ -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.88.0-
|
|
29
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.88.0-12';
|
|
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
|
|
@@ -158,7 +158,7 @@ const DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [๐คนโโ๏ธ]
|
|
|
158
158
|
*
|
|
159
159
|
* @public exported from `@promptbook/core`
|
|
160
160
|
*/
|
|
161
|
-
const DEFAULT_MAX_EXECUTION_ATTEMPTS =
|
|
161
|
+
const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [๐คนโโ๏ธ]
|
|
162
162
|
// <- TODO: [๐] Make also `BOOKS_DIRNAME_ALTERNATIVES`
|
|
163
163
|
/**
|
|
164
164
|
* Where to store the temporary downloads
|
|
@@ -2003,6 +2003,21 @@ class MissingToolsError extends Error {
|
|
|
2003
2003
|
}
|
|
2004
2004
|
}
|
|
2005
2005
|
|
|
2006
|
+
/**
|
|
2007
|
+
* Generates random token
|
|
2008
|
+
*
|
|
2009
|
+
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
2010
|
+
*
|
|
2011
|
+
* @private internal helper function
|
|
2012
|
+
* @returns secure random token
|
|
2013
|
+
*/
|
|
2014
|
+
function $randomToken(randomness) {
|
|
2015
|
+
return randomBytes(randomness).toString('hex');
|
|
2016
|
+
}
|
|
2017
|
+
/**
|
|
2018
|
+
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
2019
|
+
*/
|
|
2020
|
+
|
|
2006
2021
|
/**
|
|
2007
2022
|
* This error indicates errors during the execution of the pipeline
|
|
2008
2023
|
*
|
|
@@ -2010,11 +2025,17 @@ class MissingToolsError extends Error {
|
|
|
2010
2025
|
*/
|
|
2011
2026
|
class PipelineExecutionError extends Error {
|
|
2012
2027
|
constructor(message) {
|
|
2028
|
+
// Added id parameter
|
|
2013
2029
|
super(message);
|
|
2014
2030
|
this.name = 'PipelineExecutionError';
|
|
2031
|
+
// TODO: [๐] DRY - Maybe $randomId
|
|
2032
|
+
this.id = `error-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
2015
2033
|
Object.setPrototypeOf(this, PipelineExecutionError.prototype);
|
|
2016
2034
|
}
|
|
2017
2035
|
}
|
|
2036
|
+
/**
|
|
2037
|
+
* TODO: !!!!!! Add id to all errors
|
|
2038
|
+
*/
|
|
2018
2039
|
|
|
2019
2040
|
/**
|
|
2020
2041
|
* Determine if the pipeline is fully prepared
|
|
@@ -2053,21 +2074,6 @@ function isPipelinePrepared(pipeline) {
|
|
|
2053
2074
|
* - [โจ] Are tasks prepared
|
|
2054
2075
|
*/
|
|
2055
2076
|
|
|
2056
|
-
/**
|
|
2057
|
-
* Generates random token
|
|
2058
|
-
*
|
|
2059
|
-
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
2060
|
-
*
|
|
2061
|
-
* @private internal helper function
|
|
2062
|
-
* @returns secure random token
|
|
2063
|
-
*/
|
|
2064
|
-
function $randomToken(randomness) {
|
|
2065
|
-
return randomBytes(randomness).toString('hex');
|
|
2066
|
-
}
|
|
2067
|
-
/**
|
|
2068
|
-
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
2069
|
-
*/
|
|
2070
|
-
|
|
2071
2077
|
/**
|
|
2072
2078
|
* Recursively converts JSON strings to JSON objects
|
|
2073
2079
|
|
|
@@ -2258,7 +2264,7 @@ const ALL_ERRORS = {
|
|
|
2258
2264
|
* @public exported from `@promptbook/utils`
|
|
2259
2265
|
*/
|
|
2260
2266
|
function deserializeError(error) {
|
|
2261
|
-
const { name, stack } = error;
|
|
2267
|
+
const { name, stack, id } = error; // Added id
|
|
2262
2268
|
let { message } = error;
|
|
2263
2269
|
let ErrorClass = ALL_ERRORS[error.name];
|
|
2264
2270
|
if (ErrorClass === undefined) {
|
|
@@ -2273,7 +2279,9 @@ function deserializeError(error) {
|
|
|
2273
2279
|
${block(stack || '')}
|
|
2274
2280
|
`);
|
|
2275
2281
|
}
|
|
2276
|
-
|
|
2282
|
+
const deserializedError = new ErrorClass(message);
|
|
2283
|
+
deserializedError.id = id; // Assign id to the error object
|
|
2284
|
+
return deserializedError;
|
|
2277
2285
|
}
|
|
2278
2286
|
|
|
2279
2287
|
/**
|
|
@@ -2323,6 +2331,7 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
2323
2331
|
*/
|
|
2324
2332
|
function createTask(options) {
|
|
2325
2333
|
const { taskType, taskProcessCallback } = options;
|
|
2334
|
+
// TODO: [๐] DRY
|
|
2326
2335
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
2327
2336
|
let status = 'RUNNING';
|
|
2328
2337
|
const createdAt = new Date();
|
|
@@ -2419,19 +2428,21 @@ function createTask(options) {
|
|
|
2419
2428
|
*/
|
|
2420
2429
|
function serializeError(error) {
|
|
2421
2430
|
const { name, message, stack } = error;
|
|
2431
|
+
const { id } = error;
|
|
2422
2432
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
2423
2433
|
console.error(spaceTrim((block) => `
|
|
2424
|
-
|
|
2434
|
+
|
|
2425
2435
|
Cannot serialize error with name "${name}"
|
|
2426
2436
|
|
|
2427
2437
|
${block(stack || message)}
|
|
2428
|
-
|
|
2438
|
+
|
|
2429
2439
|
`));
|
|
2430
2440
|
}
|
|
2431
2441
|
return {
|
|
2432
2442
|
name: name,
|
|
2433
2443
|
message,
|
|
2434
2444
|
stack,
|
|
2445
|
+
id, // Include id in the serialized object
|
|
2435
2446
|
};
|
|
2436
2447
|
}
|
|
2437
2448
|
|
|
@@ -4343,6 +4354,9 @@ function countCharacters(text) {
|
|
|
4343
4354
|
text = text.replace(/\p{Extended_Pictographic}(\u{200D}\p{Extended_Pictographic})*/gu, '-');
|
|
4344
4355
|
return text.length;
|
|
4345
4356
|
}
|
|
4357
|
+
/**
|
|
4358
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
4359
|
+
*/
|
|
4346
4360
|
|
|
4347
4361
|
/**
|
|
4348
4362
|
* Number of characters per standard line with 11pt Arial font size.
|
|
@@ -4374,6 +4388,9 @@ function countLines(text) {
|
|
|
4374
4388
|
const lines = text.split('\n');
|
|
4375
4389
|
return lines.reduce((count, line) => count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 0);
|
|
4376
4390
|
}
|
|
4391
|
+
/**
|
|
4392
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
4393
|
+
*/
|
|
4377
4394
|
|
|
4378
4395
|
/**
|
|
4379
4396
|
* Counts number of pages in the text
|
|
@@ -4385,6 +4402,9 @@ function countLines(text) {
|
|
|
4385
4402
|
function countPages(text) {
|
|
4386
4403
|
return Math.ceil(countLines(text) / LINES_PER_STANDARD_PAGE);
|
|
4387
4404
|
}
|
|
4405
|
+
/**
|
|
4406
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
4407
|
+
*/
|
|
4388
4408
|
|
|
4389
4409
|
/**
|
|
4390
4410
|
* Counts number of paragraphs in the text
|
|
@@ -4394,6 +4414,9 @@ function countPages(text) {
|
|
|
4394
4414
|
function countParagraphs(text) {
|
|
4395
4415
|
return text.split(/\n\s*\n/).filter((paragraph) => paragraph.trim() !== '').length;
|
|
4396
4416
|
}
|
|
4417
|
+
/**
|
|
4418
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
4419
|
+
*/
|
|
4397
4420
|
|
|
4398
4421
|
/**
|
|
4399
4422
|
* Split text into sentences
|
|
@@ -4411,6 +4434,9 @@ function splitIntoSentences(text) {
|
|
|
4411
4434
|
function countSentences(text) {
|
|
4412
4435
|
return splitIntoSentences(text).length;
|
|
4413
4436
|
}
|
|
4437
|
+
/**
|
|
4438
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
4439
|
+
*/
|
|
4414
4440
|
|
|
4415
4441
|
/**
|
|
4416
4442
|
* Counts number of words in the text
|
|
@@ -4424,6 +4450,9 @@ function countWords(text) {
|
|
|
4424
4450
|
text = text.replace(/([a-z])([A-Z])/g, '$1 $2');
|
|
4425
4451
|
return text.split(/[^a-zะฐ-ั0-9]+/i).filter((word) => word.length > 0).length;
|
|
4426
4452
|
}
|
|
4453
|
+
/**
|
|
4454
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
4455
|
+
*/
|
|
4427
4456
|
|
|
4428
4457
|
/**
|
|
4429
4458
|
* Index of all counter functions
|