@promptbook/pdf 0.88.0-11 → 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 +7 -19
- 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
|
@@ -60,8 +60,6 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
|
|
|
60
60
|
|
|
61
61
|
During the computer revolution, we have seen [multiple generations of computer languages](https://github.com/webgptorg/promptbook/discussions/180), from the physical rewiring of the vacuum tubes through low-level machine code to the high-level languages like Python or JavaScript. And now, we're on the edge of the **next revolution**!
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
63
|
It's a revolution of writing software in **plain human language** that is understandable and executable by both humans and machines – and it's going to change everything!
|
|
66
64
|
|
|
67
65
|
The incredible growth in power of microprocessors and the Moore's Law have been the driving force behind the ever-more powerful languages, and it's been an amazing journey! Similarly, the large language models (like GPT or Claude) are the next big thing in language technology, and they're set to transform the way we interact with computers.
|
|
@@ -72,6 +70,9 @@ This shift is going to happen, whether we are ready for it or not. Our mission i
|
|
|
72
70
|
|
|
73
71
|
|
|
74
72
|
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
75
76
|
## 🚀 Get started
|
|
76
77
|
|
|
77
78
|
Take a look at the simple starter kit with books integrated into the **Hello World** sample applications:
|
|
@@ -83,6 +84,8 @@ Take a look at the simple starter kit with books integrated into the **Hello Wor
|
|
|
83
84
|
|
|
84
85
|
|
|
85
86
|
|
|
87
|
+
|
|
88
|
+
|
|
86
89
|
## 💜 The Promptbook Project
|
|
87
90
|
|
|
88
91
|
Promptbook project is ecosystem of multiple projects and tools, following is a list of most important pieces of the project:
|
|
@@ -124,29 +127,22 @@ Hello world examples:
|
|
|
124
127
|
- [Hello world in Node.js](https://github.com/webgptorg/hello-world-node-js)
|
|
125
128
|
- [Hello world in Next.js](https://github.com/webgptorg/hello-world-next-js)
|
|
126
129
|
|
|
127
|
-
|
|
128
|
-
|
|
129
130
|
We also have a community of developers and users of **Promptbook**:
|
|
130
131
|
|
|
131
132
|
- [Discord community](https://discord.gg/x3QWNaa89N)
|
|
132
133
|
- [Landing page `ptbk.io`](https://ptbk.io)
|
|
133
134
|
- [Github discussions](https://github.com/webgptorg/promptbook/discussions)
|
|
134
135
|
- [LinkedIn `Promptbook`](https://linkedin.com/company/promptbook)
|
|
135
|
-
- [Facebook `Promptbook`](https://www.facebook.com/61560776453536)
|
|
136
|
+
- [Facebook `Promptbook`](https://www.facebook.com/61560776453536)
|
|
136
137
|
|
|
137
138
|
And **Promptbook.studio** branded socials:
|
|
138
139
|
|
|
139
|
-
|
|
140
|
-
|
|
141
140
|
- [Instagram `@promptbook.studio`](https://www.instagram.com/promptbook.studio/)
|
|
142
141
|
|
|
143
142
|
And **Promptujeme** sub-brand:
|
|
144
143
|
|
|
145
144
|
_/Subbrand for Czech clients/_
|
|
146
145
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
146
|
- [Promptujeme.cz](https://www.promptujeme.cz/)
|
|
151
147
|
- [Facebook `Promptujeme`](https://www.facebook.com/promptujeme/)
|
|
152
148
|
|
|
@@ -164,8 +160,6 @@ _/Sub-brand for images and graphics generated via Promptbook prompting/_
|
|
|
164
160
|
|
|
165
161
|
## 💙 The Book language
|
|
166
162
|
|
|
167
|
-
|
|
168
|
-
|
|
169
163
|
Following is the documentation and blueprint of the [Book language](https://github.com/webgptorg/book).
|
|
170
164
|
|
|
171
165
|
Book is a language that can be used to write AI applications, agents, workflows, automations, knowledgebases, translators, sheet processors, email automations and more. It allows you to harness the power of AI models in human-like terms, without the need to know the specifics and technicalities of the models.
|
|
@@ -215,8 +209,6 @@ Personas can have access to different knowledge, tools and actions. They can als
|
|
|
215
209
|
|
|
216
210
|
- [PERSONA](https://github.com/webgptorg/promptbook/blob/main/documents/commands/PERSONA.md)
|
|
217
211
|
|
|
218
|
-
|
|
219
|
-
|
|
220
212
|
### **How:** Knowledge, Instruments and Actions
|
|
221
213
|
|
|
222
214
|
The resources used by the personas are used to do the work.
|
|
@@ -305,12 +297,8 @@ The following glossary is used to clarify certain concepts:
|
|
|
305
297
|
- **Retrieval-augmented generation** is a machine learning paradigm where a model generates text by retrieving relevant information from a large database of text. This approach combines the benefits of generative models and retrieval models.
|
|
306
298
|
- **Longtail** refers to non-common or rare events, items, or entities that are not well-represented in the training data of machine learning models. Longtail items are often challenging for models to predict accurately.
|
|
307
299
|
|
|
308
|
-
|
|
309
|
-
|
|
310
300
|
_Note: This section is not complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
|
|
311
301
|
|
|
312
|
-
|
|
313
|
-
|
|
314
302
|
### 💯 Core concepts
|
|
315
303
|
|
|
316
304
|
- [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
|
|
@@ -415,7 +403,7 @@ See [TODO.md](./TODO.md)
|
|
|
415
403
|
<a href="https://technologickainkubace.org/en/about-technology-incubation/about-the-project/">
|
|
416
404
|
<img src="./other/partners/CI-Technology-Incubation.png" alt="Technology Incubation" height="70">
|
|
417
405
|
</a>
|
|
418
|
-
|
|
406
|
+
|
|
419
407
|
</div>
|
|
420
408
|
|
|
421
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
|