@promptbook/website-crawler 0.88.0-1 → 0.88.0-9
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 +3 -26
- 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
|
@@ -58,8 +58,6 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
|
|
|
58
58
|
|
|
59
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**!
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
61
|
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!
|
|
64
62
|
|
|
65
63
|
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.
|
|
@@ -122,21 +120,16 @@ We also have a community of developers and users of **Promptbook**:
|
|
|
122
120
|
- [Landing page `ptbk.io`](https://ptbk.io)
|
|
123
121
|
- [Github discussions](https://github.com/webgptorg/promptbook/discussions)
|
|
124
122
|
- [LinkedIn `Promptbook`](https://linkedin.com/company/promptbook)
|
|
125
|
-
- [Facebook `Promptbook`](https://www.facebook.com/61560776453536)
|
|
123
|
+
- [Facebook `Promptbook`](https://www.facebook.com/61560776453536)
|
|
126
124
|
|
|
127
125
|
And **Promptbook.studio** branded socials:
|
|
128
126
|
|
|
129
|
-
|
|
130
|
-
|
|
131
127
|
- [Instagram `@promptbook.studio`](https://www.instagram.com/promptbook.studio/)
|
|
132
128
|
|
|
133
129
|
And **Promptujeme** sub-brand:
|
|
134
130
|
|
|
135
131
|
_/Subbrand for Czech clients/_
|
|
136
132
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
133
|
- [Promptujeme.cz](https://www.promptujeme.cz/)
|
|
141
134
|
- [Facebook `Promptujeme`](https://www.facebook.com/promptujeme/)
|
|
142
135
|
|
|
@@ -154,8 +147,6 @@ _/Sub-brand for images and graphics generated via Promptbook prompting/_
|
|
|
154
147
|
|
|
155
148
|
## 💙 The Book language
|
|
156
149
|
|
|
157
|
-
|
|
158
|
-
|
|
159
150
|
Following is the documentation and blueprint of the [Book language](https://github.com/webgptorg/book).
|
|
160
151
|
|
|
161
152
|
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.
|
|
@@ -205,8 +196,6 @@ Personas can have access to different knowledge, tools and actions. They can als
|
|
|
205
196
|
|
|
206
197
|
- [PERSONA](https://github.com/webgptorg/promptbook/blob/main/documents/commands/PERSONA.md)
|
|
207
198
|
|
|
208
|
-
|
|
209
|
-
|
|
210
199
|
### **How:** Knowledge, Instruments and Actions
|
|
211
200
|
|
|
212
201
|
The resources used by the personas are used to do the work.
|
|
@@ -282,11 +271,6 @@ Or you can install them separately:
|
|
|
282
271
|
|
|
283
272
|
## 📚 Dictionary
|
|
284
273
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
274
|
### 📚 Dictionary
|
|
291
275
|
|
|
292
276
|
The following glossary is used to clarify certain concepts:
|
|
@@ -302,12 +286,8 @@ The following glossary is used to clarify certain concepts:
|
|
|
302
286
|
- **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.
|
|
303
287
|
- **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.
|
|
304
288
|
|
|
305
|
-
|
|
306
|
-
|
|
307
289
|
_Note: Thos section is not complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
|
|
308
290
|
|
|
309
|
-
|
|
310
|
-
|
|
311
291
|
#### 💯 Core concepts
|
|
312
292
|
|
|
313
293
|
- [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
|
|
@@ -336,8 +316,6 @@ _Note: Thos section is not complete dictionary, more list of general AI / LLM te
|
|
|
336
316
|
- [👮 Agent adversary expectations](https://github.com/webgptorg/promptbook/discussions/39)
|
|
337
317
|
- [view more](https://github.com/webgptorg/promptbook/discussions/categories/concepts)
|
|
338
318
|
|
|
339
|
-
|
|
340
|
-
|
|
341
319
|
### Terms specific to Promptbook TypeScript implementation
|
|
342
320
|
|
|
343
321
|
- Anonymous mode
|
|
@@ -345,10 +323,9 @@ _Note: Thos section is not complete dictionary, more list of general AI / LLM te
|
|
|
345
323
|
|
|
346
324
|
|
|
347
325
|
|
|
348
|
-
##
|
|
326
|
+
## 🚂 Promptbook Engine
|
|
349
327
|
|
|
350
|
-
|
|
351
|
-
- [Usage with client and remote server](./examples/usage/remote)
|
|
328
|
+

|
|
352
329
|
|
|
353
330
|
## ➕➖ When to use Promptbook?
|
|
354
331
|
|
package/esm/index.es.js
CHANGED
|
@@ -7,7 +7,7 @@ import { mkdir, rm } from 'fs/promises';
|
|
|
7
7
|
import { basename, join, dirname } from 'path';
|
|
8
8
|
import { format } from 'prettier';
|
|
9
9
|
import parserHtml from 'prettier/parser-html';
|
|
10
|
-
import {
|
|
10
|
+
import { Subject } from 'rxjs';
|
|
11
11
|
import { randomBytes } from 'crypto';
|
|
12
12
|
import { forTime } from 'waitasecond';
|
|
13
13
|
import sha256 from 'crypto-js/sha256';
|
|
@@ -29,7 +29,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
29
29
|
* @generated
|
|
30
30
|
* @see https://github.com/webgptorg/promptbook
|
|
31
31
|
*/
|
|
32
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.88.0-
|
|
32
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.88.0-9';
|
|
33
33
|
/**
|
|
34
34
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
35
35
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2219,6 +2219,36 @@ function $randomToken(randomness) {
|
|
|
2219
2219
|
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
2220
2220
|
*/
|
|
2221
2221
|
|
|
2222
|
+
/**
|
|
2223
|
+
* Recursively converts JSON strings to JSON objects
|
|
2224
|
+
|
|
2225
|
+
* @public exported from `@promptbook/utils`
|
|
2226
|
+
*/
|
|
2227
|
+
function jsonStringsToJsons(object) {
|
|
2228
|
+
if (object === null) {
|
|
2229
|
+
return object;
|
|
2230
|
+
}
|
|
2231
|
+
if (Array.isArray(object)) {
|
|
2232
|
+
return object.map(jsonStringsToJsons);
|
|
2233
|
+
}
|
|
2234
|
+
if (typeof object !== 'object') {
|
|
2235
|
+
return object;
|
|
2236
|
+
}
|
|
2237
|
+
const newObject = { ...object };
|
|
2238
|
+
for (const [key, value] of Object.entries(object)) {
|
|
2239
|
+
if (typeof value === 'string' && isValidJsonString(value)) {
|
|
2240
|
+
newObject[key] = JSON.parse(value);
|
|
2241
|
+
}
|
|
2242
|
+
else {
|
|
2243
|
+
newObject[key] = jsonStringsToJsons(value);
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
return newObject;
|
|
2247
|
+
}
|
|
2248
|
+
/**
|
|
2249
|
+
* TODO: Type the return type correctly
|
|
2250
|
+
*/
|
|
2251
|
+
|
|
2222
2252
|
/**
|
|
2223
2253
|
* This error indicates problems parsing the format value
|
|
2224
2254
|
*
|
|
@@ -2422,21 +2452,43 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
2422
2452
|
function createTask(options) {
|
|
2423
2453
|
const { taskType, taskProcessCallback } = options;
|
|
2424
2454
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
2425
|
-
|
|
2455
|
+
let status = 'RUNNING';
|
|
2456
|
+
const createdAt = new Date();
|
|
2457
|
+
let updatedAt = createdAt;
|
|
2458
|
+
const errors = [];
|
|
2459
|
+
const warnings = [];
|
|
2460
|
+
let currentValue = {};
|
|
2461
|
+
const partialResultSubject = new Subject();
|
|
2462
|
+
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2426
2463
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
2464
|
+
Object.assign(currentValue, newOngoingResult);
|
|
2465
|
+
// <- TODO: assign deep
|
|
2427
2466
|
partialResultSubject.next(newOngoingResult);
|
|
2428
2467
|
});
|
|
2429
2468
|
finalResultPromise
|
|
2430
2469
|
.catch((error) => {
|
|
2470
|
+
errors.push(error);
|
|
2431
2471
|
partialResultSubject.error(error);
|
|
2432
2472
|
})
|
|
2433
|
-
.then((
|
|
2434
|
-
if (
|
|
2473
|
+
.then((executionResult) => {
|
|
2474
|
+
if (executionResult) {
|
|
2435
2475
|
try {
|
|
2436
|
-
|
|
2437
|
-
|
|
2476
|
+
updatedAt = new Date();
|
|
2477
|
+
errors.push(...executionResult.errors);
|
|
2478
|
+
warnings.push(...executionResult.warnings);
|
|
2479
|
+
// <- TODO: !!! Only unique errors and warnings should be added (or filtered)
|
|
2480
|
+
// TODO: [🧠] !!! errors, warning, isSuccessful are redundant both in `ExecutionTask` and `ExecutionTask.currentValue`
|
|
2481
|
+
// Also maybe move `ExecutionTask.currentValue.usage` -> `ExecutionTask.usage`
|
|
2482
|
+
// And delete `ExecutionTask.currentValue.preparedPipeline`
|
|
2483
|
+
assertsTaskSuccessful(executionResult);
|
|
2484
|
+
status = 'FINISHED';
|
|
2485
|
+
currentValue = jsonStringsToJsons(executionResult);
|
|
2486
|
+
// <- TODO: Convert JSON values in string to JSON objects
|
|
2487
|
+
partialResultSubject.next(executionResult);
|
|
2438
2488
|
}
|
|
2439
2489
|
catch (error) {
|
|
2490
|
+
status = 'ERROR';
|
|
2491
|
+
errors.push(error);
|
|
2440
2492
|
partialResultSubject.error(error);
|
|
2441
2493
|
}
|
|
2442
2494
|
}
|
|
@@ -2453,12 +2505,33 @@ function createTask(options) {
|
|
|
2453
2505
|
return {
|
|
2454
2506
|
taskType,
|
|
2455
2507
|
taskId,
|
|
2508
|
+
get status() {
|
|
2509
|
+
return status;
|
|
2510
|
+
// <- Note: [1] Theese must be getters to allow changing the value in the future
|
|
2511
|
+
},
|
|
2512
|
+
get createdAt() {
|
|
2513
|
+
return createdAt;
|
|
2514
|
+
// <- Note: [1]
|
|
2515
|
+
},
|
|
2516
|
+
get updatedAt() {
|
|
2517
|
+
return updatedAt;
|
|
2518
|
+
// <- Note: [1]
|
|
2519
|
+
},
|
|
2456
2520
|
asPromise,
|
|
2457
2521
|
asObservable() {
|
|
2458
2522
|
return partialResultSubject.asObservable();
|
|
2459
2523
|
},
|
|
2524
|
+
get errors() {
|
|
2525
|
+
return errors;
|
|
2526
|
+
// <- Note: [1]
|
|
2527
|
+
},
|
|
2528
|
+
get warnings() {
|
|
2529
|
+
return warnings;
|
|
2530
|
+
// <- Note: [1]
|
|
2531
|
+
},
|
|
2460
2532
|
get currentValue() {
|
|
2461
|
-
return
|
|
2533
|
+
return currentValue;
|
|
2534
|
+
// <- Note: [1]
|
|
2462
2535
|
},
|
|
2463
2536
|
};
|
|
2464
2537
|
}
|
|
@@ -4719,7 +4792,7 @@ async function executeAttempts(options) {
|
|
|
4719
4792
|
Last result:
|
|
4720
4793
|
${block($ongoingTaskResult.$resultString === null
|
|
4721
4794
|
? 'null'
|
|
4722
|
-
: $ongoingTaskResult.$resultString
|
|
4795
|
+
: spaceTrim($ongoingTaskResult.$resultString)
|
|
4723
4796
|
.split('\n')
|
|
4724
4797
|
.map((line) => `> ${line}`)
|
|
4725
4798
|
.join('\n'))}
|