@promptbook/remote-server 0.50.0-13 → 0.50.0-15

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 (27) hide show
  1. package/esm/index.es.js +1 -1
  2. package/esm/typings/_packages/utils.index.d.ts +9 -2
  3. package/esm/typings/conversion/utils/extractParametersFromPromptTemplate.d.ts +13 -0
  4. package/esm/typings/conversion/utils/extractParametersFromPromptTemplate.test.d.ts +1 -0
  5. package/esm/typings/conversion/utils/extractVariables.d.ts +4 -3
  6. package/esm/typings/types/PromptbookJson/PromptTemplateJson.d.ts +1 -1
  7. package/esm/typings/utils/extractParameters.d.ts +1 -3
  8. package/esm/typings/utils/sets/difference.d.ts +4 -0
  9. package/esm/typings/utils/sets/difference.test.d.ts +1 -0
  10. package/esm/typings/utils/sets/intersection.d.ts +4 -0
  11. package/esm/typings/utils/sets/intersection.test.d.ts +1 -0
  12. package/esm/typings/utils/sets/union.d.ts +4 -0
  13. package/esm/typings/utils/sets/union.test.d.ts +1 -0
  14. package/package.json +2 -2
  15. package/umd/index.umd.js +1 -1
  16. package/umd/typings/_packages/utils.index.d.ts +9 -2
  17. package/umd/typings/conversion/utils/extractParametersFromPromptTemplate.d.ts +13 -0
  18. package/umd/typings/conversion/utils/extractParametersFromPromptTemplate.test.d.ts +1 -0
  19. package/umd/typings/conversion/utils/extractVariables.d.ts +4 -3
  20. package/umd/typings/types/PromptbookJson/PromptTemplateJson.d.ts +1 -1
  21. package/umd/typings/utils/extractParameters.d.ts +1 -3
  22. package/umd/typings/utils/sets/difference.d.ts +4 -0
  23. package/umd/typings/utils/sets/difference.test.d.ts +1 -0
  24. package/umd/typings/utils/sets/intersection.d.ts +4 -0
  25. package/umd/typings/utils/sets/intersection.test.d.ts +1 -0
  26. package/umd/typings/utils/sets/union.d.ts +4 -0
  27. package/umd/typings/utils/sets/union.test.d.ts +1 -0
package/esm/index.es.js CHANGED
@@ -89,7 +89,7 @@ var PromptbookExecutionError = /** @class */ (function (_super) {
89
89
  /**
90
90
  * The version of the Promptbook library
91
91
  */
92
- var PROMPTBOOK_VERSION = '0.50.0-12';
92
+ var PROMPTBOOK_VERSION = '0.50.0-14';
93
93
 
94
94
  /**
95
95
  * Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
@@ -1,6 +1,8 @@
1
1
  import { spaceTrim } from 'spacetrim';
2
2
  import { prettifyPromptbookString } from '../conversion/prettify/prettifyPromptbookString';
3
3
  import { renderPromptbookMermaid } from '../conversion/prettify/renderPromptbookMermaid';
4
+ import { extractParametersFromPromptTemplate } from '../conversion/utils/extractParametersFromPromptTemplate';
5
+ import { extractVariables } from '../conversion/utils/extractVariables';
4
6
  import { parseNumber } from '../conversion/utils/parseNumber';
5
7
  import { renameParameter } from '../conversion/utils/renameParameter';
6
8
  import { titleToName } from '../conversion/utils/titleToName';
@@ -16,6 +18,7 @@ import { countPages } from '../utils/expectation-counters/countPages';
16
18
  import { countParagraphs } from '../utils/expectation-counters/countParagraphs';
17
19
  import { countSentences, splitIntoSentences } from '../utils/expectation-counters/countSentences';
18
20
  import { countWords } from '../utils/expectation-counters/countWords';
21
+ import { extractParameters } from '../utils/extractParameters';
19
22
  import { isValidJsonString } from '../utils/isValidJsonString';
20
23
  import { extractAllBlocksFromMarkdown } from '../utils/markdown/extractAllBlocksFromMarkdown';
21
24
  import { extractAllListItemsFromMarkdown } from '../utils/markdown/extractAllListItemsFromMarkdown';
@@ -42,12 +45,15 @@ import { searchKeywords } from '../utils/normalization/searchKeywords';
42
45
  import { extractBlock } from '../utils/postprocessing/extractBlock';
43
46
  import { removeEmojis } from '../utils/removeEmojis';
44
47
  import { removeQuotes } from '../utils/removeQuotes';
48
+ import { difference } from '../utils/sets/difference';
49
+ import { intersection } from '../utils/sets/intersection';
50
+ import { union } from '../utils/sets/union';
45
51
  import { trimCodeBlock } from '../utils/trimCodeBlock';
46
52
  import { trimEndOfCodeBlock } from '../utils/trimEndOfCodeBlock';
47
53
  import { unwrapResult } from '../utils/unwrapResult';
48
54
  export { assertsExecutionSuccessful, checkExpectations, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, extractAllBlocksFromMarkdown, // <- [🌻]
49
55
  extractAllListItemsFromMarkdown, extractBlock, // <- [🌻]
50
- extractOneBlockFromMarkdown, isPassingExpectations, isValidJsonString, parseNumber, // <- [🌻]
56
+ extractOneBlockFromMarkdown, extractParameters, extractVariables, isPassingExpectations, isValidJsonString, parseNumber, // <- [🌻]
51
57
  prettifyPromptbookString, removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, replaceParameters, spaceTrim, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
52
58
  export { countCharacters, countLines, countPages, countParagraphs, countSentences, CountUtils, countWords };
53
59
  export { splitIntoSentences };
@@ -59,7 +65,8 @@ export declare const normalizeTo: {
59
65
  'kebab-case': typeof normalizeToKebabCase;
60
66
  };
61
67
  export { capitalize, decapitalize, DIACRITIC_VARIANTS_LETTERS, IKeywords, isValidKeyword, nameToUriPart, nameToUriParts, normalizeTo_camelCase, normalizeTo_PascalCase, normalizeTo_SCREAMING_CASE, normalizeTo_snake_case, normalizeToKebabCase, normalizeWhitespaces, parseKeywords, parseKeywordsFromString, removeDiacritics, searchKeywords, string_keyword, titleToName, };
62
- export { renameParameter, renderPromptbookMermaid };
68
+ export { extractParametersFromPromptTemplate, renameParameter, renderPromptbookMermaid };
69
+ export { difference, intersection, union };
63
70
  /**
64
71
  * TODO: [🧠] Maybe create some indipendent package like `markdown-tools` from both here exported and @private utilities
65
72
  * Note: [🕙] It does not make sence to have simple lower / UPPER case normalization
@@ -0,0 +1,13 @@
1
+ import { PromptTemplateJson } from '../../types/PromptbookJson/PromptTemplateJson';
2
+ import { string_name } from '../../types/typeAliases';
3
+ /**
4
+ * Parses the prompt template and returns the set of all used parameters
5
+ *
6
+ * @param promptTemplate the template with used parameters
7
+ * @returns the set of parameter names
8
+ * @throws {PromptbookSyntaxError} if the script is invalid
9
+ */
10
+ export declare function extractParametersFromPromptTemplate(promptTemplate: Pick<PromptTemplateJson, 'title' | 'description' | 'executionType' | 'content'>): Set<string_name>;
11
+ /**
12
+ * TODO: [🔣] If script require contentLanguage
13
+ */
@@ -5,7 +5,8 @@ import { string_javascript, string_javascript_name } from '../../types/typeAlias
5
5
  * @param script from which to extract the variables
6
6
  * @returns the list of variable names
7
7
  * @throws {PromptbookSyntaxError} if the script is invalid
8
- *
9
- * @private within the promptbookStringToJson
10
8
  */
11
- export declare function extractVariables(script: string_javascript): Array<string_javascript_name>;
9
+ export declare function extractVariables(script: string_javascript): Set<string_javascript_name>;
10
+ /**
11
+ * TODO: [🔣] Support for multiple languages - python, java,...
12
+ */
@@ -32,7 +32,7 @@ export type Expectations = Partial<Record<Lowercase<ExpectationUnit>, {
32
32
  /**
33
33
  * Units of text measurement
34
34
  */
35
- export declare const EXPECTATION_UNITS: readonly ["CHARACTERS", "WORDS", "SENTENCES", "PARAGRAPHS", "LINES", "PAGES"];
35
+ export declare const EXPECTATION_UNITS: readonly ["CHARACTERS", "WORDS", "SENTENCES", "LINES", "PARAGRAPHS", "PAGES"];
36
36
  /**
37
37
  * Unit of text measurement
38
38
  */
@@ -4,7 +4,5 @@ import { string_name, string_template } from '../types/typeAliases';
4
4
  *
5
5
  * @param template the template with parameters in {curly} braces
6
6
  * @returns the list of parameter names
7
- *
8
- * @private within the library
9
7
  */
10
- export declare function extractParameters(template: string_template): Array<string_name>;
8
+ export declare function extractParameters(template: string_template): Set<string_name>;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Create difference set of two sets.
3
+ */
4
+ export declare function difference<TItem>(a: Set<TItem>, b: Set<TItem>, isEqual?: (a: TItem, b: TItem) => boolean): Set<TItem>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Creates a new set with all elements that are present in all sets
3
+ */
4
+ export declare function intersection<TItem>(...sets: Array<Set<TItem>>): Set<TItem>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Creates a new set with all elements that are present in either set
3
+ */
4
+ export declare function union<TItem>(...sets: Array<Set<TItem>>): Set<TItem>;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/remote-server",
3
- "version": "0.50.0-13",
3
+ "version": "0.50.0-15",
4
4
  "description": "Library to supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -49,7 +49,7 @@
49
49
  }
50
50
  ],
51
51
  "peerDependencies": {
52
- "@promptbook/core": "0.50.0-13"
52
+ "@promptbook/core": "0.50.0-15"
53
53
  },
54
54
  "main": "./umd/index.umd.js",
55
55
  "module": "./esm/index.es.js",
package/umd/index.umd.js CHANGED
@@ -95,7 +95,7 @@
95
95
  /**
96
96
  * The version of the Promptbook library
97
97
  */
98
- var PROMPTBOOK_VERSION = '0.50.0-12';
98
+ var PROMPTBOOK_VERSION = '0.50.0-14';
99
99
 
100
100
  /**
101
101
  * Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
@@ -1,6 +1,8 @@
1
1
  import { spaceTrim } from 'spacetrim';
2
2
  import { prettifyPromptbookString } from '../conversion/prettify/prettifyPromptbookString';
3
3
  import { renderPromptbookMermaid } from '../conversion/prettify/renderPromptbookMermaid';
4
+ import { extractParametersFromPromptTemplate } from '../conversion/utils/extractParametersFromPromptTemplate';
5
+ import { extractVariables } from '../conversion/utils/extractVariables';
4
6
  import { parseNumber } from '../conversion/utils/parseNumber';
5
7
  import { renameParameter } from '../conversion/utils/renameParameter';
6
8
  import { titleToName } from '../conversion/utils/titleToName';
@@ -16,6 +18,7 @@ import { countPages } from '../utils/expectation-counters/countPages';
16
18
  import { countParagraphs } from '../utils/expectation-counters/countParagraphs';
17
19
  import { countSentences, splitIntoSentences } from '../utils/expectation-counters/countSentences';
18
20
  import { countWords } from '../utils/expectation-counters/countWords';
21
+ import { extractParameters } from '../utils/extractParameters';
19
22
  import { isValidJsonString } from '../utils/isValidJsonString';
20
23
  import { extractAllBlocksFromMarkdown } from '../utils/markdown/extractAllBlocksFromMarkdown';
21
24
  import { extractAllListItemsFromMarkdown } from '../utils/markdown/extractAllListItemsFromMarkdown';
@@ -42,12 +45,15 @@ import { searchKeywords } from '../utils/normalization/searchKeywords';
42
45
  import { extractBlock } from '../utils/postprocessing/extractBlock';
43
46
  import { removeEmojis } from '../utils/removeEmojis';
44
47
  import { removeQuotes } from '../utils/removeQuotes';
48
+ import { difference } from '../utils/sets/difference';
49
+ import { intersection } from '../utils/sets/intersection';
50
+ import { union } from '../utils/sets/union';
45
51
  import { trimCodeBlock } from '../utils/trimCodeBlock';
46
52
  import { trimEndOfCodeBlock } from '../utils/trimEndOfCodeBlock';
47
53
  import { unwrapResult } from '../utils/unwrapResult';
48
54
  export { assertsExecutionSuccessful, checkExpectations, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, extractAllBlocksFromMarkdown, // <- [🌻]
49
55
  extractAllListItemsFromMarkdown, extractBlock, // <- [🌻]
50
- extractOneBlockFromMarkdown, isPassingExpectations, isValidJsonString, parseNumber, // <- [🌻]
56
+ extractOneBlockFromMarkdown, extractParameters, extractVariables, isPassingExpectations, isValidJsonString, parseNumber, // <- [🌻]
51
57
  prettifyPromptbookString, removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, replaceParameters, spaceTrim, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
52
58
  export { countCharacters, countLines, countPages, countParagraphs, countSentences, CountUtils, countWords };
53
59
  export { splitIntoSentences };
@@ -59,7 +65,8 @@ export declare const normalizeTo: {
59
65
  'kebab-case': typeof normalizeToKebabCase;
60
66
  };
61
67
  export { capitalize, decapitalize, DIACRITIC_VARIANTS_LETTERS, IKeywords, isValidKeyword, nameToUriPart, nameToUriParts, normalizeTo_camelCase, normalizeTo_PascalCase, normalizeTo_SCREAMING_CASE, normalizeTo_snake_case, normalizeToKebabCase, normalizeWhitespaces, parseKeywords, parseKeywordsFromString, removeDiacritics, searchKeywords, string_keyword, titleToName, };
62
- export { renameParameter, renderPromptbookMermaid };
68
+ export { extractParametersFromPromptTemplate, renameParameter, renderPromptbookMermaid };
69
+ export { difference, intersection, union };
63
70
  /**
64
71
  * TODO: [🧠] Maybe create some indipendent package like `markdown-tools` from both here exported and @private utilities
65
72
  * Note: [🕙] It does not make sence to have simple lower / UPPER case normalization
@@ -0,0 +1,13 @@
1
+ import { PromptTemplateJson } from '../../types/PromptbookJson/PromptTemplateJson';
2
+ import { string_name } from '../../types/typeAliases';
3
+ /**
4
+ * Parses the prompt template and returns the set of all used parameters
5
+ *
6
+ * @param promptTemplate the template with used parameters
7
+ * @returns the set of parameter names
8
+ * @throws {PromptbookSyntaxError} if the script is invalid
9
+ */
10
+ export declare function extractParametersFromPromptTemplate(promptTemplate: Pick<PromptTemplateJson, 'title' | 'description' | 'executionType' | 'content'>): Set<string_name>;
11
+ /**
12
+ * TODO: [🔣] If script require contentLanguage
13
+ */
@@ -5,7 +5,8 @@ import { string_javascript, string_javascript_name } from '../../types/typeAlias
5
5
  * @param script from which to extract the variables
6
6
  * @returns the list of variable names
7
7
  * @throws {PromptbookSyntaxError} if the script is invalid
8
- *
9
- * @private within the promptbookStringToJson
10
8
  */
11
- export declare function extractVariables(script: string_javascript): Array<string_javascript_name>;
9
+ export declare function extractVariables(script: string_javascript): Set<string_javascript_name>;
10
+ /**
11
+ * TODO: [🔣] Support for multiple languages - python, java,...
12
+ */
@@ -32,7 +32,7 @@ export type Expectations = Partial<Record<Lowercase<ExpectationUnit>, {
32
32
  /**
33
33
  * Units of text measurement
34
34
  */
35
- export declare const EXPECTATION_UNITS: readonly ["CHARACTERS", "WORDS", "SENTENCES", "PARAGRAPHS", "LINES", "PAGES"];
35
+ export declare const EXPECTATION_UNITS: readonly ["CHARACTERS", "WORDS", "SENTENCES", "LINES", "PARAGRAPHS", "PAGES"];
36
36
  /**
37
37
  * Unit of text measurement
38
38
  */
@@ -4,7 +4,5 @@ import { string_name, string_template } from '../types/typeAliases';
4
4
  *
5
5
  * @param template the template with parameters in {curly} braces
6
6
  * @returns the list of parameter names
7
- *
8
- * @private within the library
9
7
  */
10
- export declare function extractParameters(template: string_template): Array<string_name>;
8
+ export declare function extractParameters(template: string_template): Set<string_name>;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Create difference set of two sets.
3
+ */
4
+ export declare function difference<TItem>(a: Set<TItem>, b: Set<TItem>, isEqual?: (a: TItem, b: TItem) => boolean): Set<TItem>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Creates a new set with all elements that are present in all sets
3
+ */
4
+ export declare function intersection<TItem>(...sets: Array<Set<TItem>>): Set<TItem>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Creates a new set with all elements that are present in either set
3
+ */
4
+ export declare function union<TItem>(...sets: Array<Set<TItem>>): Set<TItem>;
@@ -0,0 +1 @@
1
+ export {};