@promptbook/pdf 0.88.0-1 → 0.88.0-11
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 +17 -24
- 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
|
@@ -118,6 +118,14 @@ Promptbook project is ecosystem of multiple projects and tools, following is a l
|
|
|
118
118
|
</tbody>
|
|
119
119
|
</table>
|
|
120
120
|
|
|
121
|
+
Hello world examples:
|
|
122
|
+
|
|
123
|
+
- [Hello world](https://github.com/webgptorg/hello-world)
|
|
124
|
+
- [Hello world in Node.js](https://github.com/webgptorg/hello-world-node-js)
|
|
125
|
+
- [Hello world in Next.js](https://github.com/webgptorg/hello-world-next-js)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
121
129
|
We also have a community of developers and users of **Promptbook**:
|
|
122
130
|
|
|
123
131
|
- [Discord community](https://discord.gg/x3QWNaa89N)
|
|
@@ -284,16 +292,9 @@ Or you can install them separately:
|
|
|
284
292
|
|
|
285
293
|
## 📚 Dictionary
|
|
286
294
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
### 📚 Dictionary
|
|
293
|
-
|
|
294
295
|
The following glossary is used to clarify certain concepts:
|
|
295
296
|
|
|
296
|
-
|
|
297
|
+
### General LLM / AI terms
|
|
297
298
|
|
|
298
299
|
- **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.
|
|
299
300
|
- **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.
|
|
@@ -306,11 +307,11 @@ The following glossary is used to clarify certain concepts:
|
|
|
306
307
|
|
|
307
308
|
|
|
308
309
|
|
|
309
|
-
_Note:
|
|
310
|
+
_Note: This section is not complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
|
|
310
311
|
|
|
311
312
|
|
|
312
313
|
|
|
313
|
-
|
|
314
|
+
### 💯 Core concepts
|
|
314
315
|
|
|
315
316
|
- [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
|
|
316
317
|
- [📯 Pipeline](https://github.com/webgptorg/promptbook/discussions/64)
|
|
@@ -323,7 +324,7 @@ _Note: Thos section is not complete dictionary, more list of general AI / LLM te
|
|
|
323
324
|
- [🔣 Words not tokens](https://github.com/webgptorg/promptbook/discussions/29)
|
|
324
325
|
- [☯ Separation of concerns](https://github.com/webgptorg/promptbook/discussions/32)
|
|
325
326
|
|
|
326
|
-
|
|
327
|
+
#### Advanced concepts
|
|
327
328
|
|
|
328
329
|
- [📚 Knowledge (Retrieval-augmented generation)](https://github.com/webgptorg/promptbook/discussions/41)
|
|
329
330
|
- [🌏 Remote server](https://github.com/webgptorg/promptbook/discussions/89)
|
|
@@ -340,17 +341,9 @@ _Note: Thos section is not complete dictionary, more list of general AI / LLM te
|
|
|
340
341
|
|
|
341
342
|
|
|
342
343
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
- Anonymous mode
|
|
346
|
-
- Application mode
|
|
347
|
-
|
|
344
|
+
## 🚂 Promptbook Engine
|
|
348
345
|
|
|
349
|
-
|
|
350
|
-
## 🔌 Usage in Typescript / Javascript
|
|
351
|
-
|
|
352
|
-
- [Simple usage](./examples/usage/simple-script)
|
|
353
|
-
- [Usage with client and remote server](./examples/usage/remote)
|
|
346
|
+

|
|
354
347
|
|
|
355
348
|
## ➕➖ When to use Promptbook?
|
|
356
349
|
|
|
@@ -416,13 +409,13 @@ See [TODO.md](./TODO.md)
|
|
|
416
409
|
<div style="display: flex; align-items: center; gap: 20px;">
|
|
417
410
|
|
|
418
411
|
<a href="https://promptbook.studio/">
|
|
419
|
-
<img src="./design/promptbook-studio-logo.png" alt="Partner 3" height="
|
|
412
|
+
<img src="./design/promptbook-studio-logo.png" alt="Partner 3" height="70">
|
|
420
413
|
</a>
|
|
421
414
|
|
|
422
415
|
<a href="https://technologickainkubace.org/en/about-technology-incubation/about-the-project/">
|
|
423
|
-
<img src="./other/partners/CI-Technology-Incubation.png" alt="Technology Incubation" height="
|
|
416
|
+
<img src="./other/partners/CI-Technology-Incubation.png" alt="Technology Incubation" height="70">
|
|
424
417
|
</a>
|
|
425
|
-
|
|
418
|
+
|
|
426
419
|
</div>
|
|
427
420
|
|
|
428
421
|
## 🖋️ Contributing
|
package/esm/index.es.js
CHANGED
|
@@ -5,7 +5,7 @@ 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 {
|
|
8
|
+
import { Subject } from 'rxjs';
|
|
9
9
|
import { randomBytes } from 'crypto';
|
|
10
10
|
import { forTime } from 'waitasecond';
|
|
11
11
|
import sha256 from 'crypto-js/sha256';
|
|
@@ -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-11';
|
|
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
|
|
@@ -2081,6 +2081,36 @@ function $randomToken(randomness) {
|
|
|
2081
2081
|
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
2082
2082
|
*/
|
|
2083
2083
|
|
|
2084
|
+
/**
|
|
2085
|
+
* Recursively converts JSON strings to JSON objects
|
|
2086
|
+
|
|
2087
|
+
* @public exported from `@promptbook/utils`
|
|
2088
|
+
*/
|
|
2089
|
+
function jsonStringsToJsons(object) {
|
|
2090
|
+
if (object === null) {
|
|
2091
|
+
return object;
|
|
2092
|
+
}
|
|
2093
|
+
if (Array.isArray(object)) {
|
|
2094
|
+
return object.map(jsonStringsToJsons);
|
|
2095
|
+
}
|
|
2096
|
+
if (typeof object !== 'object') {
|
|
2097
|
+
return object;
|
|
2098
|
+
}
|
|
2099
|
+
const newObject = { ...object };
|
|
2100
|
+
for (const [key, value] of Object.entries(object)) {
|
|
2101
|
+
if (typeof value === 'string' && isValidJsonString(value)) {
|
|
2102
|
+
newObject[key] = JSON.parse(value);
|
|
2103
|
+
}
|
|
2104
|
+
else {
|
|
2105
|
+
newObject[key] = jsonStringsToJsons(value);
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
return newObject;
|
|
2109
|
+
}
|
|
2110
|
+
/**
|
|
2111
|
+
* TODO: Type the return type correctly
|
|
2112
|
+
*/
|
|
2113
|
+
|
|
2084
2114
|
/**
|
|
2085
2115
|
* This error indicates problems parsing the format value
|
|
2086
2116
|
*
|
|
@@ -2307,21 +2337,43 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
2307
2337
|
function createTask(options) {
|
|
2308
2338
|
const { taskType, taskProcessCallback } = options;
|
|
2309
2339
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
2310
|
-
|
|
2340
|
+
let status = 'RUNNING';
|
|
2341
|
+
const createdAt = new Date();
|
|
2342
|
+
let updatedAt = createdAt;
|
|
2343
|
+
const errors = [];
|
|
2344
|
+
const warnings = [];
|
|
2345
|
+
let currentValue = {};
|
|
2346
|
+
const partialResultSubject = new Subject();
|
|
2347
|
+
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
2311
2348
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
2349
|
+
Object.assign(currentValue, newOngoingResult);
|
|
2350
|
+
// <- TODO: assign deep
|
|
2312
2351
|
partialResultSubject.next(newOngoingResult);
|
|
2313
2352
|
});
|
|
2314
2353
|
finalResultPromise
|
|
2315
2354
|
.catch((error) => {
|
|
2355
|
+
errors.push(error);
|
|
2316
2356
|
partialResultSubject.error(error);
|
|
2317
2357
|
})
|
|
2318
|
-
.then((
|
|
2319
|
-
if (
|
|
2358
|
+
.then((executionResult) => {
|
|
2359
|
+
if (executionResult) {
|
|
2320
2360
|
try {
|
|
2321
|
-
|
|
2322
|
-
|
|
2361
|
+
updatedAt = new Date();
|
|
2362
|
+
errors.push(...executionResult.errors);
|
|
2363
|
+
warnings.push(...executionResult.warnings);
|
|
2364
|
+
// <- TODO: !!! Only unique errors and warnings should be added (or filtered)
|
|
2365
|
+
// TODO: [🧠] !!! errors, warning, isSuccessful are redundant both in `ExecutionTask` and `ExecutionTask.currentValue`
|
|
2366
|
+
// Also maybe move `ExecutionTask.currentValue.usage` -> `ExecutionTask.usage`
|
|
2367
|
+
// And delete `ExecutionTask.currentValue.preparedPipeline`
|
|
2368
|
+
assertsTaskSuccessful(executionResult);
|
|
2369
|
+
status = 'FINISHED';
|
|
2370
|
+
currentValue = jsonStringsToJsons(executionResult);
|
|
2371
|
+
// <- TODO: [🧠] Is this a good idea to convert JSON strins to JSONs?
|
|
2372
|
+
partialResultSubject.next(executionResult);
|
|
2323
2373
|
}
|
|
2324
2374
|
catch (error) {
|
|
2375
|
+
status = 'ERROR';
|
|
2376
|
+
errors.push(error);
|
|
2325
2377
|
partialResultSubject.error(error);
|
|
2326
2378
|
}
|
|
2327
2379
|
}
|
|
@@ -2338,12 +2390,33 @@ function createTask(options) {
|
|
|
2338
2390
|
return {
|
|
2339
2391
|
taskType,
|
|
2340
2392
|
taskId,
|
|
2393
|
+
get status() {
|
|
2394
|
+
return status;
|
|
2395
|
+
// <- Note: [1] Theese must be getters to allow changing the value in the future
|
|
2396
|
+
},
|
|
2397
|
+
get createdAt() {
|
|
2398
|
+
return createdAt;
|
|
2399
|
+
// <- Note: [1]
|
|
2400
|
+
},
|
|
2401
|
+
get updatedAt() {
|
|
2402
|
+
return updatedAt;
|
|
2403
|
+
// <- Note: [1]
|
|
2404
|
+
},
|
|
2341
2405
|
asPromise,
|
|
2342
2406
|
asObservable() {
|
|
2343
2407
|
return partialResultSubject.asObservable();
|
|
2344
2408
|
},
|
|
2409
|
+
get errors() {
|
|
2410
|
+
return errors;
|
|
2411
|
+
// <- Note: [1]
|
|
2412
|
+
},
|
|
2413
|
+
get warnings() {
|
|
2414
|
+
return warnings;
|
|
2415
|
+
// <- Note: [1]
|
|
2416
|
+
},
|
|
2345
2417
|
get currentValue() {
|
|
2346
|
-
return
|
|
2418
|
+
return currentValue;
|
|
2419
|
+
// <- Note: [1]
|
|
2347
2420
|
},
|
|
2348
2421
|
};
|
|
2349
2422
|
}
|
|
@@ -4718,7 +4791,7 @@ async function executeAttempts(options) {
|
|
|
4718
4791
|
Last result:
|
|
4719
4792
|
${block($ongoingTaskResult.$resultString === null
|
|
4720
4793
|
? 'null'
|
|
4721
|
-
: $ongoingTaskResult.$resultString
|
|
4794
|
+
: spaceTrim$1($ongoingTaskResult.$resultString)
|
|
4722
4795
|
.split('\n')
|
|
4723
4796
|
.map((line) => `> ${line}`)
|
|
4724
4797
|
.join('\n'))}
|