@promptbook/node 0.88.0-8 → 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 CHANGED
@@ -62,8 +62,6 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
62
62
 
63
63
  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
64
 
65
-
66
-
67
65
  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!
68
66
 
69
67
  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.
@@ -126,21 +124,16 @@ We also have a community of developers and users of **Promptbook**:
126
124
  - [Landing page `ptbk.io`](https://ptbk.io)
127
125
  - [Github discussions](https://github.com/webgptorg/promptbook/discussions)
128
126
  - [LinkedIn `Promptbook`](https://linkedin.com/company/promptbook)
129
- - [Facebook `Promptbook`](https://www.facebook.com/61560776453536)
127
+ - [Facebook `Promptbook`](https://www.facebook.com/61560776453536)
130
128
 
131
129
  And **Promptbook.studio** branded socials:
132
130
 
133
-
134
-
135
131
  - [Instagram `@promptbook.studio`](https://www.instagram.com/promptbook.studio/)
136
132
 
137
133
  And **Promptujeme** sub-brand:
138
134
 
139
135
  _/Subbrand for Czech clients/_
140
136
 
141
-
142
-
143
-
144
137
  - [Promptujeme.cz](https://www.promptujeme.cz/)
145
138
  - [Facebook `Promptujeme`](https://www.facebook.com/promptujeme/)
146
139
 
@@ -158,8 +151,6 @@ _/Sub-brand for images and graphics generated via Promptbook prompting/_
158
151
 
159
152
  ## 💙 The Book language
160
153
 
161
-
162
-
163
154
  Following is the documentation and blueprint of the [Book language](https://github.com/webgptorg/book).
164
155
 
165
156
  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.
@@ -209,8 +200,6 @@ Personas can have access to different knowledge, tools and actions. They can als
209
200
 
210
201
  - [PERSONA](https://github.com/webgptorg/promptbook/blob/main/documents/commands/PERSONA.md)
211
202
 
212
-
213
-
214
203
  ### **How:** Knowledge, Instruments and Actions
215
204
 
216
205
  The resources used by the personas are used to do the work.
@@ -286,11 +275,6 @@ Or you can install them separately:
286
275
 
287
276
  ## 📚 Dictionary
288
277
 
289
-
290
-
291
-
292
-
293
-
294
278
  ### 📚 Dictionary
295
279
 
296
280
  The following glossary is used to clarify certain concepts:
@@ -306,12 +290,8 @@ The following glossary is used to clarify certain concepts:
306
290
  - **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.
307
291
  - **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.
308
292
 
309
-
310
-
311
293
  _Note: Thos section is not complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
312
294
 
313
-
314
-
315
295
  #### 💯 Core concepts
316
296
 
317
297
  - [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
@@ -340,8 +320,6 @@ _Note: Thos section is not complete dictionary, more list of general AI / LLM te
340
320
  - [👮 Agent adversary expectations](https://github.com/webgptorg/promptbook/discussions/39)
341
321
  - [view more](https://github.com/webgptorg/promptbook/discussions/categories/concepts)
342
322
 
343
-
344
-
345
323
  ### Terms specific to Promptbook TypeScript implementation
346
324
 
347
325
  - Anonymous mode
@@ -349,10 +327,9 @@ _Note: Thos section is not complete dictionary, more list of general AI / LLM te
349
327
 
350
328
 
351
329
 
352
- ## 🔌 Usage in Typescript / Javascript
330
+ ## 🚂 Promptbook Engine
353
331
 
354
- - [Simple usage](./examples/usage/simple-script)
355
- - [Usage with client and remote server](./examples/usage/remote)
332
+ ![Schema of Promptbook Engine](./documents/promptbook-engine.svg)
356
333
 
357
334
  ## ➕➖ When to use Promptbook?
358
335
 
package/esm/index.es.js CHANGED
@@ -30,7 +30,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
30
30
  * @generated
31
31
  * @see https://github.com/webgptorg/promptbook
32
32
  */
33
- const PROMPTBOOK_ENGINE_VERSION = '0.88.0-8';
33
+ const PROMPTBOOK_ENGINE_VERSION = '0.88.0-9';
34
34
  /**
35
35
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
36
36
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1605,6 +1605,36 @@ function $randomToken(randomness) {
1605
1605
  * TODO: Maybe use nanoid instead https://github.com/ai/nanoid
1606
1606
  */
1607
1607
 
1608
+ /**
1609
+ * Recursively converts JSON strings to JSON objects
1610
+
1611
+ * @public exported from `@promptbook/utils`
1612
+ */
1613
+ function jsonStringsToJsons(object) {
1614
+ if (object === null) {
1615
+ return object;
1616
+ }
1617
+ if (Array.isArray(object)) {
1618
+ return object.map(jsonStringsToJsons);
1619
+ }
1620
+ if (typeof object !== 'object') {
1621
+ return object;
1622
+ }
1623
+ const newObject = { ...object };
1624
+ for (const [key, value] of Object.entries(object)) {
1625
+ if (typeof value === 'string' && isValidJsonString(value)) {
1626
+ newObject[key] = JSON.parse(value);
1627
+ }
1628
+ else {
1629
+ newObject[key] = jsonStringsToJsons(value);
1630
+ }
1631
+ }
1632
+ return newObject;
1633
+ }
1634
+ /**
1635
+ * TODO: Type the return type correctly
1636
+ */
1637
+
1608
1638
  /**
1609
1639
  * This error indicates errors during the execution of the pipeline
1610
1640
  *
@@ -1875,11 +1905,12 @@ function createTask(options) {
1875
1905
  let updatedAt = createdAt;
1876
1906
  const errors = [];
1877
1907
  const warnings = [];
1878
- const currentValue = {};
1908
+ let currentValue = {};
1879
1909
  const partialResultSubject = new Subject();
1880
1910
  // <- Note: Not using `BehaviorSubject` because on error we can't access the last value
1881
1911
  const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
1882
1912
  Object.assign(currentValue, newOngoingResult);
1913
+ // <- TODO: assign deep
1883
1914
  partialResultSubject.next(newOngoingResult);
1884
1915
  });
1885
1916
  finalResultPromise
@@ -1899,7 +1930,8 @@ function createTask(options) {
1899
1930
  // And delete `ExecutionTask.currentValue.preparedPipeline`
1900
1931
  assertsTaskSuccessful(executionResult);
1901
1932
  status = 'FINISHED';
1902
- Object.assign(currentValue, executionResult);
1933
+ currentValue = jsonStringsToJsons(executionResult);
1934
+ // <- TODO: Convert JSON values in string to JSON objects
1903
1935
  partialResultSubject.next(executionResult);
1904
1936
  }
1905
1937
  catch (error) {