@promptbook/documents 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
|
@@ -71,6 +71,9 @@ This shift is going to happen, whether we are ready for it or not. Our mission i
|
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
74
77
|
## ๐ Get started
|
|
75
78
|
|
|
76
79
|
Take a look at the simple starter kit with books integrated into the **Hello World** sample applications:
|
|
@@ -82,6 +85,8 @@ Take a look at the simple starter kit with books integrated into the **Hello Wor
|
|
|
82
85
|
|
|
83
86
|
|
|
84
87
|
|
|
88
|
+
|
|
89
|
+
|
|
85
90
|
## ๐ The Promptbook Project
|
|
86
91
|
|
|
87
92
|
Promptbook project is ecosystem of multiple projects and tools, following is a list of most important pieces of the project:
|
|
@@ -399,7 +404,7 @@ See [TODO.md](./TODO.md)
|
|
|
399
404
|
<a href="https://technologickainkubace.org/en/about-technology-incubation/about-the-project/">
|
|
400
405
|
<img src="./other/partners/CI-Technology-Incubation.png" alt="Technology Incubation" height="70">
|
|
401
406
|
</a>
|
|
402
|
-
|
|
407
|
+
|
|
403
408
|
</div>
|
|
404
409
|
|
|
405
410
|
## ๐๏ธ Contributing
|
package/esm/index.es.js
CHANGED
|
@@ -8,8 +8,8 @@ import hexEncoder from 'crypto-js/enc-hex';
|
|
|
8
8
|
import { basename, join, dirname } from 'path';
|
|
9
9
|
import { format } from 'prettier';
|
|
10
10
|
import parserHtml from 'prettier/parser-html';
|
|
11
|
-
import { Subject } from 'rxjs';
|
|
12
11
|
import { randomBytes } from 'crypto';
|
|
12
|
+
import { Subject } from 'rxjs';
|
|
13
13
|
import sha256 from 'crypto-js/sha256';
|
|
14
14
|
import { lookup, extension } from 'mime-types';
|
|
15
15
|
import { parse, unparse } from 'papaparse';
|
|
@@ -28,7 +28,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
28
28
|
* @generated
|
|
29
29
|
* @see https://github.com/webgptorg/promptbook
|
|
30
30
|
*/
|
|
31
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.88.0-
|
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.88.0-12';
|
|
32
32
|
/**
|
|
33
33
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
34
34
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
@@ -160,7 +160,7 @@ const DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [๐คนโโ๏ธ]
|
|
|
160
160
|
*
|
|
161
161
|
* @public exported from `@promptbook/core`
|
|
162
162
|
*/
|
|
163
|
-
const DEFAULT_MAX_EXECUTION_ATTEMPTS =
|
|
163
|
+
const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [๐คนโโ๏ธ]
|
|
164
164
|
// <- TODO: [๐] Make also `BOOKS_DIRNAME_ALTERNATIVES`
|
|
165
165
|
/**
|
|
166
166
|
* Where to store the temporary downloads
|
|
@@ -2173,6 +2173,21 @@ function createCollectionFromJson(...promptbooks) {
|
|
|
2173
2173
|
return new SimplePipelineCollection(...promptbooks);
|
|
2174
2174
|
}
|
|
2175
2175
|
|
|
2176
|
+
/**
|
|
2177
|
+
* Generates random token
|
|
2178
|
+
*
|
|
2179
|
+
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
2180
|
+
*
|
|
2181
|
+
* @private internal helper function
|
|
2182
|
+
* @returns secure random token
|
|
2183
|
+
*/
|
|
2184
|
+
function $randomToken(randomness) {
|
|
2185
|
+
return randomBytes(randomness).toString('hex');
|
|
2186
|
+
}
|
|
2187
|
+
/**
|
|
2188
|
+
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
2189
|
+
*/
|
|
2190
|
+
|
|
2176
2191
|
/**
|
|
2177
2192
|
* This error indicates errors during the execution of the pipeline
|
|
2178
2193
|
*
|
|
@@ -2180,11 +2195,17 @@ function createCollectionFromJson(...promptbooks) {
|
|
|
2180
2195
|
*/
|
|
2181
2196
|
class PipelineExecutionError extends Error {
|
|
2182
2197
|
constructor(message) {
|
|
2198
|
+
// Added id parameter
|
|
2183
2199
|
super(message);
|
|
2184
2200
|
this.name = 'PipelineExecutionError';
|
|
2201
|
+
// TODO: [๐] DRY - Maybe $randomId
|
|
2202
|
+
this.id = `error-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
2185
2203
|
Object.setPrototypeOf(this, PipelineExecutionError.prototype);
|
|
2186
2204
|
}
|
|
2187
2205
|
}
|
|
2206
|
+
/**
|
|
2207
|
+
* TODO: !!!!!! Add id to all errors
|
|
2208
|
+
*/
|
|
2188
2209
|
|
|
2189
2210
|
/**
|
|
2190
2211
|
* Determine if the pipeline is fully prepared
|
|
@@ -2223,21 +2244,6 @@ function isPipelinePrepared(pipeline) {
|
|
|
2223
2244
|
* - [โจ] Are tasks prepared
|
|
2224
2245
|
*/
|
|
2225
2246
|
|
|
2226
|
-
/**
|
|
2227
|
-
* Generates random token
|
|
2228
|
-
*
|
|
2229
|
-
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
2230
|
-
*
|
|
2231
|
-
* @private internal helper function
|
|
2232
|
-
* @returns secure random token
|
|
2233
|
-
*/
|
|
2234
|
-
function $randomToken(randomness) {
|
|
2235
|
-
return randomBytes(randomness).toString('hex');
|
|
2236
|
-
}
|
|
2237
|
-
/**
|
|
2238
|
-
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
2239
|
-
*/
|
|
2240
|
-
|
|
2241
2247
|
/**
|
|
2242
2248
|
* Recursively converts JSON strings to JSON objects
|
|
2243
2249
|
|
|
@@ -2428,7 +2434,7 @@ const ALL_ERRORS = {
|
|
|
2428
2434
|
* @public exported from `@promptbook/utils`
|
|
2429
2435
|
*/
|
|
2430
2436
|
function deserializeError(error) {
|
|
2431
|
-
const { name, stack } = error;
|
|
2437
|
+
const { name, stack, id } = error; // Added id
|
|
2432
2438
|
let { message } = error;
|
|
2433
2439
|
let ErrorClass = ALL_ERRORS[error.name];
|
|
2434
2440
|
if (ErrorClass === undefined) {
|
|
@@ -2443,7 +2449,9 @@ function deserializeError(error) {
|
|
|
2443
2449
|
${block(stack || '')}
|
|
2444
2450
|
`);
|
|
2445
2451
|
}
|
|
2446
|
-
|
|
2452
|
+
const deserializedError = new ErrorClass(message);
|
|
2453
|
+
deserializedError.id = id; // Assign id to the error object
|
|
2454
|
+
return deserializedError;
|
|
2447
2455
|
}
|
|
2448
2456
|
|
|
2449
2457
|
/**
|
|
@@ -2493,6 +2501,7 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
2493
2501
|
*/
|
|
2494
2502
|
function createTask(options) {
|
|
2495
2503
|
const { taskType, taskProcessCallback } = options;
|
|
2504
|
+
// TODO: [๐] DRY
|
|
2496
2505
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
2497
2506
|
let status = 'RUNNING';
|
|
2498
2507
|
const createdAt = new Date();
|
|
@@ -2589,19 +2598,21 @@ function createTask(options) {
|
|
|
2589
2598
|
*/
|
|
2590
2599
|
function serializeError(error) {
|
|
2591
2600
|
const { name, message, stack } = error;
|
|
2601
|
+
const { id } = error;
|
|
2592
2602
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
2593
2603
|
console.error(spaceTrim$1((block) => `
|
|
2594
|
-
|
|
2604
|
+
|
|
2595
2605
|
Cannot serialize error with name "${name}"
|
|
2596
2606
|
|
|
2597
2607
|
${block(stack || message)}
|
|
2598
|
-
|
|
2608
|
+
|
|
2599
2609
|
`));
|
|
2600
2610
|
}
|
|
2601
2611
|
return {
|
|
2602
2612
|
name: name,
|
|
2603
2613
|
message,
|
|
2604
2614
|
stack,
|
|
2615
|
+
id, // Include id in the serialized object
|
|
2605
2616
|
};
|
|
2606
2617
|
}
|
|
2607
2618
|
|
|
@@ -4503,6 +4514,9 @@ function countCharacters(text) {
|
|
|
4503
4514
|
text = text.replace(/\p{Extended_Pictographic}(\u{200D}\p{Extended_Pictographic})*/gu, '-');
|
|
4504
4515
|
return text.length;
|
|
4505
4516
|
}
|
|
4517
|
+
/**
|
|
4518
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
4519
|
+
*/
|
|
4506
4520
|
|
|
4507
4521
|
/**
|
|
4508
4522
|
* Number of characters per standard line with 11pt Arial font size.
|
|
@@ -4534,6 +4548,9 @@ function countLines(text) {
|
|
|
4534
4548
|
const lines = text.split('\n');
|
|
4535
4549
|
return lines.reduce((count, line) => count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 0);
|
|
4536
4550
|
}
|
|
4551
|
+
/**
|
|
4552
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
4553
|
+
*/
|
|
4537
4554
|
|
|
4538
4555
|
/**
|
|
4539
4556
|
* Counts number of pages in the text
|
|
@@ -4545,6 +4562,9 @@ function countLines(text) {
|
|
|
4545
4562
|
function countPages(text) {
|
|
4546
4563
|
return Math.ceil(countLines(text) / LINES_PER_STANDARD_PAGE);
|
|
4547
4564
|
}
|
|
4565
|
+
/**
|
|
4566
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
4567
|
+
*/
|
|
4548
4568
|
|
|
4549
4569
|
/**
|
|
4550
4570
|
* Counts number of paragraphs in the text
|
|
@@ -4554,6 +4574,9 @@ function countPages(text) {
|
|
|
4554
4574
|
function countParagraphs(text) {
|
|
4555
4575
|
return text.split(/\n\s*\n/).filter((paragraph) => paragraph.trim() !== '').length;
|
|
4556
4576
|
}
|
|
4577
|
+
/**
|
|
4578
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
4579
|
+
*/
|
|
4557
4580
|
|
|
4558
4581
|
/**
|
|
4559
4582
|
* Split text into sentences
|
|
@@ -4571,6 +4594,9 @@ function splitIntoSentences(text) {
|
|
|
4571
4594
|
function countSentences(text) {
|
|
4572
4595
|
return splitIntoSentences(text).length;
|
|
4573
4596
|
}
|
|
4597
|
+
/**
|
|
4598
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
4599
|
+
*/
|
|
4574
4600
|
|
|
4575
4601
|
/**
|
|
4576
4602
|
* Counts number of words in the text
|
|
@@ -4584,6 +4610,9 @@ function countWords(text) {
|
|
|
4584
4610
|
text = text.replace(/([a-z])([A-Z])/g, '$1 $2');
|
|
4585
4611
|
return text.split(/[^a-zะฐ-ั0-9]+/i).filter((word) => word.length > 0).length;
|
|
4586
4612
|
}
|
|
4613
|
+
/**
|
|
4614
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
4615
|
+
*/
|
|
4587
4616
|
|
|
4588
4617
|
/**
|
|
4589
4618
|
* Index of all counter functions
|