@promptbook/markdown-utils 0.100.3-0 → 0.101.0-0
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 +127 -3
- package/esm/index.es.js.map +1 -1
- 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/types/ChatParticipant.d.ts +1 -1
- 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/humanizeAiText.d.ts +12 -0
- package/esm/typings/src/utils/markdown/humanizeAiText.test.d.ts +1 -0
- package/esm/typings/src/utils/markdown/humanizeAiTextEllipsis.d.ts +12 -0
- package/esm/typings/src/utils/markdown/humanizeAiTextEmdashed.d.ts +12 -0
- package/esm/typings/src/utils/markdown/humanizeAiTextQuotes.d.ts +12 -0
- package/esm/typings/src/utils/markdown/humanizeAiTextWhitespace.d.ts +12 -0
- package/esm/typings/src/utils/markdown/promptbookifyAiText.d.ts +11 -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/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +133 -2
- 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
package/esm/index.es.js
CHANGED
|
@@ -26,7 +26,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
26
26
|
* @generated
|
|
27
27
|
* @see https://github.com/webgptorg/promptbook
|
|
28
28
|
*/
|
|
29
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.
|
|
29
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.101.0-0';
|
|
30
30
|
/**
|
|
31
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
32
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2680,7 +2680,7 @@ const LLM_PROVIDER_PROFILES = {
|
|
|
2680
2680
|
};
|
|
2681
2681
|
/**
|
|
2682
2682
|
* TODO: Refactor this - each profile must be alongside the provider definition
|
|
2683
|
-
* TODO: [🕛] Unite `
|
|
2683
|
+
* TODO: [🕛] Unite `AgentBasicInformation`, `ChatParticipant`, `LlmExecutionTools` + `LlmToolsMetadata`
|
|
2684
2684
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2685
2685
|
*/
|
|
2686
2686
|
|
|
@@ -4889,6 +4889,7 @@ function countCharacters(text) {
|
|
|
4889
4889
|
}
|
|
4890
4890
|
/**
|
|
4891
4891
|
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
4892
|
+
* TODO: [🧠][✌️] Make some Promptbook-native token system
|
|
4892
4893
|
*/
|
|
4893
4894
|
|
|
4894
4895
|
/**
|
|
@@ -4923,6 +4924,7 @@ function countLines(text) {
|
|
|
4923
4924
|
}
|
|
4924
4925
|
/**
|
|
4925
4926
|
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
4927
|
+
* TODO: [🧠][✌️] Make some Promptbook-native token system
|
|
4926
4928
|
*/
|
|
4927
4929
|
|
|
4928
4930
|
/**
|
|
@@ -4937,6 +4939,7 @@ function countPages(text) {
|
|
|
4937
4939
|
}
|
|
4938
4940
|
/**
|
|
4939
4941
|
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
4942
|
+
* TODO: [🧠][✌️] Make some Promptbook-native token system
|
|
4940
4943
|
*/
|
|
4941
4944
|
|
|
4942
4945
|
/**
|
|
@@ -4949,6 +4952,7 @@ function countParagraphs(text) {
|
|
|
4949
4952
|
}
|
|
4950
4953
|
/**
|
|
4951
4954
|
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
4955
|
+
* TODO: [🧠][✌️] Make some Promptbook-native token system
|
|
4952
4956
|
*/
|
|
4953
4957
|
|
|
4954
4958
|
/**
|
|
@@ -4969,6 +4973,7 @@ function countSentences(text) {
|
|
|
4969
4973
|
}
|
|
4970
4974
|
/**
|
|
4971
4975
|
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
4976
|
+
* TODO: [🧠][✌️] Make some Promptbook-native token system
|
|
4972
4977
|
*/
|
|
4973
4978
|
|
|
4974
4979
|
/**
|
|
@@ -4985,6 +4990,8 @@ function countWords(text) {
|
|
|
4985
4990
|
}
|
|
4986
4991
|
/**
|
|
4987
4992
|
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
4993
|
+
* TODO: [🧠][✌️] Make some Promptbook-native token system
|
|
4994
|
+
* TODO: [✌️] `countWords` should be just `splitWords(...).length`, and all other counters should use this pattern as well
|
|
4988
4995
|
*/
|
|
4989
4996
|
|
|
4990
4997
|
/**
|
|
@@ -6773,6 +6780,108 @@ function flattenMarkdown(markdown) {
|
|
|
6773
6780
|
* NOW we are working just with markdown string and its good enough
|
|
6774
6781
|
*/
|
|
6775
6782
|
|
|
6783
|
+
/**
|
|
6784
|
+
* Change ellipsis character to three dots `…` -> `...`
|
|
6785
|
+
*
|
|
6786
|
+
* Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
|
|
6787
|
+
*
|
|
6788
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
6789
|
+
*/
|
|
6790
|
+
function humanizeAiTextEllipsis(aiText) {
|
|
6791
|
+
return aiText.replace(/…/g, '...');
|
|
6792
|
+
}
|
|
6793
|
+
/**
|
|
6794
|
+
* Note: [🏂] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
|
|
6795
|
+
*/
|
|
6796
|
+
|
|
6797
|
+
/**
|
|
6798
|
+
* Change em-dashes to regular dashes `—` -> `-`
|
|
6799
|
+
*
|
|
6800
|
+
* Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
|
|
6801
|
+
*
|
|
6802
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
6803
|
+
*/
|
|
6804
|
+
function humanizeAiTextEmdashed(aiText) {
|
|
6805
|
+
return aiText.replace(/—/g, '-');
|
|
6806
|
+
}
|
|
6807
|
+
/**
|
|
6808
|
+
* Note: [🏂] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
|
|
6809
|
+
*/
|
|
6810
|
+
|
|
6811
|
+
/**
|
|
6812
|
+
* Change smart quotes to regular quotes
|
|
6813
|
+
*
|
|
6814
|
+
* Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
|
|
6815
|
+
*
|
|
6816
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
6817
|
+
*/
|
|
6818
|
+
function humanizeAiTextQuotes(aiText) {
|
|
6819
|
+
return aiText
|
|
6820
|
+
.replace(/[“”]/g, '"')
|
|
6821
|
+
.replace(/[‚‘’]/g, "'")
|
|
6822
|
+
.replace(/«/g, '"')
|
|
6823
|
+
.replace(/»/g, '"')
|
|
6824
|
+
.replace(/„/g, '"')
|
|
6825
|
+
.replace(/‹/g, "'")
|
|
6826
|
+
.replace(/›/g, "'");
|
|
6827
|
+
}
|
|
6828
|
+
/**
|
|
6829
|
+
* Note: [🏂] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
|
|
6830
|
+
*/
|
|
6831
|
+
|
|
6832
|
+
/**
|
|
6833
|
+
* Change unprintable hard spaces to regular spaces
|
|
6834
|
+
*
|
|
6835
|
+
* Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
|
|
6836
|
+
*
|
|
6837
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
6838
|
+
*/
|
|
6839
|
+
function humanizeAiTextWhitespace(aiText) {
|
|
6840
|
+
return aiText.replace(/\u00A0/g, ' ');
|
|
6841
|
+
}
|
|
6842
|
+
/**
|
|
6843
|
+
* Note: [🏂] This function is not tested by itself but together with other cleanup functions with `humanizeAiText`
|
|
6844
|
+
*/
|
|
6845
|
+
|
|
6846
|
+
/**
|
|
6847
|
+
* Function `humanizeAiText` will remove traces of AI text generation artifacts
|
|
6848
|
+
*
|
|
6849
|
+
* Tip: If you want more control, look for other functions for example `humanizeAiTextEmdashed` exported `@promptbook/markdown-utils`
|
|
6850
|
+
*
|
|
6851
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
6852
|
+
*/
|
|
6853
|
+
function humanizeAiText(aiText) {
|
|
6854
|
+
let cleanedText = aiText;
|
|
6855
|
+
cleanedText = humanizeAiTextEllipsis(cleanedText);
|
|
6856
|
+
cleanedText = humanizeAiTextEmdashed(cleanedText);
|
|
6857
|
+
cleanedText = humanizeAiTextQuotes(cleanedText);
|
|
6858
|
+
cleanedText = humanizeAiTextWhitespace(cleanedText);
|
|
6859
|
+
return cleanedText;
|
|
6860
|
+
}
|
|
6861
|
+
/**
|
|
6862
|
+
* TODO: [🅾️] !!! Use this across the project where AI text is involved
|
|
6863
|
+
*/
|
|
6864
|
+
|
|
6865
|
+
/**
|
|
6866
|
+
* Function `promptbookifyAiText` will slightly modify the text so we know it was processed by Promptbook
|
|
6867
|
+
*
|
|
6868
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
6869
|
+
*/
|
|
6870
|
+
function promptbookifyAiText(text) {
|
|
6871
|
+
// Note: Duplicating some spaces
|
|
6872
|
+
const words = text.split(' '); // <- Note: [✌️] Use `splitWords` when available
|
|
6873
|
+
const wordLength = words.length; // <- Note: [✌️] `countWords` should be just `splitWords(...).length`
|
|
6874
|
+
for (const wordIndex of [3, 7, 11, 19].filter((i) => i < wordLength)) {
|
|
6875
|
+
words[wordIndex] = ' ' + words[wordIndex];
|
|
6876
|
+
}
|
|
6877
|
+
const promptbookifiedText = words.join(' ');
|
|
6878
|
+
return promptbookifiedText;
|
|
6879
|
+
}
|
|
6880
|
+
/**
|
|
6881
|
+
* TODO: [🅾️]!!! Use this across the project where AI text is involved
|
|
6882
|
+
* TODO: [🧠][✌️] Make some Promptbook-native token system
|
|
6883
|
+
*/
|
|
6884
|
+
|
|
6776
6885
|
/**
|
|
6777
6886
|
* Removes Markdown formatting tags from a string.
|
|
6778
6887
|
*
|
|
@@ -6790,5 +6899,20 @@ function removeMarkdownFormatting(str) {
|
|
|
6790
6899
|
return str;
|
|
6791
6900
|
}
|
|
6792
6901
|
|
|
6793
|
-
|
|
6902
|
+
/**
|
|
6903
|
+
* Removes Markdown link tags from a string.
|
|
6904
|
+
*
|
|
6905
|
+
* @param {string} str - The string to remove Markdown tags from.
|
|
6906
|
+
* @returns {string} The input string with all Markdown tags removed.
|
|
6907
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
6908
|
+
*/
|
|
6909
|
+
function removeMarkdownLinks(str) {
|
|
6910
|
+
// Use regular expressions to remove Markdown tags from the string
|
|
6911
|
+
return str.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '$1');
|
|
6912
|
+
}
|
|
6913
|
+
/**
|
|
6914
|
+
* @see https://chat.openai.com/chat/bb7c3a5b-fe9c-4ccc-9057-f47e0fd66489
|
|
6915
|
+
*/
|
|
6916
|
+
|
|
6917
|
+
export { BOOK_LANGUAGE_VERSION, MarkdownScraper, PROMPTBOOK_ENGINE_VERSION, _MarkdownScraperRegistration, addAutoGeneratedSection, createMarkdownChart, createMarkdownScraper, createMarkdownTable, escapeMarkdownBlock, extractAllBlocksFromMarkdown, extractAllListItemsFromMarkdown, extractBlock, extractJsonBlock, extractOneBlockFromMarkdown, flattenMarkdown, humanizeAiText, humanizeAiTextEllipsis, humanizeAiTextEmdashed, humanizeAiTextQuotes, humanizeAiTextWhitespace, parseMarkdownSection, promptbookifyAiText, removeMarkdownComments, removeMarkdownFormatting, removeMarkdownLinks, splitMarkdownIntoSections };
|
|
6794
6918
|
//# sourceMappingURL=index.es.js.map
|