@promptbook/documents 0.88.0-1 → 0.88.0-10
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 +16 -40
- package/esm/index.es.js +82 -9
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/_packages/utils.index.d.ts +2 -0
- package/esm/typings/src/cli/cli-commands/common/handleActionErrors.d.ts +11 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +24 -0
- package/esm/typings/src/utils/serialization/jsonStringsToJsons.d.ts +9 -0
- package/esm/typings/src/utils/serialization/jsonStringsToJsons.test.d.ts +1 -0
- package/package.json +2 -2
- package/umd/index.umd.js +81 -8
- package/umd/index.umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -61,8 +61,6 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
|
|
|
61
61
|
|
|
62
62
|
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**!
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
64
|
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!
|
|
67
65
|
|
|
68
66
|
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.
|
|
@@ -119,27 +117,28 @@ Promptbook project is ecosystem of multiple projects and tools, following is a l
|
|
|
119
117
|
</tbody>
|
|
120
118
|
</table>
|
|
121
119
|
|
|
120
|
+
Hello world examples:
|
|
121
|
+
|
|
122
|
+
- [Hello world](https://github.com/webgptorg/hello-world)
|
|
123
|
+
- [Hello world in Node.js](https://github.com/webgptorg/hello-world-node-js)
|
|
124
|
+
- [Hello world in Next.js](https://github.com/webgptorg/hello-world-next-js)
|
|
125
|
+
|
|
122
126
|
We also have a community of developers and users of **Promptbook**:
|
|
123
127
|
|
|
124
128
|
- [Discord community](https://discord.gg/x3QWNaa89N)
|
|
125
129
|
- [Landing page `ptbk.io`](https://ptbk.io)
|
|
126
130
|
- [Github discussions](https://github.com/webgptorg/promptbook/discussions)
|
|
127
131
|
- [LinkedIn `Promptbook`](https://linkedin.com/company/promptbook)
|
|
128
|
-
- [Facebook `Promptbook`](https://www.facebook.com/61560776453536)
|
|
132
|
+
- [Facebook `Promptbook`](https://www.facebook.com/61560776453536)
|
|
129
133
|
|
|
130
134
|
And **Promptbook.studio** branded socials:
|
|
131
135
|
|
|
132
|
-
|
|
133
|
-
|
|
134
136
|
- [Instagram `@promptbook.studio`](https://www.instagram.com/promptbook.studio/)
|
|
135
137
|
|
|
136
138
|
And **Promptujeme** sub-brand:
|
|
137
139
|
|
|
138
140
|
_/Subbrand for Czech clients/_
|
|
139
141
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
142
|
- [Promptujeme.cz](https://www.promptujeme.cz/)
|
|
144
143
|
- [Facebook `Promptujeme`](https://www.facebook.com/promptujeme/)
|
|
145
144
|
|
|
@@ -157,8 +156,6 @@ _/Sub-brand for images and graphics generated via Promptbook prompting/_
|
|
|
157
156
|
|
|
158
157
|
## 💙 The Book language
|
|
159
158
|
|
|
160
|
-
|
|
161
|
-
|
|
162
159
|
Following is the documentation and blueprint of the [Book language](https://github.com/webgptorg/book).
|
|
163
160
|
|
|
164
161
|
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.
|
|
@@ -208,8 +205,6 @@ Personas can have access to different knowledge, tools and actions. They can als
|
|
|
208
205
|
|
|
209
206
|
- [PERSONA](https://github.com/webgptorg/promptbook/blob/main/documents/commands/PERSONA.md)
|
|
210
207
|
|
|
211
|
-
|
|
212
|
-
|
|
213
208
|
### **How:** Knowledge, Instruments and Actions
|
|
214
209
|
|
|
215
210
|
The resources used by the personas are used to do the work.
|
|
@@ -285,16 +280,9 @@ Or you can install them separately:
|
|
|
285
280
|
|
|
286
281
|
## 📚 Dictionary
|
|
287
282
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
### 📚 Dictionary
|
|
294
|
-
|
|
295
283
|
The following glossary is used to clarify certain concepts:
|
|
296
284
|
|
|
297
|
-
|
|
285
|
+
### General LLM / AI terms
|
|
298
286
|
|
|
299
287
|
- **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.
|
|
300
288
|
- **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.
|
|
@@ -305,13 +293,9 @@ The following glossary is used to clarify certain concepts:
|
|
|
305
293
|
- **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
294
|
- **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
295
|
|
|
296
|
+
_Note: This section is not complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
|
|
308
297
|
|
|
309
|
-
|
|
310
|
-
_Note: Thos section is not complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
#### 💯 Core concepts
|
|
298
|
+
### 💯 Core concepts
|
|
315
299
|
|
|
316
300
|
- [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
|
|
317
301
|
- [📯 Pipeline](https://github.com/webgptorg/promptbook/discussions/64)
|
|
@@ -324,7 +308,7 @@ _Note: Thos section is not complete dictionary, more list of general AI / LLM te
|
|
|
324
308
|
- [🔣 Words not tokens](https://github.com/webgptorg/promptbook/discussions/29)
|
|
325
309
|
- [☯ Separation of concerns](https://github.com/webgptorg/promptbook/discussions/32)
|
|
326
310
|
|
|
327
|
-
|
|
311
|
+
#### Advanced concepts
|
|
328
312
|
|
|
329
313
|
- [📚 Knowledge (Retrieval-augmented generation)](https://github.com/webgptorg/promptbook/discussions/41)
|
|
330
314
|
- [🌏 Remote server](https://github.com/webgptorg/promptbook/discussions/89)
|
|
@@ -341,17 +325,9 @@ _Note: Thos section is not complete dictionary, more list of general AI / LLM te
|
|
|
341
325
|
|
|
342
326
|
|
|
343
327
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
- Anonymous mode
|
|
347
|
-
- Application mode
|
|
348
|
-
|
|
328
|
+
## 🚂 Promptbook Engine
|
|
349
329
|
|
|
350
|
-
|
|
351
|
-
## 🔌 Usage in Typescript / Javascript
|
|
352
|
-
|
|
353
|
-
- [Simple usage](./examples/usage/simple-script)
|
|
354
|
-
- [Usage with client and remote server](./examples/usage/remote)
|
|
330
|
+

|
|
355
331
|
|
|
356
332
|
## ➕➖ When to use Promptbook?
|
|
357
333
|
|
|
@@ -417,13 +393,13 @@ See [TODO.md](./TODO.md)
|
|
|
417
393
|
<div style="display: flex; align-items: center; gap: 20px;">
|
|
418
394
|
|
|
419
395
|
<a href="https://promptbook.studio/">
|
|
420
|
-
<img src="./design/promptbook-studio-logo.png" alt="Partner 3" height="
|
|
396
|
+
<img src="./design/promptbook-studio-logo.png" alt="Partner 3" height="70">
|
|
421
397
|
</a>
|
|
422
398
|
|
|
423
399
|
<a href="https://technologickainkubace.org/en/about-technology-incubation/about-the-project/">
|
|
424
|
-
<img src="./other/partners/CI-Technology-Incubation.png" alt="Technology Incubation" height="
|
|
400
|
+
<img src="./other/partners/CI-Technology-Incubation.png" alt="Technology Incubation" height="70">
|
|
425
401
|
</a>
|
|
426
|
-
|
|
402
|
+
|
|
427
403
|
</div>
|
|
428
404
|
|
|
429
405
|
## 🖋️ Contributing
|
package/esm/index.es.js
CHANGED
|
@@ -8,7 +8,7 @@ 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 {
|
|
11
|
+
import { Subject } from 'rxjs';
|
|
12
12
|
import { randomBytes } from 'crypto';
|
|
13
13
|
import sha256 from 'crypto-js/sha256';
|
|
14
14
|
import { lookup, extension } from 'mime-types';
|
|
@@ -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-10';
|
|
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
|
|
@@ -2238,6 +2238,36 @@ function $randomToken(randomness) {
|
|
|
2238
2238
|
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
2239
2239
|
*/
|
|
2240
2240
|
|
|
2241
|
+
/**
|
|
2242
|
+
* Recursively converts JSON strings to JSON objects
|
|
2243
|
+
|
|
2244
|
+
* @public exported from `@promptbook/utils`
|
|
2245
|
+
*/
|
|
2246
|
+
function jsonStringsToJsons(object) {
|
|
2247
|
+
if (object === null) {
|
|
2248
|
+
return object;
|
|
2249
|
+
}
|
|
2250
|
+
if (Array.isArray(object)) {
|
|
2251
|
+
return object.map(jsonStringsToJsons);
|
|
2252
|
+
}
|
|
2253
|
+
if (typeof object !== 'object') {
|
|
2254
|
+
return object;
|
|
2255
|
+
}
|
|
2256
|
+
const newObject = { ...object };
|
|
2257
|
+
for (const [key, value] of Object.entries(object)) {
|
|
2258
|
+
if (typeof value === 'string' && isValidJsonString(value)) {
|
|
2259
|
+
newObject[key] = JSON.parse(value);
|
|
2260
|
+
}
|
|
2261
|
+
else {
|
|
2262
|
+
newObject[key] = jsonStringsToJsons(value);
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
2265
|
+
return newObject;
|
|
2266
|
+
}
|
|
2267
|
+
/**
|
|
2268
|
+
* TODO: Type the return type correctly
|
|
2269
|
+
*/
|
|
2270
|
+
|
|
2241
2271
|
/**
|
|
2242
2272
|
* This error indicates problems parsing the format value
|
|
2243
2273
|
*
|
|
@@ -2464,21 +2494,43 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
2464
2494
|
function createTask(options) {
|
|
2465
2495
|
const { taskType, taskProcessCallback } = options;
|
|
2466
2496
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
2467
|
-
|
|
2497
|
+
let status = 'RUNNING';
|
|
2498
|
+
const createdAt = new Date();
|
|
2499
|
+
let updatedAt = createdAt;
|
|
2500
|
+
const errors = [];
|
|
2501
|
+
const warnings = [];
|
|
2502
|
+
let currentValue = {};
|
|
2503
|
+
const partialResultSubject = new Subject();
|
|
2504
|
+
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2468
2505
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
2506
|
+
Object.assign(currentValue, newOngoingResult);
|
|
2507
|
+
// <- TODO: assign deep
|
|
2469
2508
|
partialResultSubject.next(newOngoingResult);
|
|
2470
2509
|
});
|
|
2471
2510
|
finalResultPromise
|
|
2472
2511
|
.catch((error) => {
|
|
2512
|
+
errors.push(error);
|
|
2473
2513
|
partialResultSubject.error(error);
|
|
2474
2514
|
})
|
|
2475
|
-
.then((
|
|
2476
|
-
if (
|
|
2515
|
+
.then((executionResult) => {
|
|
2516
|
+
if (executionResult) {
|
|
2477
2517
|
try {
|
|
2478
|
-
|
|
2479
|
-
|
|
2518
|
+
updatedAt = new Date();
|
|
2519
|
+
errors.push(...executionResult.errors);
|
|
2520
|
+
warnings.push(...executionResult.warnings);
|
|
2521
|
+
// <- TODO: !!! Only unique errors and warnings should be added (or filtered)
|
|
2522
|
+
// TODO: [🧠] !!! errors, warning, isSuccessful are redundant both in `ExecutionTask` and `ExecutionTask.currentValue`
|
|
2523
|
+
// Also maybe move `ExecutionTask.currentValue.usage` -> `ExecutionTask.usage`
|
|
2524
|
+
// And delete `ExecutionTask.currentValue.preparedPipeline`
|
|
2525
|
+
assertsTaskSuccessful(executionResult);
|
|
2526
|
+
status = 'FINISHED';
|
|
2527
|
+
currentValue = jsonStringsToJsons(executionResult);
|
|
2528
|
+
// <- TODO: [🧠] Is this a good idea to convert JSON strins to JSONs?
|
|
2529
|
+
partialResultSubject.next(executionResult);
|
|
2480
2530
|
}
|
|
2481
2531
|
catch (error) {
|
|
2532
|
+
status = 'ERROR';
|
|
2533
|
+
errors.push(error);
|
|
2482
2534
|
partialResultSubject.error(error);
|
|
2483
2535
|
}
|
|
2484
2536
|
}
|
|
@@ -2495,12 +2547,33 @@ function createTask(options) {
|
|
|
2495
2547
|
return {
|
|
2496
2548
|
taskType,
|
|
2497
2549
|
taskId,
|
|
2550
|
+
get status() {
|
|
2551
|
+
return status;
|
|
2552
|
+
// <- Note: [1] Theese must be getters to allow changing the value in the future
|
|
2553
|
+
},
|
|
2554
|
+
get createdAt() {
|
|
2555
|
+
return createdAt;
|
|
2556
|
+
// <- Note: [1]
|
|
2557
|
+
},
|
|
2558
|
+
get updatedAt() {
|
|
2559
|
+
return updatedAt;
|
|
2560
|
+
// <- Note: [1]
|
|
2561
|
+
},
|
|
2498
2562
|
asPromise,
|
|
2499
2563
|
asObservable() {
|
|
2500
2564
|
return partialResultSubject.asObservable();
|
|
2501
2565
|
},
|
|
2566
|
+
get errors() {
|
|
2567
|
+
return errors;
|
|
2568
|
+
// <- Note: [1]
|
|
2569
|
+
},
|
|
2570
|
+
get warnings() {
|
|
2571
|
+
return warnings;
|
|
2572
|
+
// <- Note: [1]
|
|
2573
|
+
},
|
|
2502
2574
|
get currentValue() {
|
|
2503
|
-
return
|
|
2575
|
+
return currentValue;
|
|
2576
|
+
// <- Note: [1]
|
|
2504
2577
|
},
|
|
2505
2578
|
};
|
|
2506
2579
|
}
|
|
@@ -4865,7 +4938,7 @@ async function executeAttempts(options) {
|
|
|
4865
4938
|
Last result:
|
|
4866
4939
|
${block($ongoingTaskResult.$resultString === null
|
|
4867
4940
|
? 'null'
|
|
4868
|
-
: $ongoingTaskResult.$resultString
|
|
4941
|
+
: spaceTrim($ongoingTaskResult.$resultString)
|
|
4869
4942
|
.split('\n')
|
|
4870
4943
|
.map((line) => `> ${line}`)
|
|
4871
4944
|
.join('\n'))}
|