@promptbook/remote-client 0.88.0-8 → 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 +21 -27
- package/esm/index.es.js +27 -3
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/utils.index.d.ts +2 -0
- 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/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 +3 -2
- package/umd/index.umd.js +30 -7
- 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/remote-client`
|
|
31
27
|
|
|
32
28
|
- Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
|
@@ -70,6 +66,9 @@ This shift is going to happen, whether we are ready for it or not. Our mission i
|
|
|
70
66
|
|
|
71
67
|
|
|
72
68
|
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
73
72
|
## 🚀 Get started
|
|
74
73
|
|
|
75
74
|
Take a look at the simple starter kit with books integrated into the **Hello World** sample applications:
|
|
@@ -81,6 +80,8 @@ Take a look at the simple starter kit with books integrated into the **Hello Wor
|
|
|
81
80
|
|
|
82
81
|
|
|
83
82
|
|
|
83
|
+
|
|
84
|
+
|
|
84
85
|
## 💜 The Promptbook Project
|
|
85
86
|
|
|
86
87
|
Promptbook project is ecosystem of multiple projects and tools, following is a list of most important pieces of the project:
|
|
@@ -116,6 +117,14 @@ Promptbook project is ecosystem of multiple projects and tools, following is a l
|
|
|
116
117
|
</tbody>
|
|
117
118
|
</table>
|
|
118
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
|
+
|
|
126
|
+
|
|
127
|
+
|
|
119
128
|
We also have a community of developers and users of **Promptbook**:
|
|
120
129
|
|
|
121
130
|
- [Discord community](https://discord.gg/x3QWNaa89N)
|
|
@@ -282,16 +291,9 @@ Or you can install them separately:
|
|
|
282
291
|
|
|
283
292
|
## 📚 Dictionary
|
|
284
293
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
### 📚 Dictionary
|
|
291
|
-
|
|
292
294
|
The following glossary is used to clarify certain concepts:
|
|
293
295
|
|
|
294
|
-
|
|
296
|
+
### General LLM / AI terms
|
|
295
297
|
|
|
296
298
|
- **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.
|
|
297
299
|
- **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.
|
|
@@ -304,11 +306,11 @@ The following glossary is used to clarify certain concepts:
|
|
|
304
306
|
|
|
305
307
|
|
|
306
308
|
|
|
307
|
-
_Note:
|
|
309
|
+
_Note: This section is not complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
|
|
308
310
|
|
|
309
311
|
|
|
310
312
|
|
|
311
|
-
|
|
313
|
+
### 💯 Core concepts
|
|
312
314
|
|
|
313
315
|
- [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
|
|
314
316
|
- [📯 Pipeline](https://github.com/webgptorg/promptbook/discussions/64)
|
|
@@ -321,7 +323,7 @@ _Note: Thos section is not complete dictionary, more list of general AI / LLM te
|
|
|
321
323
|
- [🔣 Words not tokens](https://github.com/webgptorg/promptbook/discussions/29)
|
|
322
324
|
- [☯ Separation of concerns](https://github.com/webgptorg/promptbook/discussions/32)
|
|
323
325
|
|
|
324
|
-
|
|
326
|
+
#### Advanced concepts
|
|
325
327
|
|
|
326
328
|
- [📚 Knowledge (Retrieval-augmented generation)](https://github.com/webgptorg/promptbook/discussions/41)
|
|
327
329
|
- [🌏 Remote server](https://github.com/webgptorg/promptbook/discussions/89)
|
|
@@ -338,17 +340,9 @@ _Note: Thos section is not complete dictionary, more list of general AI / LLM te
|
|
|
338
340
|
|
|
339
341
|
|
|
340
342
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
- Anonymous mode
|
|
344
|
-
- Application mode
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
## 🔌 Usage in Typescript / Javascript
|
|
343
|
+
## 🚂 Promptbook Engine
|
|
349
344
|
|
|
350
|
-
|
|
351
|
-
- [Usage with client and remote server](./examples/usage/remote)
|
|
345
|
+

|
|
352
346
|
|
|
353
347
|
## ➕➖ When to use Promptbook?
|
|
354
348
|
|
|
@@ -414,11 +408,11 @@ See [TODO.md](./TODO.md)
|
|
|
414
408
|
<div style="display: flex; align-items: center; gap: 20px;">
|
|
415
409
|
|
|
416
410
|
<a href="https://promptbook.studio/">
|
|
417
|
-
<img src="./design/promptbook-studio-logo.png" alt="Partner 3" height="
|
|
411
|
+
<img src="./design/promptbook-studio-logo.png" alt="Partner 3" height="70">
|
|
418
412
|
</a>
|
|
419
413
|
|
|
420
414
|
<a href="https://technologickainkubace.org/en/about-technology-incubation/about-the-project/">
|
|
421
|
-
<img src="./other/partners/CI-Technology-Incubation.png" alt="Technology Incubation" height="
|
|
415
|
+
<img src="./other/partners/CI-Technology-Incubation.png" alt="Technology Incubation" height="70">
|
|
422
416
|
</a>
|
|
423
417
|
|
|
424
418
|
</div>
|
package/esm/index.es.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import spaceTrim$1, { spaceTrim } from 'spacetrim';
|
|
2
|
+
import { randomBytes } from 'crypto';
|
|
2
3
|
import { io } from 'socket.io-client';
|
|
3
4
|
import { SHA256 } from 'crypto-js';
|
|
4
5
|
import hexEncoder from 'crypto-js/enc-hex';
|
|
@@ -19,7 +20,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
19
20
|
* @generated
|
|
20
21
|
* @see https://github.com/webgptorg/promptbook
|
|
21
22
|
*/
|
|
22
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.88.0
|
|
23
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.88.0';
|
|
23
24
|
/**
|
|
24
25
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
25
26
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -193,6 +194,21 @@ class ParseError extends Error {
|
|
|
193
194
|
* TODO: Maybe split `ParseError` and `ApplyError`
|
|
194
195
|
*/
|
|
195
196
|
|
|
197
|
+
/**
|
|
198
|
+
* Generates random token
|
|
199
|
+
*
|
|
200
|
+
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
201
|
+
*
|
|
202
|
+
* @private internal helper function
|
|
203
|
+
* @returns secure random token
|
|
204
|
+
*/
|
|
205
|
+
function $randomToken(randomness) {
|
|
206
|
+
return randomBytes(randomness).toString('hex');
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
210
|
+
*/
|
|
211
|
+
|
|
196
212
|
/**
|
|
197
213
|
* This error indicates errors during the execution of the pipeline
|
|
198
214
|
*
|
|
@@ -200,11 +216,17 @@ class ParseError extends Error {
|
|
|
200
216
|
*/
|
|
201
217
|
class PipelineExecutionError extends Error {
|
|
202
218
|
constructor(message) {
|
|
219
|
+
// Added id parameter
|
|
203
220
|
super(message);
|
|
204
221
|
this.name = 'PipelineExecutionError';
|
|
222
|
+
// TODO: [🐙] DRY - Maybe $randomId
|
|
223
|
+
this.id = `error-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
205
224
|
Object.setPrototypeOf(this, PipelineExecutionError.prototype);
|
|
206
225
|
}
|
|
207
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* TODO: !!!!!! Add id to all errors
|
|
229
|
+
*/
|
|
208
230
|
|
|
209
231
|
/**
|
|
210
232
|
* This error indicates that the promptbook object has valid syntax (=can be parsed) but contains logical errors (like circular dependencies)
|
|
@@ -460,7 +482,7 @@ const ALL_ERRORS = {
|
|
|
460
482
|
* @public exported from `@promptbook/utils`
|
|
461
483
|
*/
|
|
462
484
|
function deserializeError(error) {
|
|
463
|
-
const { name, stack } = error;
|
|
485
|
+
const { name, stack, id } = error; // Added id
|
|
464
486
|
let { message } = error;
|
|
465
487
|
let ErrorClass = ALL_ERRORS[error.name];
|
|
466
488
|
if (ErrorClass === undefined) {
|
|
@@ -475,7 +497,9 @@ function deserializeError(error) {
|
|
|
475
497
|
${block(stack || '')}
|
|
476
498
|
`);
|
|
477
499
|
}
|
|
478
|
-
|
|
500
|
+
const deserializedError = new ErrorClass(message);
|
|
501
|
+
deserializedError.id = id; // Assign id to the error object
|
|
502
|
+
return deserializedError;
|
|
479
503
|
}
|
|
480
504
|
|
|
481
505
|
/**
|