@promptbook/fake-llm 0.101.0-0 β†’ 0.101.0-10

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 (60) hide show
  1. package/esm/index.es.js +30 -6
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/components.index.d.ts +18 -0
  4. package/esm/typings/src/_packages/core.index.d.ts +2 -0
  5. package/esm/typings/src/_packages/types.index.d.ts +6 -0
  6. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +41 -3
  7. package/esm/typings/src/book-2.0/agent-source/parseParameters.d.ts +13 -0
  8. package/esm/typings/src/book-2.0/commitments/ACTION/ACTION.d.ts +8 -2
  9. package/esm/typings/src/book-2.0/commitments/DELETE/DELETE.d.ts +59 -0
  10. package/esm/typings/src/book-2.0/commitments/FORMAT/FORMAT.d.ts +8 -2
  11. package/esm/typings/src/book-2.0/commitments/GOAL/GOAL.d.ts +45 -0
  12. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +1 -1
  13. package/esm/typings/src/book-2.0/commitments/MEMORY/MEMORY.d.ts +46 -0
  14. package/esm/typings/src/book-2.0/commitments/MESSAGE/MESSAGE.d.ts +47 -0
  15. package/esm/typings/src/book-2.0/commitments/META/META.d.ts +62 -0
  16. package/esm/typings/src/book-2.0/commitments/MODEL/MODEL.d.ts +8 -2
  17. package/esm/typings/src/book-2.0/commitments/NOTE/NOTE.d.ts +8 -2
  18. package/esm/typings/src/book-2.0/commitments/PERSONA/PERSONA.d.ts +8 -2
  19. package/esm/typings/src/book-2.0/commitments/SCENARIO/SCENARIO.d.ts +46 -0
  20. package/esm/typings/src/book-2.0/commitments/STYLE/STYLE.d.ts +8 -2
  21. package/esm/typings/src/book-2.0/commitments/index.d.ts +7 -3
  22. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/MockedChat.d.ts +46 -0
  23. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/index.d.ts +3 -0
  24. package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +10 -0
  25. package/esm/typings/src/book-components/BookEditor/BookEditorInner.d.ts +3 -0
  26. package/esm/typings/src/book-components/Chat/Chat/Chat.d.ts +0 -5
  27. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +28 -2
  28. package/esm/typings/src/book-components/Chat/Chat/constants.d.ts +8 -0
  29. package/esm/typings/src/book-components/Chat/examples/ChatMarkdownDemo.d.ts +16 -0
  30. package/esm/typings/src/book-components/Chat/utils/renderMarkdown.d.ts +21 -0
  31. package/esm/typings/src/book-components/Chat/utils/renderMarkdown.test.d.ts +1 -0
  32. package/esm/typings/src/book-components/icons/ArrowIcon.d.ts +9 -0
  33. package/esm/typings/src/book-components/icons/ResetIcon.d.ts +6 -0
  34. package/esm/typings/src/book-components/icons/SendIcon.d.ts +8 -0
  35. package/esm/typings/src/book-components/icons/TemplateIcon.d.ts +8 -0
  36. package/esm/typings/src/utils/markdown/escapeMarkdownBlock.d.ts +2 -0
  37. package/esm/typings/src/utils/markdown/humanizeAiText.d.ts +2 -0
  38. package/esm/typings/src/utils/markdown/humanizeAiTextEllipsis.d.ts +1 -0
  39. package/esm/typings/src/utils/markdown/humanizeAiTextEmdashed.d.ts +1 -0
  40. package/esm/typings/src/utils/markdown/humanizeAiTextQuotes.d.ts +1 -0
  41. package/esm/typings/src/utils/markdown/humanizeAiTextWhitespace.d.ts +1 -0
  42. package/esm/typings/src/utils/markdown/prettifyMarkdown.d.ts +8 -0
  43. package/esm/typings/src/utils/markdown/promptbookifyAiText.d.ts +1 -0
  44. package/esm/typings/src/utils/normalization/capitalize.d.ts +2 -0
  45. package/esm/typings/src/utils/normalization/decapitalize.d.ts +3 -1
  46. package/esm/typings/src/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +2 -0
  47. package/esm/typings/src/utils/normalization/normalizeTo_snake_case.d.ts +2 -0
  48. package/esm/typings/src/utils/normalization/normalizeWhitespaces.d.ts +2 -0
  49. package/esm/typings/src/utils/normalization/removeDiacritics.d.ts +2 -0
  50. package/esm/typings/src/utils/parseNumber.d.ts +1 -0
  51. package/esm/typings/src/utils/removeEmojis.d.ts +2 -0
  52. package/esm/typings/src/utils/removeQuotes.d.ts +1 -0
  53. package/esm/typings/src/utils/serialization/deepClone.d.ts +1 -0
  54. package/esm/typings/src/utils/trimCodeBlock.d.ts +1 -0
  55. package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +1 -0
  56. package/esm/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -0
  57. package/esm/typings/src/version.d.ts +1 -1
  58. package/package.json +2 -2
  59. package/umd/index.umd.js +35 -10
  60. package/umd/index.umd.js.map +1 -1
@@ -3,6 +3,8 @@ import type { string_markdown_text } from '../../types/typeAliases';
3
3
  * Function escapeMarkdownBlock will escape markdown block if needed
4
4
  * It is useful when you want have block in block
5
5
  *
6
+ * Note: [πŸ”‚] This function is idempotent.
7
+ *
6
8
  * @public exported from `@promptbook/markdown-utils`
7
9
  */
8
10
  export declare function escapeMarkdownBlock(value: string_markdown_text): string_markdown_text;
@@ -2,11 +2,13 @@ import { string_markdown } from '../../types/typeAliases';
2
2
  /**
3
3
  * Function `humanizeAiText` will remove traces of AI text generation artifacts
4
4
  *
5
+ * Note: [πŸ”‚] This function is idempotent.
5
6
  * Tip: If you want more control, look for other functions for example `humanizeAiTextEmdashed` exported `@promptbook/markdown-utils`
6
7
  *
7
8
  * @public exported from `@promptbook/markdown-utils`
8
9
  */
9
10
  export declare function humanizeAiText(aiText: string_markdown): string_markdown;
10
11
  /**
12
+ * TODO: [🧠] Maybe this should be exported from `@promptbook/utils` not `@promptbook/markdown-utils`
11
13
  * TODO: [πŸ…ΎοΈ] !!! Use this across the project where AI text is involved
12
14
  */
@@ -2,6 +2,7 @@ import { string_markdown } from '../../types/typeAliases';
2
2
  /**
3
3
  * Change ellipsis character to three dots `…` -> `...`
4
4
  *
5
+ * Note: [πŸ”‚] This function is idempotent.
5
6
  * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
6
7
  *
7
8
  * @public exported from `@promptbook/markdown-utils`
@@ -2,6 +2,7 @@ import { string_markdown } from '../../types/typeAliases';
2
2
  /**
3
3
  * Change em-dashes to regular dashes `β€”` -> `-`
4
4
  *
5
+ * Note: [πŸ”‚] This function is idempotent.
5
6
  * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
6
7
  *
7
8
  * @public exported from `@promptbook/markdown-utils`
@@ -2,6 +2,7 @@ import { string_markdown } from '../../types/typeAliases';
2
2
  /**
3
3
  * Change smart quotes to regular quotes
4
4
  *
5
+ * Note: [πŸ”‚] This function is idempotent.
5
6
  * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
6
7
  *
7
8
  * @public exported from `@promptbook/markdown-utils`
@@ -2,6 +2,7 @@ import { string_markdown } from '../../types/typeAliases';
2
2
  /**
3
3
  * Change unprintable hard spaces to regular spaces
4
4
  *
5
+ * Note: [πŸ”‚] This function is idempotent.
5
6
  * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
6
7
  *
7
8
  * @public exported from `@promptbook/markdown-utils`
@@ -7,3 +7,11 @@ import type { string_html } from '../../types/typeAliases';
7
7
  * @private withing the package because of HUGE size of prettier dependency
8
8
  */
9
9
  export declare function prettifyMarkdown<TContent extends string_html>(content: TContent): TContent;
10
+ /**
11
+ * Async version of prettifyMarkdown using dynamic imports
12
+ *
13
+ * @param content raw html code
14
+ * @returns formatted html code
15
+ * @private withing the package because of HUGE size of prettier dependency
16
+ */
17
+ export declare function prettifyMarkdownAsync<TContent extends string_html>(content: TContent): Promise<TContent>;
@@ -6,6 +6,7 @@ import { string_markdown } from '../../types/typeAliases';
6
6
  */
7
7
  export declare function promptbookifyAiText(text: string_markdown): string_markdown;
8
8
  /**
9
+ * TODO: !!!!! Make the function idempotent and add "Note: [πŸ”‚] This function is idempotent."
9
10
  * TODO: [πŸ…ΎοΈ]!!! Use this across the project where AI text is involved
10
11
  * TODO: [🧠][✌️] Make some Promptbook-native token system
11
12
  */
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * Makes first letter of a string uppercase
3
3
  *
4
+ * Note: [πŸ”‚] This function is idempotent.
5
+ *
4
6
  * @public exported from `@promptbook/utils`
5
7
  */
6
8
  export declare function capitalize(word: string): string;
@@ -1,5 +1,7 @@
1
1
  /**
2
- * Makes first letter of a string uppercase
2
+ * Makes first letter of a string lowercase
3
+ *
4
+ * Note: [πŸ”‚] This function is idempotent.
3
5
  *
4
6
  * @public exported from `@promptbook/utils`
5
7
  */
@@ -9,6 +9,8 @@ export type string_SCREAMING_CASE = string;
9
9
  /**
10
10
  * Normalizes a text string to SCREAMING_CASE (all uppercase with underscores).
11
11
  *
12
+ * Note: [πŸ”‚] This function is idempotent.
13
+ *
12
14
  * @param text The text string to be converted to SCREAMING_CASE format.
13
15
  * @returns The normalized text in SCREAMING_CASE format.
14
16
  * @example 'HELLO_WORLD'
@@ -8,6 +8,8 @@ export type string_snake_case = string;
8
8
  /**
9
9
  * Normalizes a text string to snake_case format.
10
10
  *
11
+ * Note: [πŸ”‚] This function is idempotent.
12
+ *
11
13
  * @param text The text string to be converted to snake_case format.
12
14
  * @returns The normalized text in snake_case format.
13
15
  * @example 'hello_world'
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * Take every whitespace (space, new line, tab) and replace it with a single space
3
3
  *
4
+ * Note: [πŸ”‚] This function is idempotent.
5
+ *
4
6
  * @public exported from `@promptbook/utils`
5
7
  */
6
8
  export declare function normalizeWhitespaces(sentence: string): string;
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * Removes diacritic marks (accents) from characters in a string.
3
3
  *
4
+ * Note: [πŸ”‚] This function is idempotent.
5
+ *
4
6
  * @param input The string containing diacritics to be normalized.
5
7
  * @returns The string with diacritics removed or normalized.
6
8
  * @public exported from `@promptbook/utils`
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Function parseNumber will parse number from string
3
3
  *
4
+ * Note: [πŸ”‚] This function is idempotent.
4
5
  * Unlike Number.parseInt, Number.parseFloat it will never ever result in NaN
5
6
  * Note: it also works only with decimal numbers
6
7
  *
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * Removes emojis from a string and fix whitespaces
3
3
  *
4
+ * Note: [πŸ”‚] This function is idempotent.
5
+ *
4
6
  * @param text with emojis
5
7
  * @returns text without emojis
6
8
  * @public exported from `@promptbook/utils`
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Removes quotes from a string
3
3
  *
4
+ * Note: [πŸ”‚] This function is idempotent.
4
5
  * Tip: This is very useful for post-processing of the result of the LLM model
5
6
  * Note: This function removes only the same quotes from the beginning and the end of the string
6
7
  * Note: There are two similar functions:
@@ -2,6 +2,7 @@ import type { WritableDeep } from 'type-fest';
2
2
  /**
3
3
  * Creates a deep clone of the given object
4
4
  *
5
+ * Note: [πŸ”‚] This function is idempotent.
5
6
  * Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
6
7
  *
7
8
  * @param objectValue The object to clone.
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Function trimCodeBlock will trim starting and ending code block from the string if it is present.
3
3
  *
4
+ * Note: [πŸ”‚] This function is idempotent.
4
5
  * Note: This is useful for post-processing of the result of the chat LLM model
5
6
  * when the model wraps the result in the (markdown) code block.
6
7
  *
@@ -3,6 +3,7 @@ import type { really_unknown } from '../../organization/really_unknown';
3
3
  /**
4
4
  * Tests if given string is valid URL.
5
5
  *
6
+ * Note: [πŸ”‚] This function is idempotent.
6
7
  * Note: Dataurl are considered perfectly valid.
7
8
  * Note: There are two similar functions:
8
9
  * - `isValidUrl` which tests any URL
@@ -3,6 +3,8 @@ import type { really_unknown } from '../../organization/really_unknown';
3
3
  /**
4
4
  * Checks if value is valid uuid
5
5
  *
6
+ * Note: [πŸ”‚] This function is idempotent.
7
+ *
6
8
  * @public exported from `@promptbook/utils`
7
9
  */
8
10
  export declare function isValidUuid(value: really_unknown): value is string_uuid;
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.100.4-0`).
18
+ * It follows semantic versioning (e.g., `0.101.0-9`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/fake-llm",
3
- "version": "0.101.0-0",
3
+ "version": "0.101.0-10",
4
4
  "description": "Promptbook: Run AI apps in plain human language across multiple models and platforms",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -96,7 +96,7 @@
96
96
  "module": "./esm/index.es.js",
97
97
  "typings": "./esm/typings/src/_packages/fake-llm.index.d.ts",
98
98
  "peerDependencies": {
99
- "@promptbook/core": "0.101.0-0"
99
+ "@promptbook/core": "0.101.0-10"
100
100
  },
101
101
  "dependencies": {
102
102
  "crypto": "1.0.1",
package/umd/index.umd.js CHANGED
@@ -1,14 +1,12 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('crypto'), require('waitasecond'), require('lorem-ipsum'), require('path'), require('prettier/parser-html'), require('prettier/parser-markdown'), require('prettier/standalone')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'crypto', 'waitasecond', 'lorem-ipsum', 'path', 'prettier/parser-html', 'prettier/parser-markdown', 'prettier/standalone'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-fake-llm"] = {}, global.spaceTrim, global.crypto, global.waitasecond, global.loremIpsum, null, global.parserHtml, global.parserMarkdown, global.standalone));
5
- })(this, (function (exports, spaceTrim, crypto, waitasecond, loremIpsum, path, parserHtml, parserMarkdown, standalone) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('crypto'), require('waitasecond'), require('lorem-ipsum'), require('path')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'crypto', 'waitasecond', 'lorem-ipsum', 'path'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-fake-llm"] = {}, global.spaceTrim, global.crypto, global.waitasecond, global.loremIpsum));
5
+ })(this, (function (exports, spaceTrim, crypto, waitasecond, loremIpsum) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
9
  var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
10
- var parserHtml__default = /*#__PURE__*/_interopDefaultLegacy(parserHtml);
11
- var parserMarkdown__default = /*#__PURE__*/_interopDefaultLegacy(parserMarkdown);
12
10
 
13
11
  // ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
14
12
  /**
@@ -24,7 +22,7 @@
24
22
  * @generated
25
23
  * @see https://github.com/webgptorg/promptbook
26
24
  */
27
- const PROMPTBOOK_ENGINE_VERSION = '0.101.0-0';
25
+ const PROMPTBOOK_ENGINE_VERSION = '0.101.0-10';
28
26
  /**
29
27
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
30
28
  * Note: [πŸ’ž] Ignore a discrepancy between file name and entity name
@@ -557,6 +555,7 @@
557
555
  /**
558
556
  * Creates a deep clone of the given object
559
557
  *
558
+ * Note: [πŸ”‚] This function is idempotent.
560
559
  * Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
561
560
  *
562
561
  * @param objectValue The object to clone.
@@ -1341,6 +1340,8 @@
1341
1340
  /**
1342
1341
  * Removes diacritic marks (accents) from characters in a string.
1343
1342
  *
1343
+ * Note: [πŸ”‚] This function is idempotent.
1344
+ *
1344
1345
  * @param input The string containing diacritics to be normalized.
1345
1346
  * @returns The string with diacritics removed or normalized.
1346
1347
  * @public exported from `@promptbook/utils`
@@ -1496,6 +1497,8 @@
1496
1497
  /**
1497
1498
  * Removes emojis from a string and fix whitespaces
1498
1499
  *
1500
+ * Note: [πŸ”‚] This function is idempotent.
1501
+ *
1499
1502
  * @param text with emojis
1500
1503
  * @returns text without emojis
1501
1504
  * @public exported from `@promptbook/utils`
@@ -1682,6 +1685,8 @@
1682
1685
  /**
1683
1686
  * Makes first letter of a string uppercase
1684
1687
  *
1688
+ * Note: [πŸ”‚] This function is idempotent.
1689
+ *
1685
1690
  * @public exported from `@promptbook/utils`
1686
1691
  */
1687
1692
  function capitalize(word) {
@@ -1689,7 +1694,9 @@
1689
1694
  }
1690
1695
 
1691
1696
  /**
1692
- * Makes first letter of a string uppercase
1697
+ * Makes first letter of a string lowercase
1698
+ *
1699
+ * Note: [πŸ”‚] This function is idempotent.
1693
1700
  *
1694
1701
  * @public exported from `@promptbook/utils`
1695
1702
  */
@@ -1700,6 +1707,8 @@
1700
1707
  /**
1701
1708
  * Normalizes a text string to SCREAMING_CASE (all uppercase with underscores).
1702
1709
  *
1710
+ * Note: [πŸ”‚] This function is idempotent.
1711
+ *
1703
1712
  * @param text The text string to be converted to SCREAMING_CASE format.
1704
1713
  * @returns The normalized text in SCREAMING_CASE format.
1705
1714
  * @example 'HELLO_WORLD'
@@ -1814,6 +1823,8 @@
1814
1823
  /**
1815
1824
  * Normalizes a text string to snake_case format.
1816
1825
  *
1826
+ * Note: [πŸ”‚] This function is idempotent.
1827
+ *
1817
1828
  * @param text The text string to be converted to snake_case format.
1818
1829
  * @returns The normalized text in snake_case format.
1819
1830
  * @example 'hello_world'
@@ -1827,6 +1838,8 @@
1827
1838
  /**
1828
1839
  * Take every whitespace (space, new line, tab) and replace it with a single space
1829
1840
  *
1841
+ * Note: [πŸ”‚] This function is idempotent.
1842
+ *
1830
1843
  * @public exported from `@promptbook/utils`
1831
1844
  */
1832
1845
  function normalizeWhitespaces(sentence) {
@@ -1836,6 +1849,7 @@
1836
1849
  /**
1837
1850
  * Removes quotes from a string
1838
1851
  *
1852
+ * Note: [πŸ”‚] This function is idempotent.
1839
1853
  * Tip: This is very useful for post-processing of the result of the LLM model
1840
1854
  * Note: This function removes only the same quotes from the beginning and the end of the string
1841
1855
  * Note: There are two similar functions:
@@ -1859,6 +1873,7 @@
1859
1873
  /**
1860
1874
  * Function trimCodeBlock will trim starting and ending code block from the string if it is present.
1861
1875
  *
1876
+ * Note: [πŸ”‚] This function is idempotent.
1862
1877
  * Note: This is useful for post-processing of the result of the chat LLM model
1863
1878
  * when the model wraps the result in the (markdown) code block.
1864
1879
  *
@@ -2085,10 +2100,20 @@
2085
2100
  * @private withing the package because of HUGE size of prettier dependency
2086
2101
  */
2087
2102
  function prettifyMarkdown(content) {
2103
+ // In browser/Next.js environments, just return the original content
2104
+ // since prettier parsers are not available and would cause bundling issues
2105
+ if (typeof window !== 'undefined') {
2106
+ return content;
2107
+ }
2088
2108
  try {
2089
- return standalone.format(content, {
2109
+ // Use dynamic require to avoid static imports that cause bundling issues
2110
+ // This will only work in Node.js environments
2111
+ const prettierStandalone = eval('require')('prettier/standalone');
2112
+ const parserMarkdown = eval('require')('prettier/parser-markdown');
2113
+ const parserHtml = eval('require')('prettier/parser-html');
2114
+ return prettierStandalone.format(content, {
2090
2115
  parser: 'markdown',
2091
- plugins: [parserMarkdown__default["default"], parserHtml__default["default"]],
2116
+ plugins: [parserMarkdown, parserHtml],
2092
2117
  // TODO: DRY - make some import or auto-copy of .prettierrc
2093
2118
  endOfLine: 'lf',
2094
2119
  tabWidth: 4,