@promptbook/utils 0.73.0 → 0.74.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.
Files changed (40) hide show
  1. package/README.md +176 -3
  2. package/esm/index.es.js +22 -10
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/anthropic-claude.index.d.ts +2 -2
  5. package/esm/typings/src/_packages/azure-openai.index.d.ts +2 -2
  6. package/esm/typings/src/_packages/browser.index.d.ts +2 -2
  7. package/esm/typings/src/_packages/cli.index.d.ts +2 -2
  8. package/esm/typings/src/_packages/core.index.d.ts +7 -3
  9. package/esm/typings/src/_packages/documents.index.d.ts +2 -2
  10. package/esm/typings/src/_packages/execute-javascript.index.d.ts +2 -2
  11. package/esm/typings/src/_packages/fake-llm.index.d.ts +2 -2
  12. package/esm/typings/src/_packages/langtail.index.d.ts +2 -2
  13. package/esm/typings/src/_packages/legacy-documents.index.d.ts +2 -2
  14. package/esm/typings/src/_packages/markdown-utils.index.d.ts +2 -2
  15. package/esm/typings/src/_packages/node.index.d.ts +2 -2
  16. package/esm/typings/src/_packages/openai.index.d.ts +2 -2
  17. package/esm/typings/src/_packages/pdf.index.d.ts +2 -2
  18. package/esm/typings/src/_packages/remote-client.index.d.ts +2 -2
  19. package/esm/typings/src/_packages/remote-server.index.d.ts +2 -2
  20. package/esm/typings/src/_packages/utils.index.d.ts +2 -2
  21. package/esm/typings/src/_packages/website-crawler.index.d.ts +2 -2
  22. package/esm/typings/src/cli/cli-commands/make.d.ts +0 -1
  23. package/esm/typings/src/cli/cli-commands/run.d.ts +14 -0
  24. package/esm/typings/src/cli/promptbookCli.d.ts +1 -0
  25. package/esm/typings/src/cli/test/ptbk.d.ts +5 -2
  26. package/esm/typings/src/commands/{PROMPTBOOK_VERSION/PromptbookVersionCommand.d.ts → BOOK_VERSION/BookVersionCommand.d.ts} +4 -4
  27. package/esm/typings/src/commands/BOOK_VERSION/bookVersionCommandParser.d.ts +9 -0
  28. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +1 -1
  29. package/esm/typings/src/commands/index.d.ts +1 -1
  30. package/esm/typings/src/config.d.ts +6 -0
  31. package/esm/typings/src/storage/blackhole/BlackholeStorage.d.ts +33 -0
  32. package/esm/typings/src/storage/memory/MemoryStorage.d.ts +1 -1
  33. package/esm/typings/src/storage/{memory/utils → utils}/PrefixStorage.d.ts +1 -1
  34. package/esm/typings/src/version.d.ts +13 -2
  35. package/package.json +1 -1
  36. package/umd/index.umd.js +23 -10
  37. package/umd/index.umd.js.map +1 -1
  38. package/esm/typings/src/commands/PROMPTBOOK_VERSION/promptbookVersionCommandParser.d.ts +0 -9
  39. /package/esm/typings/src/commands/{PROMPTBOOK_VERSION/promptbookVersionCommand.test.d.ts → BOOK_VERSION/bookVersionCommand.test.d.ts} +0 -0
  40. /package/esm/typings/src/storage/{memory → local-storage}/utils/makePromptbookStorageFromWebStorage.d.ts +0 -0
package/README.md CHANGED
@@ -24,6 +24,10 @@ Build responsible, controlled and transparent applications on top of LLM models!
24
24
 
25
25
 
26
26
 
27
+ <blockquote style="color: #ff8811">
28
+ <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>.
29
+ </blockquote>
30
+
27
31
  ## 📦 Package `@promptbook/utils`
28
32
 
29
33
  - Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
@@ -189,12 +193,63 @@ In all of these situations, but especially in 3., the **✨ Promptbook can make
189
193
 
190
194
 
191
195
 
196
+
197
+
198
+
199
+ ## 💜 The Promptbook Project
200
+
201
+ Promptbook project is ecosystem of multiple projects and tools, following is a list of most important pieces of the project:
202
+
203
+ <table>
204
+ <thead>
205
+ <tr>
206
+ <th>Project</th>
207
+ <th>Description</th>
208
+ <th>Link</th>
209
+ </tr>
210
+ </thead>
211
+ <tbody>
212
+ <tr>
213
+ <td>Core</td>
214
+ <td>Promptbook core is a description and documentation of basic innerworkings how should be Promptbook implemented and defines which fetures must be descriable by book language</td>
215
+ <td rowspan=2>https://ptbk.io<br/>https://github.com/webgptorg/book</td>
216
+ </tr>
217
+ <tr>
218
+ <td>Book language</td>
219
+ <td>
220
+ Book is a markdown-like language to define core entities like projects, pipelines, knowledge,.... It is designed to be understandable by non-programmers and non-technical people
221
+ </td>
222
+ </tr>
223
+ <tr>
224
+ <td>Promptbook typescript project</td>
225
+ <td>Implementation of Promptbook in TypeScript published into multiple packages to NPM</td>
226
+ <td>https://github.com/webgptorg/promptbook + Multiple packages on NPM</td>
227
+ </tr>
228
+ <tr>
229
+ <td>Promptbook studio</td>
230
+ <td>No-code studio to write book without need to write even the markdown</td>
231
+ <td rowspan=2>https://promptbook.studio<br/>https://github.com/hejny/promptbook-studio</td>
232
+ </tr>
233
+ <tr>
234
+ <td>Promptbook miniapps</td>
235
+ <td>Builder of LLM miniapps from book notation</td>
236
+ </tr>
237
+ </tbody>
238
+ </table>
239
+
240
+
241
+
192
242
  ## 💙 Book language _(for prompt-engineer)_
193
243
 
194
- Promptbook [pipelines](https://github.com/webgptorg/promptbook/discussions/64) are written in markdown-like language called [Book](https://github.com/webgptorg/book). It is designed to be understandable by non-programmers and non-technical people.
195
244
 
196
245
 
197
246
 
247
+ ## 💙 The blueprint of book language
248
+
249
+ Following is the documentation and blueprint of the Book language.
250
+
251
+ ### Example
252
+
198
253
  ```markdown
199
254
  # 🌟 My first Book
200
255
 
@@ -210,6 +265,60 @@ Promptbook [pipelines](https://github.com/webgptorg/promptbook/discussions/64) a
210
265
  -> {article}
211
266
  ```
212
267
 
268
+ ### Goals and principles of book language
269
+
270
+ File is designed to be easy to read and write. It is strict subset of markdown. It is designed to be understandable by both humans and machines and without specific knowledge of the language.
271
+
272
+ It has file with `.ptbk.md` or `.book` extension with `UTF-8` non BOM encoding.
273
+
274
+ As it is source code, it can leverage all the features of version control systems like git and does not suffer from the problems of binary formats, proprietary formats, or no-code solutions.
275
+
276
+ But unlike programming languages, it is designed to be understandable by non-programmers and non-technical people.
277
+
278
+ ### Structure
279
+
280
+ Book is divided into sections. Each section starts with heading. The language itself is not sensitive to the type of heading _(`h1`, `h2`, `h3`, ...)_ but it is recommended to use `h1` for header section and `h2` for other sections.
281
+
282
+ ### Header
283
+
284
+ Header is the first section of the book. It contains metadata about the pipeline. It is recommended to use `h1` heading for header section but it is not required.
285
+
286
+ ### Parameter
287
+
288
+ Foo bar
289
+
290
+ #### Parameter names
291
+
292
+ Reserved words:
293
+
294
+ - _each command_ like `PERSONA`, `EXPECT`, `KNOWLEDGE`, etc.
295
+ - `content`
296
+ - `context`
297
+ - `knowledge`
298
+ - `examples`
299
+ - `modelName`
300
+ - `currentDate`
301
+
302
+ #### Parameter notation
303
+
304
+ ### Template
305
+
306
+ Todo todo
307
+
308
+ ### Command
309
+
310
+ Todo todo
311
+
312
+ ### Block
313
+
314
+ Todo todo
315
+
316
+ ### Return parameter
317
+
318
+ ### Examples
319
+
320
+
321
+
213
322
  ## 📦 Packages _(for developers)_
214
323
 
215
324
  This library is divided into several packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
@@ -248,11 +357,66 @@ Or you can install them separately:
248
357
 
249
358
 
250
359
 
360
+
361
+
362
+
251
363
  ## 📚 Dictionary
252
364
 
365
+
366
+
367
+
368
+
369
+
370
+ ### 📚 Dictionary
371
+
253
372
  The following glossary is used to clarify certain concepts:
254
373
 
255
- ### Core concepts
374
+ #### General LLM / AI terms
375
+
376
+ - **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.
377
+ - **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.
378
+ - **Fine-tuning** is a process where a pre-trained AI model is further trained on a specific dataset to improve its performance on a specific task.
379
+ - **Zero-shot learning** is a machine learning paradigm where a model is trained to perform a task without any labeled examples. Instead, the model is provided with a description of the task and is expected to generate the correct output.
380
+ - **Few-shot learning** is a machine learning paradigm where a model is trained to perform a task with only a few labeled examples. This is in contrast to traditional machine learning, where models are trained on large datasets.
381
+ - **Meta-learning** is a machine learning paradigm where a model is trained on a variety of tasks and is able to learn new tasks with minimal additional training. This is achieved by learning a set of meta-parameters that can be quickly adapted to new tasks.
382
+ - **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.
383
+ - **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.
384
+
385
+
386
+
387
+ _Note: Thos section is not complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
388
+
389
+ #### Promptbook core
390
+
391
+ - **Organization** _(legacy name collection)_ group jobs, workforce, knowledge, instruments, and actions into one package. Entities in one organization can share resources (= import resources from each other).
392
+ - **Jobs**
393
+ - **Task**
394
+ - **Subtask**
395
+ - **Workforce**
396
+ - **Persona**
397
+ - **Team**
398
+ - **Role**
399
+ - **Knowledge**
400
+ - **Public**
401
+ - **Private**
402
+ - **Protected**
403
+ - **Instruments**
404
+ - **Actions**
405
+
406
+ #### Book language
407
+
408
+ - **Book file**
409
+ - **Section**
410
+ - **Heading**
411
+ - **Description**
412
+ - **Command**
413
+ - **Block**
414
+ - **Return statement**
415
+ - **Comment**
416
+ - **Import**
417
+ - **Scope**
418
+
419
+ #### 💯 Core concepts
256
420
 
257
421
  - [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
258
422
  - [📯 Pipeline](https://github.com/webgptorg/promptbook/discussions/64)
@@ -265,7 +429,7 @@ The following glossary is used to clarify certain concepts:
265
429
  - [🔣 Words not tokens](https://github.com/webgptorg/promptbook/discussions/29)
266
430
  - [☯ Separation of concerns](https://github.com/webgptorg/promptbook/discussions/32)
267
431
 
268
- ### Advanced concepts
432
+ ##### Advanced concepts
269
433
 
270
434
  - [📚 Knowledge (Retrieval-augmented generation)](https://github.com/webgptorg/promptbook/discussions/41)
271
435
  - [🌏 Remote server](https://github.com/webgptorg/promptbook/discussions/89)
@@ -280,6 +444,15 @@ The following glossary is used to clarify certain concepts:
280
444
  - [👮 Agent adversary expectations](https://github.com/webgptorg/promptbook/discussions/39)
281
445
  - [view more](https://github.com/webgptorg/promptbook/discussions/categories/concepts)
282
446
 
447
+
448
+
449
+ ### Terms specific to Promptbook TypeScript implementation
450
+
451
+ - Anonymous mode
452
+ - Application mode
453
+
454
+
455
+
283
456
  ## 🔌 Usage in Typescript / Javascript
284
457
 
285
458
  - [Simple usage](./examples/usage/simple-script)
package/esm/index.es.js CHANGED
@@ -3,10 +3,20 @@ import { basename } from 'path';
3
3
 
4
4
  // ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
5
5
  /**
6
- * The version of the Promptbook library
6
+ * The version of the Book language
7
+ *
8
+ * @see https://github.com/webgptorg/book
9
+ */
10
+ var BOOK_LANGUAGE_VERSION = '1.0.0';
11
+ /**
12
+ * The version of the Promptbook engine
13
+ *
14
+ * @see https://github.com/webgptorg/promptbook
15
+ */
16
+ var PROMPTBOOK_ENGINE_VERSION = '0.74.0-10';
17
+ /**
18
+ * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
7
19
  */
8
- var PROMPTBOOK_VERSION = '0.72.0';
9
- // TODO: [main] !!!! List here all the versions and annotate + put into script
10
20
 
11
21
  /*! *****************************************************************************
12
22
  Copyright (c) Microsoft Corporation.
@@ -1287,10 +1297,12 @@ function countLines(text) {
1287
1297
  * @public exported from `@promptbook/utils`
1288
1298
  */
1289
1299
  function countPages(text) {
1290
- var sentencesPerPage = 5; // Assuming each page has 5 sentences
1291
- var sentences = text.split(/[.!?]+/).filter(function (sentence) { return sentence.trim() !== ''; });
1292
- var pageCount = Math.ceil(sentences.length / sentencesPerPage);
1293
- return pageCount;
1300
+ if (text === '') {
1301
+ return 0;
1302
+ }
1303
+ var pagesByLinesCount = Math.ceil(countLines(text) / 44);
1304
+ var pagesByCharactersCount = Math.ceil(countCharacters(text) / 2772);
1305
+ return Math.max(pagesByLinesCount, pagesByCharactersCount);
1294
1306
  }
1295
1307
 
1296
1308
  /**
@@ -2381,7 +2393,7 @@ function isValidPromptbookVersion(version) {
2381
2393
  if ( /* version === '1.0.0' || */version === '2.0.0' || version === '3.0.0') {
2382
2394
  return false;
2383
2395
  }
2384
- // <- TODO: [main] !!! Check isValidPromptbookVersion against PROMPTBOOK_VERSIONS
2396
+ // <- TODO: [main] !!! Check isValidPromptbookVersion against PROMPTBOOK_ENGINE_VERSIONS
2385
2397
  return true;
2386
2398
  }
2387
2399
 
@@ -2452,7 +2464,7 @@ function isValidPipelineUrl(url) {
2452
2464
  if (!url.startsWith('https://')) {
2453
2465
  return false;
2454
2466
  }
2455
- if (!url.endsWith('.ptbk.md')) {
2467
+ if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.ptbk.md') || url.endsWith('.ptbk'))) {
2456
2468
  return false;
2457
2469
  }
2458
2470
  if (url.includes('#')) {
@@ -2480,5 +2492,5 @@ function isValidUuid(value) {
2480
2492
  return /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i.test(value);
2481
2493
  }
2482
2494
 
2483
- export { $currentDate, $deepFreeze, $isRunningInBrowser, $isRunningInNode, $isRunningInWebWorker, $randomSeed, CountUtils, DIACRITIC_VARIANTS_LETTERS, PROMPTBOOK_VERSION, capitalize, checkSerializableAsJson, clonePipeline, countCharacters, countLines, countPages, countParagraphs, countSentences, countWords, decapitalize, deepClone, deserializeError, difference, extractParameterNames, extractParameterNamesFromTemplate, extractVariables, forEachAsync, intersection, isHostnameOnPrivateNetwork, isSerializableAsJson, isUrlOnPrivateNetwork, isValidEmail, isValidFilePath, isValidJavascriptName, isValidJsonString, isValidKeyword, isValidPipelineUrl, isValidPromptbookVersion, isValidSemanticVersion, isValidUrl, isValidUuid, nameToUriPart, nameToUriParts, normalizeToKebabCase, normalizeTo_PascalCase, normalizeTo_SCREAMING_CASE, normalizeTo_camelCase, normalizeTo_snake_case, normalizeWhitespaces, parseKeywords, parseKeywordsFromString, parseNumber, removeDiacritics, removeEmojis, removeQuotes, renameParameter, renderPromptbookMermaid, replaceParameters, searchKeywords, serializeError, splitIntoSentences, titleToName, trimCodeBlock, trimEndOfCodeBlock, union, unwrapResult };
2495
+ export { $currentDate, $deepFreeze, $isRunningInBrowser, $isRunningInNode, $isRunningInWebWorker, $randomSeed, BOOK_LANGUAGE_VERSION, CountUtils, DIACRITIC_VARIANTS_LETTERS, PROMPTBOOK_ENGINE_VERSION, capitalize, checkSerializableAsJson, clonePipeline, countCharacters, countLines, countPages, countParagraphs, countSentences, countWords, decapitalize, deepClone, deserializeError, difference, extractParameterNames, extractParameterNamesFromTemplate, extractVariables, forEachAsync, intersection, isHostnameOnPrivateNetwork, isSerializableAsJson, isUrlOnPrivateNetwork, isValidEmail, isValidFilePath, isValidJavascriptName, isValidJsonString, isValidKeyword, isValidPipelineUrl, isValidPromptbookVersion, isValidSemanticVersion, isValidUrl, isValidUuid, nameToUriPart, nameToUriParts, normalizeToKebabCase, normalizeTo_PascalCase, normalizeTo_SCREAMING_CASE, normalizeTo_camelCase, normalizeTo_snake_case, normalizeWhitespaces, parseKeywords, parseKeywordsFromString, parseNumber, removeDiacritics, removeEmojis, removeQuotes, renameParameter, renderPromptbookMermaid, replaceParameters, searchKeywords, serializeError, splitIntoSentences, titleToName, trimCodeBlock, trimEndOfCodeBlock, union, unwrapResult };
2484
2496
  //# sourceMappingURL=index.es.js.map