@promptbook/pdf 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
|
@@ -70,6 +70,9 @@ This shift is going to happen, whether we are ready for it or not. Our mission i
|
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
73
76
|
## ๐ Get started
|
|
74
77
|
|
|
75
78
|
Take a look at the simple starter kit with books integrated into the **Hello World** sample applications:
|
|
@@ -81,6 +84,8 @@ Take a look at the simple starter kit with books integrated into the **Hello Wor
|
|
|
81
84
|
|
|
82
85
|
|
|
83
86
|
|
|
87
|
+
|
|
88
|
+
|
|
84
89
|
## ๐ The Promptbook Project
|
|
85
90
|
|
|
86
91
|
Promptbook project is ecosystem of multiple projects and tools, following is a list of most important pieces of the project:
|
|
@@ -398,7 +403,7 @@ See [TODO.md](./TODO.md)
|
|
|
398
403
|
<a href="https://technologickainkubace.org/en/about-technology-incubation/about-the-project/">
|
|
399
404
|
<img src="./other/partners/CI-Technology-Incubation.png" alt="Technology Incubation" height="70">
|
|
400
405
|
</a>
|
|
401
|
-
|
|
406
|
+
|
|
402
407
|
</div>
|
|
403
408
|
|
|
404
409
|
## ๐๏ธ 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
|
|
@@ -2016,6 +2016,21 @@ class MissingToolsError extends Error {
|
|
|
2016
2016
|
}
|
|
2017
2017
|
}
|
|
2018
2018
|
|
|
2019
|
+
/**
|
|
2020
|
+
* Generates random token
|
|
2021
|
+
*
|
|
2022
|
+
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
2023
|
+
*
|
|
2024
|
+
* @private internal helper function
|
|
2025
|
+
* @returns secure random token
|
|
2026
|
+
*/
|
|
2027
|
+
function $randomToken(randomness) {
|
|
2028
|
+
return randomBytes(randomness).toString('hex');
|
|
2029
|
+
}
|
|
2030
|
+
/**
|
|
2031
|
+
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
2032
|
+
*/
|
|
2033
|
+
|
|
2019
2034
|
/**
|
|
2020
2035
|
* This error indicates errors during the execution of the pipeline
|
|
2021
2036
|
*
|
|
@@ -2023,11 +2038,17 @@ class MissingToolsError extends Error {
|
|
|
2023
2038
|
*/
|
|
2024
2039
|
class PipelineExecutionError extends Error {
|
|
2025
2040
|
constructor(message) {
|
|
2041
|
+
// Added id parameter
|
|
2026
2042
|
super(message);
|
|
2027
2043
|
this.name = 'PipelineExecutionError';
|
|
2044
|
+
// TODO: [๐] DRY - Maybe $randomId
|
|
2045
|
+
this.id = `error-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
2028
2046
|
Object.setPrototypeOf(this, PipelineExecutionError.prototype);
|
|
2029
2047
|
}
|
|
2030
2048
|
}
|
|
2049
|
+
/**
|
|
2050
|
+
* TODO: !!!!!! Add id to all errors
|
|
2051
|
+
*/
|
|
2031
2052
|
|
|
2032
2053
|
/**
|
|
2033
2054
|
* Determine if the pipeline is fully prepared
|
|
@@ -2066,21 +2087,6 @@ function isPipelinePrepared(pipeline) {
|
|
|
2066
2087
|
* - [โจ] Are tasks prepared
|
|
2067
2088
|
*/
|
|
2068
2089
|
|
|
2069
|
-
/**
|
|
2070
|
-
* Generates random token
|
|
2071
|
-
*
|
|
2072
|
-
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
2073
|
-
*
|
|
2074
|
-
* @private internal helper function
|
|
2075
|
-
* @returns secure random token
|
|
2076
|
-
*/
|
|
2077
|
-
function $randomToken(randomness) {
|
|
2078
|
-
return randomBytes(randomness).toString('hex');
|
|
2079
|
-
}
|
|
2080
|
-
/**
|
|
2081
|
-
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
2082
|
-
*/
|
|
2083
|
-
|
|
2084
2090
|
/**
|
|
2085
2091
|
* Recursively converts JSON strings to JSON objects
|
|
2086
2092
|
|
|
@@ -2271,7 +2277,7 @@ const ALL_ERRORS = {
|
|
|
2271
2277
|
* @public exported from `@promptbook/utils`
|
|
2272
2278
|
*/
|
|
2273
2279
|
function deserializeError(error) {
|
|
2274
|
-
const { name, stack } = error;
|
|
2280
|
+
const { name, stack, id } = error; // Added id
|
|
2275
2281
|
let { message } = error;
|
|
2276
2282
|
let ErrorClass = ALL_ERRORS[error.name];
|
|
2277
2283
|
if (ErrorClass === undefined) {
|
|
@@ -2286,7 +2292,9 @@ function deserializeError(error) {
|
|
|
2286
2292
|
${block(stack || '')}
|
|
2287
2293
|
`);
|
|
2288
2294
|
}
|
|
2289
|
-
|
|
2295
|
+
const deserializedError = new ErrorClass(message);
|
|
2296
|
+
deserializedError.id = id; // Assign id to the error object
|
|
2297
|
+
return deserializedError;
|
|
2290
2298
|
}
|
|
2291
2299
|
|
|
2292
2300
|
/**
|
|
@@ -2336,6 +2344,7 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
2336
2344
|
*/
|
|
2337
2345
|
function createTask(options) {
|
|
2338
2346
|
const { taskType, taskProcessCallback } = options;
|
|
2347
|
+
// TODO: [๐] DRY
|
|
2339
2348
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
2340
2349
|
let status = 'RUNNING';
|
|
2341
2350
|
const createdAt = new Date();
|
|
@@ -2432,19 +2441,21 @@ function createTask(options) {
|
|
|
2432
2441
|
*/
|
|
2433
2442
|
function serializeError(error) {
|
|
2434
2443
|
const { name, message, stack } = error;
|
|
2444
|
+
const { id } = error;
|
|
2435
2445
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
2436
2446
|
console.error(spaceTrim((block) => `
|
|
2437
|
-
|
|
2447
|
+
|
|
2438
2448
|
Cannot serialize error with name "${name}"
|
|
2439
2449
|
|
|
2440
2450
|
${block(stack || message)}
|
|
2441
|
-
|
|
2451
|
+
|
|
2442
2452
|
`));
|
|
2443
2453
|
}
|
|
2444
2454
|
return {
|
|
2445
2455
|
name: name,
|
|
2446
2456
|
message,
|
|
2447
2457
|
stack,
|
|
2458
|
+
id, // Include id in the serialized object
|
|
2448
2459
|
};
|
|
2449
2460
|
}
|
|
2450
2461
|
|
|
@@ -4356,6 +4367,9 @@ function countCharacters(text) {
|
|
|
4356
4367
|
text = text.replace(/\p{Extended_Pictographic}(\u{200D}\p{Extended_Pictographic})*/gu, '-');
|
|
4357
4368
|
return text.length;
|
|
4358
4369
|
}
|
|
4370
|
+
/**
|
|
4371
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
4372
|
+
*/
|
|
4359
4373
|
|
|
4360
4374
|
/**
|
|
4361
4375
|
* Number of characters per standard line with 11pt Arial font size.
|
|
@@ -4387,6 +4401,9 @@ function countLines(text) {
|
|
|
4387
4401
|
const lines = text.split('\n');
|
|
4388
4402
|
return lines.reduce((count, line) => count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 0);
|
|
4389
4403
|
}
|
|
4404
|
+
/**
|
|
4405
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
4406
|
+
*/
|
|
4390
4407
|
|
|
4391
4408
|
/**
|
|
4392
4409
|
* Counts number of pages in the text
|
|
@@ -4398,6 +4415,9 @@ function countLines(text) {
|
|
|
4398
4415
|
function countPages(text) {
|
|
4399
4416
|
return Math.ceil(countLines(text) / LINES_PER_STANDARD_PAGE);
|
|
4400
4417
|
}
|
|
4418
|
+
/**
|
|
4419
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
4420
|
+
*/
|
|
4401
4421
|
|
|
4402
4422
|
/**
|
|
4403
4423
|
* Counts number of paragraphs in the text
|
|
@@ -4407,6 +4427,9 @@ function countPages(text) {
|
|
|
4407
4427
|
function countParagraphs(text) {
|
|
4408
4428
|
return text.split(/\n\s*\n/).filter((paragraph) => paragraph.trim() !== '').length;
|
|
4409
4429
|
}
|
|
4430
|
+
/**
|
|
4431
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
4432
|
+
*/
|
|
4410
4433
|
|
|
4411
4434
|
/**
|
|
4412
4435
|
* Split text into sentences
|
|
@@ -4424,6 +4447,9 @@ function splitIntoSentences(text) {
|
|
|
4424
4447
|
function countSentences(text) {
|
|
4425
4448
|
return splitIntoSentences(text).length;
|
|
4426
4449
|
}
|
|
4450
|
+
/**
|
|
4451
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
4452
|
+
*/
|
|
4427
4453
|
|
|
4428
4454
|
/**
|
|
4429
4455
|
* Counts number of words in the text
|
|
@@ -4437,6 +4463,9 @@ function countWords(text) {
|
|
|
4437
4463
|
text = text.replace(/([a-z])([A-Z])/g, '$1 $2');
|
|
4438
4464
|
return text.split(/[^a-zะฐ-ั0-9]+/i).filter((word) => word.length > 0).length;
|
|
4439
4465
|
}
|
|
4466
|
+
/**
|
|
4467
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
4468
|
+
*/
|
|
4440
4469
|
|
|
4441
4470
|
/**
|
|
4442
4471
|
* Index of all counter functions
|