@promptbook/cli 0.88.0-11 → 0.88.0-12

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
@@ -112,8 +112,6 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
112
112
 
113
113
  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**!
114
114
 
115
-
116
-
117
115
  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!
118
116
 
119
117
  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.
@@ -124,6 +122,9 @@ This shift is going to happen, whether we are ready for it or not. Our mission i
124
122
 
125
123
 
126
124
 
125
+
126
+
127
+
127
128
  ## 🚀 Get started
128
129
 
129
130
  Take a look at the simple starter kit with books integrated into the **Hello World** sample applications:
@@ -135,6 +136,8 @@ Take a look at the simple starter kit with books integrated into the **Hello Wor
135
136
 
136
137
 
137
138
 
139
+
140
+
138
141
  ## 💜 The Promptbook Project
139
142
 
140
143
  Promptbook project is ecosystem of multiple projects and tools, following is a list of most important pieces of the project:
@@ -176,29 +179,22 @@ Hello world examples:
176
179
  - [Hello world in Node.js](https://github.com/webgptorg/hello-world-node-js)
177
180
  - [Hello world in Next.js](https://github.com/webgptorg/hello-world-next-js)
178
181
 
179
-
180
-
181
182
  We also have a community of developers and users of **Promptbook**:
182
183
 
183
184
  - [Discord community](https://discord.gg/x3QWNaa89N)
184
185
  - [Landing page `ptbk.io`](https://ptbk.io)
185
186
  - [Github discussions](https://github.com/webgptorg/promptbook/discussions)
186
187
  - [LinkedIn `Promptbook`](https://linkedin.com/company/promptbook)
187
- - [Facebook `Promptbook`](https://www.facebook.com/61560776453536)
188
+ - [Facebook `Promptbook`](https://www.facebook.com/61560776453536)
188
189
 
189
190
  And **Promptbook.studio** branded socials:
190
191
 
191
-
192
-
193
192
  - [Instagram `@promptbook.studio`](https://www.instagram.com/promptbook.studio/)
194
193
 
195
194
  And **Promptujeme** sub-brand:
196
195
 
197
196
  _/Subbrand for Czech clients/_
198
197
 
199
-
200
-
201
-
202
198
  - [Promptujeme.cz](https://www.promptujeme.cz/)
203
199
  - [Facebook `Promptujeme`](https://www.facebook.com/promptujeme/)
204
200
 
@@ -216,8 +212,6 @@ _/Sub-brand for images and graphics generated via Promptbook prompting/_
216
212
 
217
213
  ## 💙 The Book language
218
214
 
219
-
220
-
221
215
  Following is the documentation and blueprint of the [Book language](https://github.com/webgptorg/book).
222
216
 
223
217
  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.
@@ -267,8 +261,6 @@ Personas can have access to different knowledge, tools and actions. They can als
267
261
 
268
262
  - [PERSONA](https://github.com/webgptorg/promptbook/blob/main/documents/commands/PERSONA.md)
269
263
 
270
-
271
-
272
264
  ### **How:** Knowledge, Instruments and Actions
273
265
 
274
266
  The resources used by the personas are used to do the work.
@@ -357,12 +349,8 @@ The following glossary is used to clarify certain concepts:
357
349
  - **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.
358
350
  - **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.
359
351
 
360
-
361
-
362
352
  _Note: This section is not complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
363
353
 
364
-
365
-
366
354
  ### 💯 Core concepts
367
355
 
368
356
  - [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
@@ -467,7 +455,7 @@ See [TODO.md](./TODO.md)
467
455
  <a href="https://technologickainkubace.org/en/about-technology-incubation/about-the-project/">
468
456
  <img src="./other/partners/CI-Technology-Incubation.png" alt="Technology Incubation" height="70">
469
457
  </a>
470
-
458
+
471
459
  </div>
472
460
 
473
461
  ## 🖋️ Contributing
package/esm/index.es.js CHANGED
@@ -6,13 +6,13 @@ import { basename, join, dirname, relative } from 'path';
6
6
  import { stat, access, constants, readFile, writeFile, readdir, mkdir, unlink, rm, rename, rmdir } from 'fs/promises';
7
7
  import hexEncoder from 'crypto-js/enc-hex';
8
8
  import sha256 from 'crypto-js/sha256';
9
+ import { randomBytes } from 'crypto';
9
10
  import * as dotenv from 'dotenv';
10
11
  import { spawn } from 'child_process';
11
12
  import JSZip from 'jszip';
12
13
  import { format } from 'prettier';
13
14
  import parserHtml from 'prettier/parser-html';
14
15
  import { Subject } from 'rxjs';
15
- import { randomBytes } from 'crypto';
16
16
  import { parse, unparse } from 'papaparse';
17
17
  import { SHA256 } from 'crypto-js';
18
18
  import { lookup, extension } from 'mime-types';
@@ -44,7 +44,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
44
44
  * @generated
45
45
  * @see https://github.com/webgptorg/promptbook
46
46
  */
47
- const PROMPTBOOK_ENGINE_VERSION = '0.88.0-11';
47
+ const PROMPTBOOK_ENGINE_VERSION = '0.88.0-12';
48
48
  /**
49
49
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
50
50
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -204,7 +204,7 @@ const DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [🤹‍♂️]
204
204
  *
205
205
  * @public exported from `@promptbook/core`
206
206
  */
207
- const DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [🤹‍♂️]
207
+ const DEFAULT_MAX_EXECUTION_ATTEMPTS = 10; // <- TODO: [🤹‍♂️]
208
208
  /**
209
209
  * Where to store your books
210
210
  * This is kind of a "src" for your books
@@ -1498,6 +1498,21 @@ class FileCacheStorage {
1498
1498
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
1499
1499
  */
1500
1500
 
1501
+ /**
1502
+ * Generates random token
1503
+ *
1504
+ * Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
1505
+ *
1506
+ * @private internal helper function
1507
+ * @returns secure random token
1508
+ */
1509
+ function $randomToken(randomness) {
1510
+ return randomBytes(randomness).toString('hex');
1511
+ }
1512
+ /**
1513
+ * TODO: Maybe use nanoid instead https://github.com/ai/nanoid
1514
+ */
1515
+
1501
1516
  /**
1502
1517
  * This error indicates errors during the execution of the pipeline
1503
1518
  *
@@ -1505,11 +1520,17 @@ class FileCacheStorage {
1505
1520
  */
1506
1521
  class PipelineExecutionError extends Error {
1507
1522
  constructor(message) {
1523
+ // Added id parameter
1508
1524
  super(message);
1509
1525
  this.name = 'PipelineExecutionError';
1526
+ // TODO: [🐙] DRY - Maybe $randomId
1527
+ this.id = `error-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
1510
1528
  Object.setPrototypeOf(this, PipelineExecutionError.prototype);
1511
1529
  }
1512
1530
  }
1531
+ /**
1532
+ * TODO: !!!!!! Add id to all errors
1533
+ */
1513
1534
 
1514
1535
  /**
1515
1536
  * Stores data in memory (HEAP)
@@ -4073,21 +4094,6 @@ function isPipelinePrepared(pipeline) {
4073
4094
  * - [♨] Are tasks prepared
4074
4095
  */
4075
4096
 
4076
- /**
4077
- * Generates random token
4078
- *
4079
- * Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
4080
- *
4081
- * @private internal helper function
4082
- * @returns secure random token
4083
- */
4084
- function $randomToken(randomness) {
4085
- return randomBytes(randomness).toString('hex');
4086
- }
4087
- /**
4088
- * TODO: Maybe use nanoid instead https://github.com/ai/nanoid
4089
- */
4090
-
4091
4097
  /**
4092
4098
  * Recursively converts JSON strings to JSON objects
4093
4099
 
@@ -4268,7 +4274,7 @@ const ALL_ERRORS = {
4268
4274
  * @public exported from `@promptbook/utils`
4269
4275
  */
4270
4276
  function deserializeError(error) {
4271
- const { name, stack } = error;
4277
+ const { name, stack, id } = error; // Added id
4272
4278
  let { message } = error;
4273
4279
  let ErrorClass = ALL_ERRORS[error.name];
4274
4280
  if (ErrorClass === undefined) {
@@ -4283,7 +4289,9 @@ function deserializeError(error) {
4283
4289
  ${block(stack || '')}
4284
4290
  `);
4285
4291
  }
4286
- return new ErrorClass(message);
4292
+ const deserializedError = new ErrorClass(message);
4293
+ deserializedError.id = id; // Assign id to the error object
4294
+ return deserializedError;
4287
4295
  }
4288
4296
 
4289
4297
  /**
@@ -4333,6 +4341,7 @@ function assertsTaskSuccessful(executionResult) {
4333
4341
  */
4334
4342
  function createTask(options) {
4335
4343
  const { taskType, taskProcessCallback } = options;
4344
+ // TODO: [🐙] DRY
4336
4345
  const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
4337
4346
  let status = 'RUNNING';
4338
4347
  const createdAt = new Date();
@@ -4429,19 +4438,21 @@ function createTask(options) {
4429
4438
  */
4430
4439
  function serializeError(error) {
4431
4440
  const { name, message, stack } = error;
4441
+ const { id } = error;
4432
4442
  if (!Object.keys(ALL_ERRORS).includes(name)) {
4433
4443
  console.error(spaceTrim((block) => `
4434
-
4444
+
4435
4445
  Cannot serialize error with name "${name}"
4436
4446
 
4437
4447
  ${block(stack || message)}
4438
-
4448
+
4439
4449
  `));
4440
4450
  }
4441
4451
  return {
4442
4452
  name: name,
4443
4453
  message,
4444
4454
  stack,
4455
+ id, // Include id in the serialized object
4445
4456
  };
4446
4457
  }
4447
4458
 
@@ -5174,6 +5185,9 @@ function countCharacters(text) {
5174
5185
  text = text.replace(/\p{Extended_Pictographic}(\u{200D}\p{Extended_Pictographic})*/gu, '-');
5175
5186
  return text.length;
5176
5187
  }
5188
+ /**
5189
+ * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
5190
+ */
5177
5191
 
5178
5192
  /**
5179
5193
  * Number of characters per standard line with 11pt Arial font size.
@@ -5205,6 +5219,9 @@ function countLines(text) {
5205
5219
  const lines = text.split('\n');
5206
5220
  return lines.reduce((count, line) => count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 0);
5207
5221
  }
5222
+ /**
5223
+ * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
5224
+ */
5208
5225
 
5209
5226
  /**
5210
5227
  * Counts number of pages in the text
@@ -5216,6 +5233,9 @@ function countLines(text) {
5216
5233
  function countPages(text) {
5217
5234
  return Math.ceil(countLines(text) / LINES_PER_STANDARD_PAGE);
5218
5235
  }
5236
+ /**
5237
+ * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
5238
+ */
5219
5239
 
5220
5240
  /**
5221
5241
  * Counts number of paragraphs in the text
@@ -5225,6 +5245,9 @@ function countPages(text) {
5225
5245
  function countParagraphs(text) {
5226
5246
  return text.split(/\n\s*\n/).filter((paragraph) => paragraph.trim() !== '').length;
5227
5247
  }
5248
+ /**
5249
+ * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
5250
+ */
5228
5251
 
5229
5252
  /**
5230
5253
  * Split text into sentences
@@ -5242,6 +5265,9 @@ function splitIntoSentences(text) {
5242
5265
  function countSentences(text) {
5243
5266
  return splitIntoSentences(text).length;
5244
5267
  }
5268
+ /**
5269
+ * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
5270
+ */
5245
5271
 
5246
5272
  /**
5247
5273
  * Counts number of words in the text
@@ -5255,6 +5281,9 @@ function countWords(text) {
5255
5281
  text = text.replace(/([a-z])([A-Z])/g, '$1 $2');
5256
5282
  return text.split(/[^a-zа-я0-9]+/i).filter((word) => word.length > 0).length;
5257
5283
  }
5284
+ /**
5285
+ * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
5286
+ */
5258
5287
 
5259
5288
  /**
5260
5289
  * Index of all counter functions
@@ -12341,7 +12370,7 @@ function $initializeRunCommand(program) {
12341
12370
  pipeline,
12342
12371
  tools,
12343
12372
  isNotPreparedWarningSupressed: true,
12344
- maxExecutionAttempts: 3,
12373
+ maxExecutionAttempts: DEFAULT_MAX_EXECUTION_ATTEMPTS,
12345
12374
  // <- TODO: Why "LLM execution failed undefinedx"
12346
12375
  maxParallelCount: 1, // <- TODO: Pass CLI argument
12347
12376
  });