@promptbook/utils 0.84.0-21 → 0.84.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.
Files changed (38) hide show
  1. package/README.md +26 -68
  2. package/esm/index.es.js +8 -34
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/cli.index.d.ts +0 -4
  5. package/esm/typings/src/_packages/core.index.d.ts +2 -12
  6. package/esm/typings/src/_packages/types.index.d.ts +0 -2
  7. package/esm/typings/src/_packages/utils.index.d.ts +0 -2
  8. package/esm/typings/src/_packages/wizzard.index.d.ts +0 -4
  9. package/esm/typings/src/cli/cli-commands/about.d.ts +1 -3
  10. package/esm/typings/src/cli/cli-commands/hello.d.ts +1 -3
  11. package/esm/typings/src/cli/cli-commands/list-models.d.ts +1 -3
  12. package/esm/typings/src/cli/cli-commands/make.d.ts +1 -3
  13. package/esm/typings/src/cli/cli-commands/prettify.d.ts +1 -3
  14. package/esm/typings/src/cli/cli-commands/run.d.ts +1 -3
  15. package/esm/typings/src/cli/cli-commands/runInteractiveChatbot.d.ts +1 -1
  16. package/esm/typings/src/cli/cli-commands/test-command.d.ts +1 -3
  17. package/esm/typings/src/config.d.ts +1 -27
  18. package/esm/typings/src/conversion/compilePipelineOnRemoteServer.d.ts +1 -1
  19. package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
  20. package/esm/typings/src/execution/assertsExecutionSuccessful.d.ts +1 -3
  21. package/esm/typings/src/pipeline/book-notation.d.ts +2 -3
  22. package/esm/typings/src/pipeline/prompt-notation.d.ts +5 -18
  23. package/esm/typings/src/prepare/preparePipelineOnRemoteServer.d.ts +1 -1
  24. package/esm/typings/src/remote-server/socket-types/_subtypes/PromptbookServer_Identification.d.ts +2 -5
  25. package/esm/typings/src/wizzard/wizzard.d.ts +1 -7
  26. package/package.json +14 -7
  27. package/umd/index.umd.js +7 -34
  28. package/umd/index.umd.js.map +1 -1
  29. package/esm/typings/src/_packages/deepseek.index.d.ts +0 -8
  30. package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +0 -13
  31. package/esm/typings/src/llm-providers/deepseek/DeepseekExecutionToolsOptions.d.ts +0 -9
  32. package/esm/typings/src/llm-providers/deepseek/createDeepseekExecutionTools.d.ts +0 -14
  33. package/esm/typings/src/llm-providers/deepseek/register-configuration.d.ts +0 -14
  34. package/esm/typings/src/llm-providers/deepseek/register-constructor.d.ts +0 -15
  35. package/esm/typings/src/utils/editable/edit-pipeline-string/deflatePipeline.test.d.ts +0 -1
  36. package/esm/typings/src/utils/editable/utils/isFlatPipeline.test.d.ts +0 -1
  37. package/esm/typings/src/utils/files/mimeTypeToExtension.d.ts +0 -10
  38. package/esm/typings/src/utils/files/mimeTypeToExtension.test.d.ts +0 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <!-- ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten -->
2
2
 
3
- # Promptbook
3
+ # Promptbook
4
4
 
5
5
 
6
6
 
@@ -14,13 +14,12 @@
14
14
 
15
15
 
16
16
 
17
- ## 🌟 New Features
17
+ ## New Features
18
18
 
19
- - 💫 Support of [`o3-mini` model by OpenAI](https://openai.com/index/openai-o3-mini/)
20
- - 🐋 **Support of [DeepSeek models](https://www.npmjs.com/package/@promptbook/deepseek)**
21
19
  - 💙 Working [the **Book** language v1.0.0](https://github.com/webgptorg/book)
22
20
  - 🖤 Run books from CLI - `npx ptbk run path/to/your/book`
23
- - 📚 Support of `.docx`, `.doc` and `.pdf` documents as knowledge
21
+ - 📚 Support of `.docx`, `.doc` and `.pdf` documents
22
+ - ✨ **Support of [OpenAI o1 model](https://openai.com/o1/)**
24
23
 
25
24
 
26
25
 
@@ -43,37 +42,37 @@ npm i ptbk
43
42
  npm install @promptbook/utils
44
43
  ```
45
44
 
46
- Utility functions used in the library, but also useful for individual use in pre and post-processing of LLM inputs and outputs.
45
+ Utility functions used in the library but also useful for individual use in preprocessing and postprocessing LLM inputs and outputs
47
46
 
48
- Here is an overview of the functions that can be exported from the `@promptbook/utils` package and used in your own projects:
47
+ Here is a overview of the functions which are exported from the `@promptbook/utils` package and can be used in your own projects:
49
48
 
50
- ## Simple templating
51
-
52
- The `prompt` template tag function helps format prompt strings for LLM interactions. It handles string interpolation and maintains consistent formatting for multiline strings and lists and also handles a security to avoid **prompt injection**.
53
-
54
- ```typescript
55
- import { prompt } from '@promptbook/utils';
49
+ ## Postprocessing
56
50
 
57
- const promptString = prompt`
58
- Correct the following sentence:
51
+ Sometimes you need to postprocess the output of the LLM model, every postprocessing function that is available through `POSTPROCESS` command in promptbook is exported from `@promptbook/utils`. You can use:
59
52
 
60
- > ${unsecureUserInput}
61
- `;
62
- ```
53
+ - `spaceTrim`
54
+ - `extractAllBlocksFromMarkdown`, _<- Note: Exported from [`@promptbook/markdown-utils`](https://www.npmjs.com/package/@promptbook/markdown-utils)_
55
+ - `extractAllListItemsFromMarkdown` _<- Note: Exported from [`@promptbook/markdown-utils`](https://www.npmjs.com/package/@promptbook/markdown-utils)_
56
+ - `extractBlock`
57
+ - `extractOneBlockFromMarkdown `_<- Note: Exported from [`@promptbook/markdown-utils`](https://www.npmjs.com/package/@promptbook/markdown-utils)_
58
+ - `prettifyPipelineString`
59
+ - `removeMarkdownComments`
60
+ - `removeEmojis`
61
+ - `removeMarkdownFormatting` _<- Note: Exported from [`@promptbook/markdown-utils`](https://www.npmjs.com/package/@promptbook/markdown-utils)_
62
+ - `removeQuotes`
63
+ - `trimCodeBlock`
64
+ - `trimEndOfCodeBlock`
65
+ - `unwrapResult`
63
66
 
64
- The `prompt` name could be overloaded by multiple things in your code. If you want to use the `promptTemplate` which is alias for `prompt`:
67
+ Very often you will use `unwrapResult`, which is used to extract the result you need from output with some additional information:
65
68
 
66
69
  ```typescript
67
- import { promptTemplate } from '@promptbook/utils';
68
-
69
- const promptString = promptTemplate`
70
- Correct the following sentence:
70
+ import { unwrapResult } from '@promptbook/utils';
71
71
 
72
- > ${unsecureUserInput}
73
- `;
72
+ unwrapResult('Best greeting for the user is "Hi Pavol!"'); // 'Hi Pavol!'
74
73
  ```
75
74
 
76
- ## Advanced templating
75
+ ## Templating
77
76
 
78
77
  There is a function `templateParameters` which is used to replace the parameters in given template optimized to LLM prompt templates.
79
78
 
@@ -153,32 +152,6 @@ console.log(normalizeTo['kebab-case']('Hello, world!')); // 'hello-world'
153
152
  - There are more normalization functions like `capitalize`, `decapitalize`, `removeDiacritics`,...
154
153
  - Theese can be also used as postprocessing functions in the `POSTPROCESS` command in promptbook
155
154
 
156
- ## Postprocessing
157
-
158
- Sometimes you need to postprocess the output of the LLM model, every postprocessing function that is available through `POSTPROCESS` command in promptbook is exported from `@promptbook/utils`. You can use:
159
-
160
- - `spaceTrim`
161
- - `extractAllBlocksFromMarkdown`, _<- Note: Exported from [`@promptbook/markdown-utils`](https://www.npmjs.com/package/@promptbook/markdown-utils)_
162
- - `extractAllListItemsFromMarkdown` _<- Note: Exported from [`@promptbook/markdown-utils`](https://www.npmjs.com/package/@promptbook/markdown-utils)_
163
- - `extractBlock`
164
- - `extractOneBlockFromMarkdown `_<- Note: Exported from [`@promptbook/markdown-utils`](https://www.npmjs.com/package/@promptbook/markdown-utils)_
165
- - `prettifyPipelineString`
166
- - `removeMarkdownComments`
167
- - `removeEmojis`
168
- - `removeMarkdownFormatting` _<- Note: Exported from [`@promptbook/markdown-utils`](https://www.npmjs.com/package/@promptbook/markdown-utils)_
169
- - `removeQuotes`
170
- - `trimCodeBlock`
171
- - `trimEndOfCodeBlock`
172
- - `unwrapResult`
173
-
174
- Very often you will use `unwrapResult`, which is used to extract the result you need from output with some additional information:
175
-
176
- ```typescript
177
- import { unwrapResult } from '@promptbook/utils';
178
-
179
- unwrapResult('Best greeting for the user is "Hi Pavol!"'); // 'Hi Pavol!'
180
- ```
181
-
182
155
  ## Misc
183
156
 
184
157
  See also the documentation for all the functions in the `@promptbook/utils` package, every function is documented by jsdoc, typed by typescript and tested by jest.
@@ -411,9 +384,8 @@ Or you can install them separately:
411
384
  - **[@promptbook/anthropic-claude](https://www.npmjs.com/package/@promptbook/anthropic-claude)** - Execution tools for Anthropic Claude API, wrapper around Anthropic Claude SDK
412
385
  - **[@promptbook/vercel](https://www.npmjs.com/package/@promptbook/vercel)** - Adapter for Vercel functionalities
413
386
  - **[@promptbook/google](https://www.npmjs.com/package/@promptbook/google)** - Integration with Google's Gemini API
414
- - **[@promptbook/deepseek](https://www.npmjs.com/package/@promptbook/deepseek)** - Integration with [DeepSeek API](https://www.deepseek.com/)
415
387
  - **[@promptbook/azure-openai](https://www.npmjs.com/package/@promptbook/azure-openai)** - Execution tools for Azure OpenAI API
416
-
388
+ - **[@promptbook/langtail](https://www.npmjs.com/package/@promptbook/langtail)** - Execution tools for Langtail API, wrapper around Langtail SDK
417
389
  - **[@promptbook/fake-llm](https://www.npmjs.com/package/@promptbook/fake-llm)** - Mocked execution tools for testing the library and saving the tokens
418
390
  - **[@promptbook/remote-client](https://www.npmjs.com/package/@promptbook/remote-client)** - Remote client for remote execution of promptbooks
419
391
  - **[@promptbook/remote-server](https://www.npmjs.com/package/@promptbook/remote-server)** - Remote server for remote execution of promptbooks
@@ -583,20 +555,6 @@ See [TODO.md](./TODO.md)
583
555
 
584
556
 
585
557
 
586
- ## 🤝 Partners
587
-
588
- <div style="display: flex; align-items: center; gap: 20px;">
589
-
590
- <a href="https://promptbook.studio/">
591
- <img src="./other/design/promptbook-studio-logo.png" alt="Partner 3" height="100">
592
- </a>
593
-
594
- <a href="https://technologickainkubace.org/en/about-technology-incubation/about-the-project/">
595
- <img src="./other/partners/CI-Technology-Incubation.png" alt="Technology Incubation" height="100">
596
- </a>
597
-
598
- </div>
599
-
600
558
  ## 🖋️ Contributing
601
559
 
602
560
  I am open to pull requests, feedback, and suggestions. Or if you like this utility, you can [☕ buy me a coffee](https://www.buymeacoffee.com/hejny) or [donate via cryptocurrencies](https://github.com/hejny/hejny/blob/main/documents/crypto.md).
package/esm/index.es.js CHANGED
@@ -15,7 +15,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
15
15
  * @generated
16
16
  * @see https://github.com/webgptorg/promptbook
17
17
  */
18
- var PROMPTBOOK_ENGINE_VERSION = '0.84.0-20';
18
+ var PROMPTBOOK_ENGINE_VERSION = '0.84.0-8';
19
19
  /**
20
20
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
21
21
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1729,14 +1729,13 @@ function templateParameters(template, parameters) {
1729
1729
  /**
1730
1730
  * Tag function for notating a prompt as template literal
1731
1731
  *
1732
- * Note: There are 3 similar functions:
1732
+ * Note: There are 2 similar functions:
1733
1733
  * 1) `prompt` for notating single prompt exported from `@promptbook/utils`
1734
- * 2) `promptTemplate` alias for `prompt`
1735
- * 3) `book` for notating and validating entire books exported from `@promptbook/utils`
1734
+ * 1) `book` for notating and validating entire books exported from `@promptbook/utils`
1736
1735
  *
1737
- * @param strings
1738
- * @param values
1739
- * @returns the prompt string
1736
+ * @param strings @@@
1737
+ * @param values @@@
1738
+ * @returns the pipeline string
1740
1739
  * @public exported from `@promptbook/utils`
1741
1740
  */
1742
1741
  function prompt(strings) {
@@ -1747,14 +1746,10 @@ function prompt(strings) {
1747
1746
  if (values.length === 0) {
1748
1747
  return spaceTrim$1(strings.join(''));
1749
1748
  }
1750
- var stringsWithHiddenParameters = strings.map(function (stringsItem) {
1751
- // TODO: [0] DRY
1752
- return stringsItem.split('{').join("".concat(REPLACING_NONCE, "beginbracket")).split('}').join("".concat(REPLACING_NONCE, "endbracket"));
1753
- });
1754
1749
  var placeholderParameterNames = values.map(function (value, i) { return "".concat(REPLACING_NONCE).concat(i); });
1755
1750
  var parameters = Object.fromEntries(values.map(function (value, i) { return [placeholderParameterNames[i], value]; }));
1756
1751
  // Combine strings and values
1757
- var pipelineString = stringsWithHiddenParameters.reduce(function (result, stringsItem, i) {
1752
+ var pipelineString = strings.reduce(function (result, stringsItem, i) {
1758
1753
  return placeholderParameterNames[i] === undefined
1759
1754
  ? "".concat(result).concat(stringsItem)
1760
1755
  : "".concat(result).concat(stringsItem, "{").concat(placeholderParameterNames[i], "}");
@@ -1770,26 +1765,8 @@ function prompt(strings) {
1770
1765
  console.error({ pipelineString: pipelineString, parameters: parameters, placeholderParameterNames: placeholderParameterNames, error: error });
1771
1766
  throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Internal error in prompt template literal\n \n ".concat(block(JSON.stringify({ strings: strings, values: values }, null, 4)), "}\n \n "); }));
1772
1767
  }
1773
- // TODO: [0] DRY
1774
- pipelineString = pipelineString
1775
- .split("".concat(REPLACING_NONCE, "beginbracket"))
1776
- .join('{')
1777
- .split("".concat(REPLACING_NONCE, "endbracket"))
1778
- .join('}');
1779
1768
  return pipelineString;
1780
1769
  }
1781
- /**
1782
- * Tag function for notating a prompt as template literal
1783
- *
1784
- * Note: There are 3 similar functions:
1785
- * 1) `prompt` for notating single prompt exported from `@promptbook/utils`
1786
- * 2) `promptTemplate` alias for `prompt`
1787
- * 3) `book` for notating and validating entire books exported from `@promptbook/utils`
1788
- *
1789
- * @alias prompt
1790
- * @public exported from `@promptbook/utils`
1791
- */
1792
- var promptTemplate = prompt;
1793
1770
  /**
1794
1771
  * TODO: [🧠][🈴] Where is the best location for this file
1795
1772
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2640,9 +2617,6 @@ function isValidEmail(email) {
2640
2617
  if (typeof email !== 'string') {
2641
2618
  return false;
2642
2619
  }
2643
- if (email.split('\n').length > 1) {
2644
- return false;
2645
- }
2646
2620
  return /^.+@.+\..+$/.test(email);
2647
2621
  }
2648
2622
 
@@ -2813,5 +2787,5 @@ function isValidUuid(value) {
2813
2787
  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);
2814
2788
  }
2815
2789
 
2816
- export { $deepFreeze, $getCurrentDate, $isRunningInBrowser, $isRunningInJest, $isRunningInNode, $isRunningInWebWorker, $randomSeed, BOOK_LANGUAGE_VERSION, CHARACTERS_PER_STANDARD_LINE, CountUtils, DIACRITIC_VARIANTS_LETTERS, LINES_PER_STANDARD_PAGE, PROMPTBOOK_ENGINE_VERSION, SMALL_NUMBER, VALUE_STRINGS, capitalize, checkSerializableAsJson, clonePipeline, countCharacters, countLines, countPages, countParagraphs, countSentences, countWords, decapitalize, deepClone, deserializeError, difference, exportJson, extractParameterNames, extractVariablesFromScript, forEachAsync, intersection, isHostnameOnPrivateNetwork, isRootPath, 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, numberToString, orderJson, parseKeywords, parseKeywordsFromString, parseNumber, prompt, promptTemplate, removeDiacritics, removeEmojis, removeQuotes, renderPromptbookMermaid, searchKeywords, serializeError, spaceTrim, splitIntoSentences, templateParameters, titleToName, trimCodeBlock, trimEndOfCodeBlock, union, unwrapResult, valueToString };
2790
+ export { $deepFreeze, $getCurrentDate, $isRunningInBrowser, $isRunningInJest, $isRunningInNode, $isRunningInWebWorker, $randomSeed, BOOK_LANGUAGE_VERSION, CHARACTERS_PER_STANDARD_LINE, CountUtils, DIACRITIC_VARIANTS_LETTERS, LINES_PER_STANDARD_PAGE, PROMPTBOOK_ENGINE_VERSION, SMALL_NUMBER, VALUE_STRINGS, capitalize, checkSerializableAsJson, clonePipeline, countCharacters, countLines, countPages, countParagraphs, countSentences, countWords, decapitalize, deepClone, deserializeError, difference, exportJson, extractParameterNames, extractVariablesFromScript, forEachAsync, intersection, isHostnameOnPrivateNetwork, isRootPath, 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, numberToString, orderJson, parseKeywords, parseKeywordsFromString, parseNumber, prompt, removeDiacritics, removeEmojis, removeQuotes, renderPromptbookMermaid, searchKeywords, serializeError, spaceTrim, splitIntoSentences, templateParameters, titleToName, trimCodeBlock, trimEndOfCodeBlock, union, unwrapResult, valueToString };
2817
2791
  //# sourceMappingURL=index.es.js.map