@promptbook/legacy-documents 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 +32 -6
- 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 +2 -2
- package/umd/index.umd.js +37 -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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/legacy-documents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.101.0-1",
|
|
4
4
|
"description": "Promptbook: Run AI apps in plain human language across multiple models and platforms",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"module": "./esm/index.es.js",
|
|
96
96
|
"typings": "./esm/typings/src/_packages/legacy-documents.index.d.ts",
|
|
97
97
|
"peerDependencies": {
|
|
98
|
-
"@promptbook/core": "0.
|
|
98
|
+
"@promptbook/core": "0.101.0-1"
|
|
99
99
|
},
|
|
100
100
|
"dependencies": {
|
|
101
101
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('fs/promises'), require('path'), require('spacetrim'), require('child_process'), require('colors'), require('waitasecond'), require('crypto-js'), require('crypto-js/enc-hex'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'fs/promises', 'path', 'spacetrim', 'child_process', 'colors', 'waitasecond', 'crypto-js', 'crypto-js/enc-hex', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-legacy-documents"] = {}, global.promises, global.path, global.spaceTrim, global.child_process, global.colors, global.waitasecond, global.cryptoJs, global.hexEncoder, global.
|
|
5
|
-
})(this, (function (exports, promises, path, spaceTrim, child_process, colors, waitasecond, cryptoJs, hexEncoder,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('fs/promises'), require('path'), require('spacetrim'), require('child_process'), require('colors'), require('waitasecond'), require('crypto-js'), require('crypto-js/enc-hex'), require('crypto'), require('rxjs'), require('crypto-js/sha256'), require('mime-types'), require('papaparse')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'fs/promises', 'path', 'spacetrim', 'child_process', 'colors', 'waitasecond', 'crypto-js', 'crypto-js/enc-hex', 'crypto', 'rxjs', 'crypto-js/sha256', 'mime-types', 'papaparse'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-legacy-documents"] = {}, global.promises, global.path, global.spaceTrim, global.child_process, global.colors, global.waitasecond, global.cryptoJs, global.hexEncoder, global.crypto, global.rxjs, global.sha256, global.mimeTypes, global.papaparse));
|
|
5
|
+
})(this, (function (exports, promises, path, spaceTrim, child_process, colors, waitasecond, cryptoJs, hexEncoder, crypto, rxjs, sha256, 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
10
|
var colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
|
|
11
11
|
var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
|
|
12
|
-
var parserHtml__default = /*#__PURE__*/_interopDefaultLegacy(parserHtml);
|
|
13
|
-
var parserMarkdown__default = /*#__PURE__*/_interopDefaultLegacy(parserMarkdown);
|
|
14
12
|
var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
|
|
15
13
|
|
|
16
14
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
@@ -27,7 +25,7 @@
|
|
|
27
25
|
* @generated
|
|
28
26
|
* @see https://github.com/webgptorg/promptbook
|
|
29
27
|
*/
|
|
30
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.
|
|
28
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.101.0-1';
|
|
31
29
|
/**
|
|
32
30
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
33
31
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -830,6 +828,8 @@
|
|
|
830
828
|
/**
|
|
831
829
|
* Removes diacritic marks (accents) from characters in a string.
|
|
832
830
|
*
|
|
831
|
+
* Note: [🔂] This function is idempotent.
|
|
832
|
+
*
|
|
833
833
|
* @param input The string containing diacritics to be normalized.
|
|
834
834
|
* @returns The string with diacritics removed or normalized.
|
|
835
835
|
* @public exported from `@promptbook/utils`
|
|
@@ -898,6 +898,8 @@
|
|
|
898
898
|
/**
|
|
899
899
|
* Removes emojis from a string and fix whitespaces
|
|
900
900
|
*
|
|
901
|
+
* Note: [🔂] This function is idempotent.
|
|
902
|
+
*
|
|
901
903
|
* @param text with emojis
|
|
902
904
|
* @returns text without emojis
|
|
903
905
|
* @public exported from `@promptbook/utils`
|
|
@@ -970,6 +972,7 @@
|
|
|
970
972
|
/**
|
|
971
973
|
* Tests if given string is valid URL.
|
|
972
974
|
*
|
|
975
|
+
* Note: [🔂] This function is idempotent.
|
|
973
976
|
* Note: Dataurl are considered perfectly valid.
|
|
974
977
|
* Note: There are two similar functions:
|
|
975
978
|
* - `isValidUrl` which tests any URL
|
|
@@ -1229,10 +1232,20 @@
|
|
|
1229
1232
|
* @private withing the package because of HUGE size of prettier dependency
|
|
1230
1233
|
*/
|
|
1231
1234
|
function prettifyMarkdown(content) {
|
|
1235
|
+
// In browser/Next.js environments, just return the original content
|
|
1236
|
+
// since prettier parsers are not available and would cause bundling issues
|
|
1237
|
+
if (typeof window !== 'undefined') {
|
|
1238
|
+
return content;
|
|
1239
|
+
}
|
|
1232
1240
|
try {
|
|
1233
|
-
|
|
1241
|
+
// Use dynamic require to avoid static imports that cause bundling issues
|
|
1242
|
+
// This will only work in Node.js environments
|
|
1243
|
+
const prettierStandalone = eval('require')('prettier/standalone');
|
|
1244
|
+
const parserMarkdown = eval('require')('prettier/parser-markdown');
|
|
1245
|
+
const parserHtml = eval('require')('prettier/parser-html');
|
|
1246
|
+
return prettierStandalone.format(content, {
|
|
1234
1247
|
parser: 'markdown',
|
|
1235
|
-
plugins: [
|
|
1248
|
+
plugins: [parserMarkdown, parserHtml],
|
|
1236
1249
|
// TODO: DRY - make some import or auto-copy of .prettierrc
|
|
1237
1250
|
endOfLine: 'lf',
|
|
1238
1251
|
tabWidth: 4,
|
|
@@ -1258,6 +1271,8 @@
|
|
|
1258
1271
|
/**
|
|
1259
1272
|
* Makes first letter of a string uppercase
|
|
1260
1273
|
*
|
|
1274
|
+
* Note: [🔂] This function is idempotent.
|
|
1275
|
+
*
|
|
1261
1276
|
* @public exported from `@promptbook/utils`
|
|
1262
1277
|
*/
|
|
1263
1278
|
function capitalize(word) {
|
|
@@ -1587,6 +1602,7 @@
|
|
|
1587
1602
|
/**
|
|
1588
1603
|
* Creates a deep clone of the given object
|
|
1589
1604
|
*
|
|
1605
|
+
* Note: [🔂] This function is idempotent.
|
|
1590
1606
|
* Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
|
|
1591
1607
|
*
|
|
1592
1608
|
* @param objectValue The object to clone.
|
|
@@ -3169,7 +3185,7 @@
|
|
|
3169
3185
|
};
|
|
3170
3186
|
/**
|
|
3171
3187
|
* TODO: Refactor this - each profile must be alongside the provider definition
|
|
3172
|
-
* TODO: [🕛] Unite `
|
|
3188
|
+
* TODO: [🕛] Unite `AgentBasicInformation`, `ChatParticipant`, `LlmExecutionTools` + `LlmToolsMetadata`
|
|
3173
3189
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
3174
3190
|
*/
|
|
3175
3191
|
|
|
@@ -3478,6 +3494,8 @@
|
|
|
3478
3494
|
/**
|
|
3479
3495
|
* Normalizes a text string to SCREAMING_CASE (all uppercase with underscores).
|
|
3480
3496
|
*
|
|
3497
|
+
* Note: [🔂] This function is idempotent.
|
|
3498
|
+
*
|
|
3481
3499
|
* @param text The text string to be converted to SCREAMING_CASE format.
|
|
3482
3500
|
* @returns The normalized text in SCREAMING_CASE format.
|
|
3483
3501
|
* @example 'HELLO_WORLD'
|
|
@@ -3533,6 +3551,8 @@
|
|
|
3533
3551
|
/**
|
|
3534
3552
|
* Normalizes a text string to snake_case format.
|
|
3535
3553
|
*
|
|
3554
|
+
* Note: [🔂] This function is idempotent.
|
|
3555
|
+
*
|
|
3536
3556
|
* @param text The text string to be converted to snake_case format.
|
|
3537
3557
|
* @returns The normalized text in snake_case format.
|
|
3538
3558
|
* @example 'hello_world'
|
|
@@ -5083,6 +5103,7 @@
|
|
|
5083
5103
|
}
|
|
5084
5104
|
/**
|
|
5085
5105
|
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
5106
|
+
* TODO: [🧠][✌️] Make some Promptbook-native token system
|
|
5086
5107
|
*/
|
|
5087
5108
|
|
|
5088
5109
|
/**
|
|
@@ -5117,6 +5138,7 @@
|
|
|
5117
5138
|
}
|
|
5118
5139
|
/**
|
|
5119
5140
|
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
5141
|
+
* TODO: [🧠][✌️] Make some Promptbook-native token system
|
|
5120
5142
|
*/
|
|
5121
5143
|
|
|
5122
5144
|
/**
|
|
@@ -5131,6 +5153,7 @@
|
|
|
5131
5153
|
}
|
|
5132
5154
|
/**
|
|
5133
5155
|
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
5156
|
+
* TODO: [🧠][✌️] Make some Promptbook-native token system
|
|
5134
5157
|
*/
|
|
5135
5158
|
|
|
5136
5159
|
/**
|
|
@@ -5143,6 +5166,7 @@
|
|
|
5143
5166
|
}
|
|
5144
5167
|
/**
|
|
5145
5168
|
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
5169
|
+
* TODO: [🧠][✌️] Make some Promptbook-native token system
|
|
5146
5170
|
*/
|
|
5147
5171
|
|
|
5148
5172
|
/**
|
|
@@ -5163,6 +5187,7 @@
|
|
|
5163
5187
|
}
|
|
5164
5188
|
/**
|
|
5165
5189
|
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
5190
|
+
* TODO: [🧠][✌️] Make some Promptbook-native token system
|
|
5166
5191
|
*/
|
|
5167
5192
|
|
|
5168
5193
|
/**
|
|
@@ -5179,6 +5204,8 @@
|
|
|
5179
5204
|
}
|
|
5180
5205
|
/**
|
|
5181
5206
|
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
5207
|
+
* TODO: [🧠][✌️] Make some Promptbook-native token system
|
|
5208
|
+
* TODO: [✌️] `countWords` should be just `splitWords(...).length`, and all other counters should use this pattern as well
|
|
5182
5209
|
*/
|
|
5183
5210
|
|
|
5184
5211
|
/**
|