@promptbook/core 0.88.0-9 โ 0.88.0
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 +35 -18
- package/esm/index.es.js +38 -9
- 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 +1 -1
- package/umd/index.umd.js +38 -9
- package/umd/index.umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -23,10 +23,6 @@
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
<blockquote style="color: #ff8811">
|
|
27
|
-
<b>โ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
|
|
28
|
-
</blockquote>
|
|
29
|
-
|
|
30
26
|
## ๐ฆ Package `@promptbook/core`
|
|
31
27
|
|
|
32
28
|
- Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
|
@@ -62,6 +58,8 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
|
|
|
62
58
|
|
|
63
59
|
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**!
|
|
64
60
|
|
|
61
|
+
|
|
62
|
+
|
|
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:
|
|
@@ -118,22 +121,35 @@ Promptbook project is ecosystem of multiple projects and tools, following is a l
|
|
|
118
121
|
</tbody>
|
|
119
122
|
</table>
|
|
120
123
|
|
|
124
|
+
Hello world examples:
|
|
125
|
+
|
|
126
|
+
- [Hello world](https://github.com/webgptorg/hello-world)
|
|
127
|
+
- [Hello world in Node.js](https://github.com/webgptorg/hello-world-node-js)
|
|
128
|
+
- [Hello world in Next.js](https://github.com/webgptorg/hello-world-next-js)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
121
132
|
We also have a community of developers and users of **Promptbook**:
|
|
122
133
|
|
|
123
134
|
- [Discord community](https://discord.gg/x3QWNaa89N)
|
|
124
135
|
- [Landing page `ptbk.io`](https://ptbk.io)
|
|
125
136
|
- [Github discussions](https://github.com/webgptorg/promptbook/discussions)
|
|
126
137
|
- [LinkedIn `Promptbook`](https://linkedin.com/company/promptbook)
|
|
127
|
-
- [Facebook `Promptbook`](https://www.facebook.com/61560776453536)
|
|
138
|
+
- [Facebook `Promptbook`](https://www.facebook.com/61560776453536)
|
|
128
139
|
|
|
129
140
|
And **Promptbook.studio** branded socials:
|
|
130
141
|
|
|
142
|
+
|
|
143
|
+
|
|
131
144
|
- [Instagram `@promptbook.studio`](https://www.instagram.com/promptbook.studio/)
|
|
132
145
|
|
|
133
146
|
And **Promptujeme** sub-brand:
|
|
134
147
|
|
|
135
148
|
_/Subbrand for Czech clients/_
|
|
136
149
|
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
137
153
|
- [Promptujeme.cz](https://www.promptujeme.cz/)
|
|
138
154
|
- [Facebook `Promptujeme`](https://www.facebook.com/promptujeme/)
|
|
139
155
|
|
|
@@ -151,6 +167,8 @@ _/Sub-brand for images and graphics generated via Promptbook prompting/_
|
|
|
151
167
|
|
|
152
168
|
## ๐ The Book language
|
|
153
169
|
|
|
170
|
+
|
|
171
|
+
|
|
154
172
|
Following is the documentation and blueprint of the [Book language](https://github.com/webgptorg/book).
|
|
155
173
|
|
|
156
174
|
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.
|
|
@@ -200,6 +218,8 @@ Personas can have access to different knowledge, tools and actions. They can als
|
|
|
200
218
|
|
|
201
219
|
- [PERSONA](https://github.com/webgptorg/promptbook/blob/main/documents/commands/PERSONA.md)
|
|
202
220
|
|
|
221
|
+
|
|
222
|
+
|
|
203
223
|
### **How:** Knowledge, Instruments and Actions
|
|
204
224
|
|
|
205
225
|
The resources used by the personas are used to do the work.
|
|
@@ -275,11 +295,9 @@ Or you can install them separately:
|
|
|
275
295
|
|
|
276
296
|
## ๐ Dictionary
|
|
277
297
|
|
|
278
|
-
### ๐ Dictionary
|
|
279
|
-
|
|
280
298
|
The following glossary is used to clarify certain concepts:
|
|
281
299
|
|
|
282
|
-
|
|
300
|
+
### General LLM / AI terms
|
|
283
301
|
|
|
284
302
|
- **Prompt drift** is a phenomenon where the AI model starts to generate outputs that are not aligned with the original prompt. This can happen due to the model's training data, the prompt's wording, or the model's architecture.
|
|
285
303
|
- **Pipeline, workflow or chain** is a sequence of tasks that are executed in a specific order. In the context of AI, a pipeline can refer to a sequence of AI models that are used to process data.
|
|
@@ -290,9 +308,13 @@ The following glossary is used to clarify certain concepts:
|
|
|
290
308
|
- **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.
|
|
291
309
|
- **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.
|
|
292
310
|
|
|
293
|
-
_Note: Thos section is not complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
|
|
294
311
|
|
|
295
|
-
|
|
312
|
+
|
|
313
|
+
_Note: This section is not complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
### ๐ฏ Core concepts
|
|
296
318
|
|
|
297
319
|
- [๐ Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
|
|
298
320
|
- [๐ฏ Pipeline](https://github.com/webgptorg/promptbook/discussions/64)
|
|
@@ -305,7 +327,7 @@ _Note: Thos section is not complete dictionary, more list of general AI / LLM te
|
|
|
305
327
|
- [๐ฃ Words not tokens](https://github.com/webgptorg/promptbook/discussions/29)
|
|
306
328
|
- [โฏ Separation of concerns](https://github.com/webgptorg/promptbook/discussions/32)
|
|
307
329
|
|
|
308
|
-
|
|
330
|
+
#### Advanced concepts
|
|
309
331
|
|
|
310
332
|
- [๐ Knowledge (Retrieval-augmented generation)](https://github.com/webgptorg/promptbook/discussions/41)
|
|
311
333
|
- [๐ Remote server](https://github.com/webgptorg/promptbook/discussions/89)
|
|
@@ -320,11 +342,6 @@ _Note: Thos section is not complete dictionary, more list of general AI / LLM te
|
|
|
320
342
|
- [๐ฎ Agent adversary expectations](https://github.com/webgptorg/promptbook/discussions/39)
|
|
321
343
|
- [view more](https://github.com/webgptorg/promptbook/discussions/categories/concepts)
|
|
322
344
|
|
|
323
|
-
### Terms specific to Promptbook TypeScript implementation
|
|
324
|
-
|
|
325
|
-
- Anonymous mode
|
|
326
|
-
- Application mode
|
|
327
|
-
|
|
328
345
|
|
|
329
346
|
|
|
330
347
|
## ๐ Promptbook Engine
|
|
@@ -395,11 +412,11 @@ See [TODO.md](./TODO.md)
|
|
|
395
412
|
<div style="display: flex; align-items: center; gap: 20px;">
|
|
396
413
|
|
|
397
414
|
<a href="https://promptbook.studio/">
|
|
398
|
-
<img src="./design/promptbook-studio-logo.png" alt="Partner 3" height="
|
|
415
|
+
<img src="./design/promptbook-studio-logo.png" alt="Partner 3" height="70">
|
|
399
416
|
</a>
|
|
400
417
|
|
|
401
418
|
<a href="https://technologickainkubace.org/en/about-technology-incubation/about-the-project/">
|
|
402
|
-
<img src="./other/partners/CI-Technology-Incubation.png" alt="Technology Incubation" height="
|
|
419
|
+
<img src="./other/partners/CI-Technology-Incubation.png" alt="Technology Incubation" height="70">
|
|
403
420
|
</a>
|
|
404
421
|
|
|
405
422
|
</div>
|
package/esm/index.es.js
CHANGED
|
@@ -27,7 +27,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
27
27
|
* @generated
|
|
28
28
|
* @see https://github.com/webgptorg/promptbook
|
|
29
29
|
*/
|
|
30
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.88.0
|
|
30
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.88.0';
|
|
31
31
|
/**
|
|
32
32
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
33
33
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
@@ -453,7 +453,7 @@ const CLAIM = `It's time for a paradigm shift. The future of software in plain E
|
|
|
453
453
|
*
|
|
454
454
|
* @public exported from `@promptbook/core`
|
|
455
455
|
*/
|
|
456
|
-
const LOGO_LIGHT_SRC = `https://promptbook.studio/_next/static/media/promptbook-logo.b21f0c70.png`;
|
|
456
|
+
const LOGO_LIGHT_SRC = `https://promptbook.studio/_next/static/media/promptbook-logo.b21f0c70.png`; // <- TODO: !!! Auto-update or remove
|
|
457
457
|
/**
|
|
458
458
|
* Logo for the dark theme
|
|
459
459
|
*
|
|
@@ -461,7 +461,7 @@ const LOGO_LIGHT_SRC = `https://promptbook.studio/_next/static/media/promptbook-
|
|
|
461
461
|
*
|
|
462
462
|
* @public exported from `@promptbook/core`
|
|
463
463
|
*/
|
|
464
|
-
const LOGO_DARK_SRC = `https://promptbook.studio/_next/static/media/promptbook-logo-white.09887cbc.png`;
|
|
464
|
+
const LOGO_DARK_SRC = `https://promptbook.studio/_next/static/media/promptbook-logo-white.09887cbc.png`; // <- TODO: !!! Auto-update or remove
|
|
465
465
|
/**
|
|
466
466
|
* When the title is not provided, the default title is used
|
|
467
467
|
*
|
|
@@ -549,7 +549,7 @@ const DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [๐คนโโ๏ธ]
|
|
|
549
549
|
*
|
|
550
550
|
* @public exported from `@promptbook/core`
|
|
551
551
|
*/
|
|
552
|
-
const DEFAULT_MAX_EXECUTION_ATTEMPTS =
|
|
552
|
+
const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [๐คนโโ๏ธ]
|
|
553
553
|
/**
|
|
554
554
|
* @@@
|
|
555
555
|
* TODO: [๐][main] !!3 Use
|
|
@@ -1851,11 +1851,17 @@ function jsonStringsToJsons(object) {
|
|
|
1851
1851
|
*/
|
|
1852
1852
|
class PipelineExecutionError extends Error {
|
|
1853
1853
|
constructor(message) {
|
|
1854
|
+
// Added id parameter
|
|
1854
1855
|
super(message);
|
|
1855
1856
|
this.name = 'PipelineExecutionError';
|
|
1857
|
+
// TODO: [๐] DRY - Maybe $randomId
|
|
1858
|
+
this.id = `error-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
1856
1859
|
Object.setPrototypeOf(this, PipelineExecutionError.prototype);
|
|
1857
1860
|
}
|
|
1858
1861
|
}
|
|
1862
|
+
/**
|
|
1863
|
+
* TODO: !!!!!! Add id to all errors
|
|
1864
|
+
*/
|
|
1859
1865
|
|
|
1860
1866
|
/**
|
|
1861
1867
|
* This error indicates problems parsing the format value
|
|
@@ -2043,7 +2049,7 @@ const ALL_ERRORS = {
|
|
|
2043
2049
|
* @public exported from `@promptbook/utils`
|
|
2044
2050
|
*/
|
|
2045
2051
|
function deserializeError(error) {
|
|
2046
|
-
const { name, stack } = error;
|
|
2052
|
+
const { name, stack, id } = error; // Added id
|
|
2047
2053
|
let { message } = error;
|
|
2048
2054
|
let ErrorClass = ALL_ERRORS[error.name];
|
|
2049
2055
|
if (ErrorClass === undefined) {
|
|
@@ -2058,7 +2064,9 @@ function deserializeError(error) {
|
|
|
2058
2064
|
${block(stack || '')}
|
|
2059
2065
|
`);
|
|
2060
2066
|
}
|
|
2061
|
-
|
|
2067
|
+
const deserializedError = new ErrorClass(message);
|
|
2068
|
+
deserializedError.id = id; // Assign id to the error object
|
|
2069
|
+
return deserializedError;
|
|
2062
2070
|
}
|
|
2063
2071
|
|
|
2064
2072
|
/**
|
|
@@ -2108,6 +2116,7 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
2108
2116
|
*/
|
|
2109
2117
|
function createTask(options) {
|
|
2110
2118
|
const { taskType, taskProcessCallback } = options;
|
|
2119
|
+
// TODO: [๐] DRY
|
|
2111
2120
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
2112
2121
|
let status = 'RUNNING';
|
|
2113
2122
|
const createdAt = new Date();
|
|
@@ -2140,7 +2149,7 @@ function createTask(options) {
|
|
|
2140
2149
|
assertsTaskSuccessful(executionResult);
|
|
2141
2150
|
status = 'FINISHED';
|
|
2142
2151
|
currentValue = jsonStringsToJsons(executionResult);
|
|
2143
|
-
// <- TODO:
|
|
2152
|
+
// <- TODO: [๐ง ] Is this a good idea to convert JSON strins to JSONs?
|
|
2144
2153
|
partialResultSubject.next(executionResult);
|
|
2145
2154
|
}
|
|
2146
2155
|
catch (error) {
|
|
@@ -2204,19 +2213,21 @@ function createTask(options) {
|
|
|
2204
2213
|
*/
|
|
2205
2214
|
function serializeError(error) {
|
|
2206
2215
|
const { name, message, stack } = error;
|
|
2216
|
+
const { id } = error;
|
|
2207
2217
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
2208
2218
|
console.error(spaceTrim((block) => `
|
|
2209
|
-
|
|
2219
|
+
|
|
2210
2220
|
Cannot serialize error with name "${name}"
|
|
2211
2221
|
|
|
2212
2222
|
${block(stack || message)}
|
|
2213
|
-
|
|
2223
|
+
|
|
2214
2224
|
`));
|
|
2215
2225
|
}
|
|
2216
2226
|
return {
|
|
2217
2227
|
name: name,
|
|
2218
2228
|
message,
|
|
2219
2229
|
stack,
|
|
2230
|
+
id, // Include id in the serialized object
|
|
2220
2231
|
};
|
|
2221
2232
|
}
|
|
2222
2233
|
|
|
@@ -3259,6 +3270,9 @@ function countCharacters(text) {
|
|
|
3259
3270
|
text = text.replace(/\p{Extended_Pictographic}(\u{200D}\p{Extended_Pictographic})*/gu, '-');
|
|
3260
3271
|
return text.length;
|
|
3261
3272
|
}
|
|
3273
|
+
/**
|
|
3274
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
3275
|
+
*/
|
|
3262
3276
|
|
|
3263
3277
|
/**
|
|
3264
3278
|
* Number of characters per standard line with 11pt Arial font size.
|
|
@@ -3290,6 +3304,9 @@ function countLines(text) {
|
|
|
3290
3304
|
const lines = text.split('\n');
|
|
3291
3305
|
return lines.reduce((count, line) => count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 0);
|
|
3292
3306
|
}
|
|
3307
|
+
/**
|
|
3308
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
3309
|
+
*/
|
|
3293
3310
|
|
|
3294
3311
|
/**
|
|
3295
3312
|
* Counts number of pages in the text
|
|
@@ -3301,6 +3318,9 @@ function countLines(text) {
|
|
|
3301
3318
|
function countPages(text) {
|
|
3302
3319
|
return Math.ceil(countLines(text) / LINES_PER_STANDARD_PAGE);
|
|
3303
3320
|
}
|
|
3321
|
+
/**
|
|
3322
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
3323
|
+
*/
|
|
3304
3324
|
|
|
3305
3325
|
/**
|
|
3306
3326
|
* Counts number of paragraphs in the text
|
|
@@ -3310,6 +3330,9 @@ function countPages(text) {
|
|
|
3310
3330
|
function countParagraphs(text) {
|
|
3311
3331
|
return text.split(/\n\s*\n/).filter((paragraph) => paragraph.trim() !== '').length;
|
|
3312
3332
|
}
|
|
3333
|
+
/**
|
|
3334
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
3335
|
+
*/
|
|
3313
3336
|
|
|
3314
3337
|
/**
|
|
3315
3338
|
* Split text into sentences
|
|
@@ -3327,6 +3350,9 @@ function splitIntoSentences(text) {
|
|
|
3327
3350
|
function countSentences(text) {
|
|
3328
3351
|
return splitIntoSentences(text).length;
|
|
3329
3352
|
}
|
|
3353
|
+
/**
|
|
3354
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
3355
|
+
*/
|
|
3330
3356
|
|
|
3331
3357
|
const defaultDiacriticsRemovalMap = [
|
|
3332
3358
|
{
|
|
@@ -3601,6 +3627,9 @@ function countWords(text) {
|
|
|
3601
3627
|
text = text.replace(/([a-z])([A-Z])/g, '$1 $2');
|
|
3602
3628
|
return text.split(/[^a-zะฐ-ั0-9]+/i).filter((word) => word.length > 0).length;
|
|
3603
3629
|
}
|
|
3630
|
+
/**
|
|
3631
|
+
* TODO: [๐ฅด] Implement counting in formats - like JSON, CSV, XML,...
|
|
3632
|
+
*/
|
|
3604
3633
|
|
|
3605
3634
|
/**
|
|
3606
3635
|
* Index of all counter functions
|