@promptbook/markdown-utils 0.100.4-0 → 0.101.0-1
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/esm/index.es.js +158 -7
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +4 -0
- package/esm/typings/src/_packages/core.index.d.ts +4 -2
- package/esm/typings/src/_packages/markdown-utils.index.d.ts +14 -0
- package/esm/typings/src/_packages/types.index.d.ts +4 -6
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +21 -0
- package/esm/typings/src/book-2.0/{commitments/_misc → agent-source}/AgentModelRequirements.d.ts +1 -1
- package/esm/typings/src/book-2.0/{commitments/_misc → agent-source}/AgentSourceParseResult.d.ts +3 -1
- package/esm/typings/src/book-2.0/{commitments/_misc → agent-source}/createAgentModelRequirements.d.ts +2 -2
- package/esm/typings/src/book-2.0/{commitments/_misc → agent-source}/createAgentModelRequirementsWithCommitments.d.ts +3 -3
- package/esm/typings/src/book-2.0/{commitments/_misc → agent-source}/createCommitmentRegex.d.ts +2 -2
- package/esm/typings/src/book-2.0/agent-source/extractMetaLinks.d.ts +8 -0
- package/esm/typings/src/book-2.0/agent-source/parseAgentSource.d.ts +4 -19
- package/esm/typings/src/book-2.0/agent-source/parseAgentSourceWithCommitments.d.ts +9 -0
- package/esm/typings/src/book-2.0/commitments/ACTION/ACTION.d.ts +1 -1
- package/esm/typings/src/book-2.0/commitments/FORMAT/FORMAT.d.ts +1 -1
- package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +1 -1
- package/esm/typings/src/book-2.0/commitments/META_IMAGE/META_IMAGE.d.ts +1 -1
- package/esm/typings/src/book-2.0/commitments/META_LINK/META_LINK.d.ts +1 -1
- package/esm/typings/src/book-2.0/commitments/MODEL/MODEL.d.ts +1 -1
- package/esm/typings/src/book-2.0/commitments/NOTE/NOTE.d.ts +1 -1
- package/esm/typings/src/book-2.0/commitments/PERSONA/PERSONA.d.ts +1 -1
- package/esm/typings/src/book-2.0/commitments/RULE/RULE.d.ts +1 -1
- package/esm/typings/src/book-2.0/commitments/SAMPLE/SAMPLE.d.ts +1 -1
- package/esm/typings/src/book-2.0/commitments/STYLE/STYLE.d.ts +1 -1
- package/esm/typings/src/book-2.0/commitments/_base/BaseCommitmentDefinition.d.ts +1 -1
- package/esm/typings/src/book-2.0/commitments/_base/CommitmentDefinition.d.ts +1 -1
- package/esm/typings/src/book-2.0/commitments/_base/NotYetImplementedCommitmentDefinition.d.ts +1 -1
- package/esm/typings/src/book-2.0/commitments/{_misc → _base}/ParsedCommitment.d.ts +1 -1
- package/esm/typings/src/book-2.0/commitments/_base/createEmptyAgentModelRequirements.d.ts +1 -1
- package/esm/typings/src/book-2.0/utils/extractAgentMetadata.d.ts +17 -0
- package/esm/typings/src/book-2.0/utils/extractProfileImageFromSystemMessage.d.ts +12 -0
- package/esm/typings/src/book-2.0/utils/generateGravatarUrl.d.ts +10 -0
- package/esm/typings/src/book-2.0/utils/generatePlaceholderAgentProfileImageUrl.d.ts +10 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarChip/AvatarChip.d.ts +1 -1
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +2 -8
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +6 -0
- package/esm/typings/src/book-components/Chat/examples/ChatMarkdownDemo.d.ts +16 -0
- package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/utils/renderMarkdown.d.ts +21 -0
- package/esm/typings/src/book-components/Chat/utils/renderMarkdown.test.d.ts +1 -0
- package/esm/typings/src/llm-providers/_common/profiles/llmProviderProfiles.d.ts +1 -1
- package/esm/typings/src/utils/expectation-counters/countCharacters.d.ts +2 -1
- package/esm/typings/src/utils/expectation-counters/countLines.d.ts +2 -1
- package/esm/typings/src/utils/expectation-counters/countPages.d.ts +2 -1
- package/esm/typings/src/utils/expectation-counters/countParagraphs.d.ts +2 -1
- package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +1 -0
- package/esm/typings/src/utils/expectation-counters/countWords.d.ts +3 -1
- package/esm/typings/src/utils/markdown/escapeMarkdownBlock.d.ts +2 -0
- package/esm/typings/src/utils/markdown/humanizeAiText.d.ts +13 -0
- package/esm/typings/src/utils/markdown/humanizeAiText.test.d.ts +1 -0
- package/esm/typings/src/utils/markdown/humanizeAiTextEllipsis.d.ts +13 -0
- package/esm/typings/src/utils/markdown/humanizeAiTextEmdashed.d.ts +13 -0
- package/esm/typings/src/utils/markdown/humanizeAiTextQuotes.d.ts +13 -0
- package/esm/typings/src/utils/markdown/humanizeAiTextWhitespace.d.ts +13 -0
- package/esm/typings/src/utils/markdown/prettifyMarkdown.d.ts +8 -0
- package/esm/typings/src/utils/markdown/promptbookifyAiText.d.ts +12 -0
- package/esm/typings/src/utils/markdown/promptbookifyAiText.test.d.ts +1 -0
- package/esm/typings/src/utils/markdown/removeMarkdownLinks.d.ts +11 -0
- package/esm/typings/src/utils/markdown/removeMarkdownLinks.test.d.ts +4 -0
- package/esm/typings/src/utils/normalization/capitalize.d.ts +2 -0
- package/esm/typings/src/utils/normalization/decapitalize.d.ts +3 -1
- package/esm/typings/src/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +2 -0
- package/esm/typings/src/utils/normalization/normalizeTo_snake_case.d.ts +2 -0
- package/esm/typings/src/utils/normalization/normalizeWhitespaces.d.ts +2 -0
- package/esm/typings/src/utils/normalization/removeDiacritics.d.ts +2 -0
- package/esm/typings/src/utils/parseNumber.d.ts +1 -0
- package/esm/typings/src/utils/removeEmojis.d.ts +2 -0
- package/esm/typings/src/utils/removeQuotes.d.ts +1 -0
- package/esm/typings/src/utils/serialization/deepClone.d.ts +1 -0
- package/esm/typings/src/utils/trimCodeBlock.d.ts +1 -0
- package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +1 -0
- package/esm/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +169 -10
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/book-2.0/commitments/_misc/parseAgentSourceWithCommitments.d.ts +0 -24
- package/esm/typings/src/book-2.0/utils/profileImageUtils.d.ts +0 -39
- /package/esm/typings/src/book-2.0/{commitments/_misc → agent-source}/removeCommentsFromSystemMessage.d.ts +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { string_markdown } from '../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Change ellipsis character to three dots `…` -> `...`
|
|
4
|
+
*
|
|
5
|
+
* Note: [🔂] This function is idempotent.
|
|
6
|
+
* Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
|
|
7
|
+
*
|
|
8
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
9
|
+
*/
|
|
10
|
+
export declare function humanizeAiTextEllipsis(aiText: string_markdown): string_markdown;
|
|
11
|
+
/**
|
|
12
|
+
* Note: [🏂] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
|
|
13
|
+
*/
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { string_markdown } from '../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Change em-dashes to regular dashes `—` -> `-`
|
|
4
|
+
*
|
|
5
|
+
* Note: [🔂] This function is idempotent.
|
|
6
|
+
* Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
|
|
7
|
+
*
|
|
8
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
9
|
+
*/
|
|
10
|
+
export declare function humanizeAiTextEmdashed(aiText: string_markdown): string_markdown;
|
|
11
|
+
/**
|
|
12
|
+
* Note: [🏂] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
|
|
13
|
+
*/
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { string_markdown } from '../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Change smart quotes to regular quotes
|
|
4
|
+
*
|
|
5
|
+
* Note: [🔂] This function is idempotent.
|
|
6
|
+
* Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
|
|
7
|
+
*
|
|
8
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
9
|
+
*/
|
|
10
|
+
export declare function humanizeAiTextQuotes(aiText: string_markdown): string_markdown;
|
|
11
|
+
/**
|
|
12
|
+
* Note: [🏂] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
|
|
13
|
+
*/
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { string_markdown } from '../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Change unprintable hard spaces to regular spaces
|
|
4
|
+
*
|
|
5
|
+
* Note: [🔂] This function is idempotent.
|
|
6
|
+
* Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
|
|
7
|
+
*
|
|
8
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
9
|
+
*/
|
|
10
|
+
export declare function humanizeAiTextWhitespace(aiText: string_markdown): string_markdown;
|
|
11
|
+
/**
|
|
12
|
+
* Note: [🏂] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
|
|
13
|
+
*/
|
|
@@ -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>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { string_markdown } from '../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Function `promptbookifyAiText` will slightly modify the text so we know it was processed by Promptbook
|
|
4
|
+
*
|
|
5
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
6
|
+
*/
|
|
7
|
+
export declare function promptbookifyAiText(text: string_markdown): string_markdown;
|
|
8
|
+
/**
|
|
9
|
+
* TODO: !!!!! Make the function idempotent and add "Note: [🔂] This function is idempotent."
|
|
10
|
+
* TODO: [🅾️]!!! Use this across the project where AI text is involved
|
|
11
|
+
* TODO: [🧠][✌️] Make some Promptbook-native token system
|
|
12
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes Markdown link tags from a string.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} str - The string to remove Markdown tags from.
|
|
5
|
+
* @returns {string} The input string with all Markdown tags removed.
|
|
6
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
7
|
+
*/
|
|
8
|
+
export declare function removeMarkdownLinks(str: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* @see https://chat.openai.com/chat/bb7c3a5b-fe9c-4ccc-9057-f47e0fd66489
|
|
11
|
+
*/
|
|
@@ -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
|
* 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
|
* 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.
|
|
18
|
+
* It follows semantic versioning (e.g., `0.101.0-0`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
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('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-markdown-utils"] = {}, global.spaceTrim, global.
|
|
5
|
-
})(this, (function (exports, spaceTrim,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('crypto'), require('rxjs'), require('waitasecond'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('path'), require('crypto-js'), require('mime-types'), require('papaparse')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'crypto', 'rxjs', 'waitasecond', 'crypto-js/enc-hex', 'crypto-js/sha256', 'path', 'crypto-js', 'mime-types', 'papaparse'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-markdown-utils"] = {}, global.spaceTrim, global.crypto, global.rxjs, global.waitasecond, global.hexEncoder, global.sha256, global.path, global.cryptoJs, global.mimeTypes, global.papaparse));
|
|
5
|
+
})(this, (function (exports, spaceTrim, crypto, rxjs, waitasecond, hexEncoder, sha256, path, cryptoJs, mimeTypes, papaparse) { '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
|
var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
|
|
13
11
|
var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
|
|
14
12
|
|
|
@@ -26,7 +24,7 @@
|
|
|
26
24
|
* @generated
|
|
27
25
|
* @see https://github.com/webgptorg/promptbook
|
|
28
26
|
*/
|
|
29
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.
|
|
27
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.101.0-1';
|
|
30
28
|
/**
|
|
31
29
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
30
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -51,6 +49,8 @@
|
|
|
51
49
|
/**
|
|
52
50
|
* Makes first letter of a string uppercase
|
|
53
51
|
*
|
|
52
|
+
* Note: [🔂] This function is idempotent.
|
|
53
|
+
*
|
|
54
54
|
* @public exported from `@promptbook/utils`
|
|
55
55
|
*/
|
|
56
56
|
function capitalize(word) {
|
|
@@ -642,6 +642,7 @@
|
|
|
642
642
|
/**
|
|
643
643
|
* Tests if given string is valid URL.
|
|
644
644
|
*
|
|
645
|
+
* Note: [🔂] This function is idempotent.
|
|
645
646
|
* Note: Dataurl are considered perfectly valid.
|
|
646
647
|
* Note: There are two similar functions:
|
|
647
648
|
* - `isValidUrl` which tests any URL
|
|
@@ -705,10 +706,20 @@
|
|
|
705
706
|
* @private withing the package because of HUGE size of prettier dependency
|
|
706
707
|
*/
|
|
707
708
|
function prettifyMarkdown(content) {
|
|
709
|
+
// In browser/Next.js environments, just return the original content
|
|
710
|
+
// since prettier parsers are not available and would cause bundling issues
|
|
711
|
+
if (typeof window !== 'undefined') {
|
|
712
|
+
return content;
|
|
713
|
+
}
|
|
708
714
|
try {
|
|
709
|
-
|
|
715
|
+
// Use dynamic require to avoid static imports that cause bundling issues
|
|
716
|
+
// This will only work in Node.js environments
|
|
717
|
+
const prettierStandalone = eval('require')('prettier/standalone');
|
|
718
|
+
const parserMarkdown = eval('require')('prettier/parser-markdown');
|
|
719
|
+
const parserHtml = eval('require')('prettier/parser-html');
|
|
720
|
+
return prettierStandalone.format(content, {
|
|
710
721
|
parser: 'markdown',
|
|
711
|
-
plugins: [
|
|
722
|
+
plugins: [parserMarkdown, parserHtml],
|
|
712
723
|
// TODO: DRY - make some import or auto-copy of .prettierrc
|
|
713
724
|
endOfLine: 'lf',
|
|
714
725
|
tabWidth: 4,
|
|
@@ -1054,6 +1065,7 @@
|
|
|
1054
1065
|
/**
|
|
1055
1066
|
* Creates a deep clone of the given object
|
|
1056
1067
|
*
|
|
1068
|
+
* Note: [🔂] This function is idempotent.
|
|
1057
1069
|
* Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
|
|
1058
1070
|
*
|
|
1059
1071
|
* @param objectValue The object to clone.
|
|
@@ -2680,7 +2692,7 @@
|
|
|
2680
2692
|
};
|
|
2681
2693
|
/**
|
|
2682
2694
|
* TODO: Refactor this - each profile must be alongside the provider definition
|
|
2683
|
-
* TODO: [🕛] Unite `
|
|
2695
|
+
* TODO: [🕛] Unite `AgentBasicInformation`, `ChatParticipant`, `LlmExecutionTools` + `LlmToolsMetadata`
|
|
2684
2696
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2685
2697
|
*/
|
|
2686
2698
|
|
|
@@ -2989,6 +3001,8 @@
|
|
|
2989
3001
|
/**
|
|
2990
3002
|
* Normalizes a text string to SCREAMING_CASE (all uppercase with underscores).
|
|
2991
3003
|
*
|
|
3004
|
+
* Note: [🔂] This function is idempotent.
|
|
3005
|
+
*
|
|
2992
3006
|
* @param text The text string to be converted to SCREAMING_CASE format.
|
|
2993
3007
|
* @returns The normalized text in SCREAMING_CASE format.
|
|
2994
3008
|
* @example 'HELLO_WORLD'
|
|
@@ -3044,6 +3058,8 @@
|
|
|
3044
3058
|
/**
|
|
3045
3059
|
* Normalizes a text string to snake_case format.
|
|
3046
3060
|
*
|
|
3061
|
+
* Note: [🔂] This function is idempotent.
|
|
3062
|
+
*
|
|
3047
3063
|
* @param text The text string to be converted to snake_case format.
|
|
3048
3064
|
* @returns The normalized text in snake_case format.
|
|
3049
3065
|
* @example 'hello_world'
|
|
@@ -3461,6 +3477,8 @@
|
|
|
3461
3477
|
/**
|
|
3462
3478
|
* Removes diacritic marks (accents) from characters in a string.
|
|
3463
3479
|
*
|
|
3480
|
+
* Note: [🔂] This function is idempotent.
|
|
3481
|
+
*
|
|
3464
3482
|
* @param input The string containing diacritics to be normalized.
|
|
3465
3483
|
* @returns The string with diacritics removed or normalized.
|
|
3466
3484
|
* @public exported from `@promptbook/utils`
|
|
@@ -3615,6 +3633,8 @@
|
|
|
3615
3633
|
/**
|
|
3616
3634
|
* Removes emojis from a string and fix whitespaces
|
|
3617
3635
|
*
|
|
3636
|
+
* Note: [🔂] This function is idempotent.
|
|
3637
|
+
*
|
|
3618
3638
|
* @param text with emojis
|
|
3619
3639
|
* @returns text without emojis
|
|
3620
3640
|
* @public exported from `@promptbook/utils`
|
|
@@ -4889,6 +4909,7 @@
|
|
|
4889
4909
|
}
|
|
4890
4910
|
/**
|
|
4891
4911
|
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
4912
|
+
* TODO: [🧠][✌️] Make some Promptbook-native token system
|
|
4892
4913
|
*/
|
|
4893
4914
|
|
|
4894
4915
|
/**
|
|
@@ -4923,6 +4944,7 @@
|
|
|
4923
4944
|
}
|
|
4924
4945
|
/**
|
|
4925
4946
|
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
4947
|
+
* TODO: [🧠][✌️] Make some Promptbook-native token system
|
|
4926
4948
|
*/
|
|
4927
4949
|
|
|
4928
4950
|
/**
|
|
@@ -4937,6 +4959,7 @@
|
|
|
4937
4959
|
}
|
|
4938
4960
|
/**
|
|
4939
4961
|
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
4962
|
+
* TODO: [🧠][✌️] Make some Promptbook-native token system
|
|
4940
4963
|
*/
|
|
4941
4964
|
|
|
4942
4965
|
/**
|
|
@@ -4949,6 +4972,7 @@
|
|
|
4949
4972
|
}
|
|
4950
4973
|
/**
|
|
4951
4974
|
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
4975
|
+
* TODO: [🧠][✌️] Make some Promptbook-native token system
|
|
4952
4976
|
*/
|
|
4953
4977
|
|
|
4954
4978
|
/**
|
|
@@ -4969,6 +4993,7 @@
|
|
|
4969
4993
|
}
|
|
4970
4994
|
/**
|
|
4971
4995
|
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
4996
|
+
* TODO: [🧠][✌️] Make some Promptbook-native token system
|
|
4972
4997
|
*/
|
|
4973
4998
|
|
|
4974
4999
|
/**
|
|
@@ -4985,6 +5010,8 @@
|
|
|
4985
5010
|
}
|
|
4986
5011
|
/**
|
|
4987
5012
|
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
5013
|
+
* TODO: [🧠][✌️] Make some Promptbook-native token system
|
|
5014
|
+
* TODO: [✌️] `countWords` should be just `splitWords(...).length`, and all other counters should use this pattern as well
|
|
4988
5015
|
*/
|
|
4989
5016
|
|
|
4990
5017
|
/**
|
|
@@ -6609,6 +6636,8 @@
|
|
|
6609
6636
|
* Function escapeMarkdownBlock will escape markdown block if needed
|
|
6610
6637
|
* It is useful when you want have block in block
|
|
6611
6638
|
*
|
|
6639
|
+
* Note: [🔂] This function is idempotent.
|
|
6640
|
+
*
|
|
6612
6641
|
* @public exported from `@promptbook/markdown-utils`
|
|
6613
6642
|
*/
|
|
6614
6643
|
function escapeMarkdownBlock(value) {
|
|
@@ -6773,6 +6802,114 @@
|
|
|
6773
6802
|
* NOW we are working just with markdown string and its good enough
|
|
6774
6803
|
*/
|
|
6775
6804
|
|
|
6805
|
+
/**
|
|
6806
|
+
* Change ellipsis character to three dots `…` -> `...`
|
|
6807
|
+
*
|
|
6808
|
+
* Note: [🔂] This function is idempotent.
|
|
6809
|
+
* Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
|
|
6810
|
+
*
|
|
6811
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
6812
|
+
*/
|
|
6813
|
+
function humanizeAiTextEllipsis(aiText) {
|
|
6814
|
+
return aiText.replace(/…/g, '...');
|
|
6815
|
+
}
|
|
6816
|
+
/**
|
|
6817
|
+
* Note: [🏂] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
|
|
6818
|
+
*/
|
|
6819
|
+
|
|
6820
|
+
/**
|
|
6821
|
+
* Change em-dashes to regular dashes `—` -> `-`
|
|
6822
|
+
*
|
|
6823
|
+
* Note: [🔂] This function is idempotent.
|
|
6824
|
+
* Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
|
|
6825
|
+
*
|
|
6826
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
6827
|
+
*/
|
|
6828
|
+
function humanizeAiTextEmdashed(aiText) {
|
|
6829
|
+
return aiText.replace(/—/g, '-');
|
|
6830
|
+
}
|
|
6831
|
+
/**
|
|
6832
|
+
* Note: [🏂] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
|
|
6833
|
+
*/
|
|
6834
|
+
|
|
6835
|
+
/**
|
|
6836
|
+
* Change smart quotes to regular quotes
|
|
6837
|
+
*
|
|
6838
|
+
* Note: [🔂] This function is idempotent.
|
|
6839
|
+
* Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
|
|
6840
|
+
*
|
|
6841
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
6842
|
+
*/
|
|
6843
|
+
function humanizeAiTextQuotes(aiText) {
|
|
6844
|
+
return aiText
|
|
6845
|
+
.replace(/[“”]/g, '"')
|
|
6846
|
+
.replace(/[‚‘’]/g, "'")
|
|
6847
|
+
.replace(/«/g, '"')
|
|
6848
|
+
.replace(/»/g, '"')
|
|
6849
|
+
.replace(/„/g, '"')
|
|
6850
|
+
.replace(/‹/g, "'")
|
|
6851
|
+
.replace(/›/g, "'");
|
|
6852
|
+
}
|
|
6853
|
+
/**
|
|
6854
|
+
* Note: [🏂] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
|
|
6855
|
+
*/
|
|
6856
|
+
|
|
6857
|
+
/**
|
|
6858
|
+
* Change unprintable hard spaces to regular spaces
|
|
6859
|
+
*
|
|
6860
|
+
* Note: [🔂] This function is idempotent.
|
|
6861
|
+
* Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
|
|
6862
|
+
*
|
|
6863
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
6864
|
+
*/
|
|
6865
|
+
function humanizeAiTextWhitespace(aiText) {
|
|
6866
|
+
return aiText.replace(/\u00A0/g, ' ');
|
|
6867
|
+
}
|
|
6868
|
+
/**
|
|
6869
|
+
* Note: [🏂] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
|
|
6870
|
+
*/
|
|
6871
|
+
|
|
6872
|
+
/**
|
|
6873
|
+
* Function `humanizeAiText` will remove traces of AI text generation artifacts
|
|
6874
|
+
*
|
|
6875
|
+
* Note: [🔂] This function is idempotent.
|
|
6876
|
+
* Tip: If you want more control, look for other functions for example `humanizeAiTextEmdashed` exported `@promptbook/markdown-utils`
|
|
6877
|
+
*
|
|
6878
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
6879
|
+
*/
|
|
6880
|
+
function humanizeAiText(aiText) {
|
|
6881
|
+
let cleanedText = aiText;
|
|
6882
|
+
cleanedText = humanizeAiTextEllipsis(cleanedText);
|
|
6883
|
+
cleanedText = humanizeAiTextEmdashed(cleanedText);
|
|
6884
|
+
cleanedText = humanizeAiTextQuotes(cleanedText);
|
|
6885
|
+
cleanedText = humanizeAiTextWhitespace(cleanedText);
|
|
6886
|
+
return cleanedText;
|
|
6887
|
+
}
|
|
6888
|
+
/**
|
|
6889
|
+
* TODO: [🅾️] !!! Use this across the project where AI text is involved
|
|
6890
|
+
*/
|
|
6891
|
+
|
|
6892
|
+
/**
|
|
6893
|
+
* Function `promptbookifyAiText` will slightly modify the text so we know it was processed by Promptbook
|
|
6894
|
+
*
|
|
6895
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
6896
|
+
*/
|
|
6897
|
+
function promptbookifyAiText(text) {
|
|
6898
|
+
// Note: Duplicating some spaces
|
|
6899
|
+
const words = text.split(' '); // <- Note: [✌️] Use `splitWords` when available
|
|
6900
|
+
const wordLength = words.length; // <- Note: [✌️] `countWords` should be just `splitWords(...).length`
|
|
6901
|
+
for (const wordIndex of [3, 7, 11, 19].filter((i) => i < wordLength)) {
|
|
6902
|
+
words[wordIndex] = ' ' + words[wordIndex];
|
|
6903
|
+
}
|
|
6904
|
+
const promptbookifiedText = words.join(' ');
|
|
6905
|
+
return promptbookifiedText;
|
|
6906
|
+
}
|
|
6907
|
+
/**
|
|
6908
|
+
* TODO: !!!!! Make the function idempotent and add "Note: [🔂] This function is idempotent."
|
|
6909
|
+
* TODO: [🅾️]!!! Use this across the project where AI text is involved
|
|
6910
|
+
* TODO: [🧠][✌️] Make some Promptbook-native token system
|
|
6911
|
+
*/
|
|
6912
|
+
|
|
6776
6913
|
/**
|
|
6777
6914
|
* Removes Markdown formatting tags from a string.
|
|
6778
6915
|
*
|
|
@@ -6790,6 +6927,21 @@
|
|
|
6790
6927
|
return str;
|
|
6791
6928
|
}
|
|
6792
6929
|
|
|
6930
|
+
/**
|
|
6931
|
+
* Removes Markdown link tags from a string.
|
|
6932
|
+
*
|
|
6933
|
+
* @param {string} str - The string to remove Markdown tags from.
|
|
6934
|
+
* @returns {string} The input string with all Markdown tags removed.
|
|
6935
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
6936
|
+
*/
|
|
6937
|
+
function removeMarkdownLinks(str) {
|
|
6938
|
+
// Use regular expressions to remove Markdown tags from the string
|
|
6939
|
+
return str.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '$1');
|
|
6940
|
+
}
|
|
6941
|
+
/**
|
|
6942
|
+
* @see https://chat.openai.com/chat/bb7c3a5b-fe9c-4ccc-9057-f47e0fd66489
|
|
6943
|
+
*/
|
|
6944
|
+
|
|
6793
6945
|
exports.BOOK_LANGUAGE_VERSION = BOOK_LANGUAGE_VERSION;
|
|
6794
6946
|
exports.MarkdownScraper = MarkdownScraper;
|
|
6795
6947
|
exports.PROMPTBOOK_ENGINE_VERSION = PROMPTBOOK_ENGINE_VERSION;
|
|
@@ -6805,9 +6957,16 @@
|
|
|
6805
6957
|
exports.extractJsonBlock = extractJsonBlock;
|
|
6806
6958
|
exports.extractOneBlockFromMarkdown = extractOneBlockFromMarkdown;
|
|
6807
6959
|
exports.flattenMarkdown = flattenMarkdown;
|
|
6960
|
+
exports.humanizeAiText = humanizeAiText;
|
|
6961
|
+
exports.humanizeAiTextEllipsis = humanizeAiTextEllipsis;
|
|
6962
|
+
exports.humanizeAiTextEmdashed = humanizeAiTextEmdashed;
|
|
6963
|
+
exports.humanizeAiTextQuotes = humanizeAiTextQuotes;
|
|
6964
|
+
exports.humanizeAiTextWhitespace = humanizeAiTextWhitespace;
|
|
6808
6965
|
exports.parseMarkdownSection = parseMarkdownSection;
|
|
6966
|
+
exports.promptbookifyAiText = promptbookifyAiText;
|
|
6809
6967
|
exports.removeMarkdownComments = removeMarkdownComments;
|
|
6810
6968
|
exports.removeMarkdownFormatting = removeMarkdownFormatting;
|
|
6969
|
+
exports.removeMarkdownLinks = removeMarkdownLinks;
|
|
6811
6970
|
exports.splitMarkdownIntoSections = splitMarkdownIntoSections;
|
|
6812
6971
|
|
|
6813
6972
|
Object.defineProperty(exports, '__esModule', { value: true });
|